Skip to content

Commit e285da1

Browse files
jkebingerclaude
andauthored
Change Micronaut context attribute key to avoid collision with prefab-sdk (#16)
* Change Micronaut context attribute key to avoid collision with prefab-sdk Update the HTTP request attribute name from "prefab-contexts" to "reforge-sdk-contexts" to prevent conflicts when using this SDK concurrently with the previous prefab-sdk. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Bumps version to 1.0.2 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 39e5683 commit e285da1

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

micronaut/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.reforge</groupId>
66
<artifactId>sdk-parent</artifactId>
7-
<version>1.0.1</version>
7+
<version>1.0.2</version>
88
</parent>
99

1010
<artifactId>sdk-micronaut-extension</artifactId>

micronaut/src/main/java/com/reforge/sdk/extensions/micronaut/ServerRequestContextStore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
public class ServerRequestContextStore implements ContextStore {
1717

18-
public static final String ATTRIBUTE_NAME = "prefab-contexts";
18+
public static final String ATTRIBUTE_NAME = "reforge-sdk-contexts";
1919

2020
@Override
2121
public void addContext(Context context) {
22-
getPrefabContextSet()
22+
getReforgeContextSet()
2323
.ifPresentOrElse(
2424
prefabContextSet -> prefabContextSet.addContext(context),
2525
() -> setContext(context)
@@ -50,10 +50,10 @@ public Optional<ContextSetReadable> clearContext() {
5050

5151
@Override
5252
public Optional<ContextSetReadable> getContext() {
53-
return getPrefabContextSet().map(ContextSetReadable::readOnlyContextSetView);
53+
return getReforgeContextSet().map(ContextSetReadable::readOnlyContextSetView);
5454
}
5555

56-
private Optional<ContextSet> getPrefabContextSet() {
56+
private Optional<ContextSet> getReforgeContextSet() {
5757
return ServerRequestContext
5858
.currentRequest()
5959
.flatMap(objectHttpRequest ->

micronaut/src/test/java/com/reforge/sdk/extensions/micronaut/ServerRequestContextStoreTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class ServerRequestContextStoreTest {
1515

16-
ServerRequestContextStore prefabStateStore = new ServerRequestContextStore();
16+
ServerRequestContextStore reforgeSdkContextStore = new ServerRequestContextStore();
1717
Context userContext = Context.newBuilder("user").put("country", "us").build();
1818
Context serverContext = Context.newBuilder("server").put("az", "2").build();
1919

@@ -29,25 +29,25 @@ void beforeEach() {
2929

3030
@Test
3131
void getContextReturnsEmpty() {
32-
assertThat(prefabStateStore.getContext()).isEmpty();
32+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
3333
}
3434

3535
@Test
3636
void setContextQuietlyDoesNothing() {
37-
assertThat(prefabStateStore.setContext(userAndServerContextSet)).isEmpty();
38-
assertThat(prefabStateStore.getContext()).isEmpty();
37+
assertThat(reforgeSdkContextStore.setContext(userAndServerContextSet)).isEmpty();
38+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
3939
}
4040

4141
@Test
4242
void addContextQuietlyDoesNothing() {
43-
prefabStateStore.addContext(userContext);
44-
assertThat(prefabStateStore.getContext()).isEmpty();
43+
reforgeSdkContextStore.addContext(userContext);
44+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
4545
}
4646

4747
@Test
4848
void clearContextQuietlyDoesNothing() {
49-
assertThat(prefabStateStore.clearContext()).isEmpty();
50-
assertThat(prefabStateStore.getContext()).isEmpty();
49+
assertThat(reforgeSdkContextStore.clearContext()).isEmpty();
50+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
5151
}
5252
}
5353

@@ -63,18 +63,18 @@ void beforeEach() {
6363

6464
@Test
6565
void getContextReturnsEmptyWhenNoContextSet() {
66-
assertThat(prefabStateStore.getContext()).isEmpty();
66+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
6767
}
6868

6969
@Test
7070
void setContextReturnsEmptyWhenNoContextSet() {
71-
assertThat(prefabStateStore.setContext(userAndServerContextSet)).isEmpty();
71+
assertThat(reforgeSdkContextStore.setContext(userAndServerContextSet)).isEmpty();
7272
}
7373

7474
@Test
7575
void addContextWhenEmptyUpdatesTheContext() {
76-
prefabStateStore.addContext(userContext);
77-
assertThat(prefabStateStore.getContext())
76+
reforgeSdkContextStore.addContext(userContext);
77+
assertThat(reforgeSdkContextStore.getContext())
7878
.isPresent()
7979
.get()
8080
.usingRecursiveComparison()
@@ -83,8 +83,8 @@ void addContextWhenEmptyUpdatesTheContext() {
8383

8484
@Test
8585
void clearReturnsEmpty() {
86-
assertThat(prefabStateStore.clearContext()).isEmpty();
87-
assertThat(prefabStateStore.getContext()).isEmpty();
86+
assertThat(reforgeSdkContextStore.clearContext()).isEmpty();
87+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
8888
}
8989

9090
@Nested
@@ -98,12 +98,12 @@ class WithPreExistingContext {
9898

9999
@BeforeEach
100100
void beforeEach() {
101-
prefabStateStore.setContext(userAndServerContextSet);
101+
reforgeSdkContextStore.setContext(userAndServerContextSet);
102102
}
103103

104104
@Test
105105
void getReturnsExpectedSet() {
106-
assertThat(prefabStateStore.getContext())
106+
assertThat(reforgeSdkContextStore.getContext())
107107
.isPresent()
108108
.get()
109109
.usingRecursiveComparison()
@@ -112,22 +112,22 @@ void getReturnsExpectedSet() {
112112

113113
@Test
114114
void clearWorksAsExpected() {
115-
assertThat(prefabStateStore.clearContext())
115+
assertThat(reforgeSdkContextStore.clearContext())
116116
.isPresent()
117117
.get()
118118
.usingRecursiveComparison()
119119
.isEqualTo(userAndServerContextSet);
120-
assertThat(prefabStateStore.getContext()).isEmpty();
120+
assertThat(reforgeSdkContextStore.getContext()).isEmpty();
121121
}
122122

123123
@Test
124124
void setWorksAsExpected() {
125-
assertThat(prefabStateStore.setContext(userContext))
125+
assertThat(reforgeSdkContextStore.setContext(userContext))
126126
.isPresent()
127127
.get()
128128
.usingRecursiveComparison()
129129
.isEqualTo(userAndServerContextSet);
130-
assertThat(prefabStateStore.getContext())
130+
assertThat(reforgeSdkContextStore.getContext())
131131
.isPresent()
132132
.get()
133133
.usingRecursiveComparison()
@@ -136,8 +136,8 @@ void setWorksAsExpected() {
136136

137137
@Test
138138
void addWorksAsExpected() {
139-
prefabStateStore.addContext(newUserContext);
140-
assertThat(prefabStateStore.getContext())
139+
reforgeSdkContextStore.addContext(newUserContext);
140+
assertThat(reforgeSdkContextStore.getContext())
141141
.isPresent()
142142
.get()
143143
.usingRecursiveComparison()

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<groupId>com.reforge</groupId>
1212
<artifactId>sdk-parent</artifactId>
1313

14-
<version>1.0.1</version>
14+
<version>1.0.2</version>
1515
<packaging>pom</packaging>
1616
<name>Reforge SDK Parent POM</name>
1717
<description>Parent POM for Reforge SDK modules providing feature flags, configuration management, and A/B testing capabilities</description>

sdk/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.reforge</groupId>
66
<artifactId>sdk-parent</artifactId>
7-
<version>1.0.1</version>
7+
<version>1.0.2</version>
88
</parent>
99

1010
<artifactId>sdk</artifactId>

0 commit comments

Comments
 (0)