Skip to content

Commit d78c99c

Browse files
authored
feat: remove the deprecated setTargetingKey method in EvaluationContext. (open-feature#290)
remove the deprecated setTargetingKey method in EvaluationContext. Signed-off-by: thiyagu06 <[email protected]>
1 parent 4102495 commit d78c99c

File tree

4 files changed

+2
-24
lines changed

4 files changed

+2
-24
lines changed

src/main/java/dev/openfeature/sdk/EvaluationContext.java

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
@SuppressWarnings("PMD.BeanMembersShouldSerialize")
88
public interface EvaluationContext extends Structure {
99
String getTargetingKey();
10-
11-
/**
12-
* Mutating targeting key is not supported in all implementations and will be removed.
13-
*/
14-
@Deprecated
15-
void setTargetingKey(String targetingKey);
1610

1711
/**
1812
* Merges this EvaluationContext object with the second overriding the this in

src/main/java/dev/openfeature/sdk/ImmutableContext.java

-9
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ public ImmutableContext(String targetingKey, Map<String, Value> attributes) {
5858
this.targetingKey = targetingKey;
5959
}
6060

61-
/**
62-
* Mutating targeting key is not supported in ImmutableContext and will be removed.
63-
*/
64-
@Override
65-
@Deprecated
66-
public void setTargetingKey(String targetingKey) {
67-
throw new UnsupportedOperationException("changing of targeting key is not allowed");
68-
}
69-
7061
/**
7162
* Merges this EvaluationContext object with the passed EvaluationContext, overriding in case of conflict.
7263
*

src/test/java/dev/openfeature/sdk/EvalContextTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public class EvalContextTest {
164164

165165
@Test void merge_targeting_key() {
166166
String key1 = "key1";
167-
EvaluationContext ctx1 = new MutableContext(key1);
168-
EvaluationContext ctx2 = new MutableContext();
167+
MutableContext ctx1 = new MutableContext(key1);
168+
MutableContext ctx2 = new MutableContext();
169169

170170
EvaluationContext ctxMerged = ctx1.merge(ctx2);
171171
assertEquals(key1, ctxMerged.getTargetingKey());

src/test/java/dev/openfeature/sdk/ImmutableContextTest.java

-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@
1212

1313
class ImmutableContextTest {
1414

15-
@Test
16-
@DisplayName("Mutating targeting key is not allowed on Immutable Context")
17-
void shouldThrowUnsupportedExceptionWhenMutatingTargetingKey() {
18-
EvaluationContext ctx = new ImmutableContext("targeting key", new HashMap<>());
19-
assertThrows(UnsupportedOperationException.class, () -> ctx.setTargetingKey(""));
20-
}
21-
2215
@DisplayName("attributes mutation should not affect the immutable context")
2316
@Test
2417
void shouldCreateCopyOfAttributesForImmutableContext() {

0 commit comments

Comments
 (0)