From 2db3d640273595da506483aa2cca1f1ad3d4eec5 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:00:33 -0700 Subject: [PATCH 1/6] chore(deps): bump test and plugins deps --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 1a3bdf4..79a5a90 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ 2.0.18 - 5.3.2 + 5.4.0 6.1.0 2.3.0 6.1.0 @@ -67,11 +67,11 @@ 3.15.0 3.4.0 3.12.0 - 3.5.5 + 3.5.6 3.2.8 - 5.6.0.6792 - 0.8.14 - 0.10.0 + 5.7.0.6970 + 0.8.15 + 0.11.0 jacoco From 727e19e655a3d13c3b04cc31e91ce7899a9b7518 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:25:36 -0700 Subject: [PATCH 2/6] fix(test): force context init --- src/test/java/com/switcherapi/client/SwitcherFail3Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/switcherapi/client/SwitcherFail3Test.java b/src/test/java/com/switcherapi/client/SwitcherFail3Test.java index 9f846f0..4c5bc61 100644 --- a/src/test/java/com/switcherapi/client/SwitcherFail3Test.java +++ b/src/test/java/com/switcherapi/client/SwitcherFail3Test.java @@ -16,7 +16,7 @@ class SwitcherFail3Test { @Test void shouldNotRegisterSwitcher_nullKey() { //given - TestCaseNull.configure(ContextBuilder.builder() + TestCaseNull.configure(ContextBuilder.builder(true) .context(TestCaseNull.class.getName()) .snapshotLocation(SNAPSHOTS_LOCAL) .local(true)); @@ -30,7 +30,7 @@ void shouldNotRegisterSwitcher_nullKey() { @Test void shouldNotRegisterSwitcher_emptyKey() { //given - TestCaseEmpty.configure(ContextBuilder.builder() + TestCaseEmpty.configure(ContextBuilder.builder(true) .context(TestCaseEmpty.class.getName()) .snapshotLocation(SNAPSHOTS_LOCAL) .local(true)); From 8d8b520239a5050d66b15428d894bf55caad3b26 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 14:47:22 -0700 Subject: [PATCH 3/6] Revert "fix(test): force context init" This reverts commit 727e19e655a3d13c3b04cc31e91ce7899a9b7518. --- src/test/java/com/switcherapi/client/SwitcherFail3Test.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/switcherapi/client/SwitcherFail3Test.java b/src/test/java/com/switcherapi/client/SwitcherFail3Test.java index 4c5bc61..9f846f0 100644 --- a/src/test/java/com/switcherapi/client/SwitcherFail3Test.java +++ b/src/test/java/com/switcherapi/client/SwitcherFail3Test.java @@ -16,7 +16,7 @@ class SwitcherFail3Test { @Test void shouldNotRegisterSwitcher_nullKey() { //given - TestCaseNull.configure(ContextBuilder.builder(true) + TestCaseNull.configure(ContextBuilder.builder() .context(TestCaseNull.class.getName()) .snapshotLocation(SNAPSHOTS_LOCAL) .local(true)); @@ -30,7 +30,7 @@ void shouldNotRegisterSwitcher_nullKey() { @Test void shouldNotRegisterSwitcher_emptyKey() { //given - TestCaseEmpty.configure(ContextBuilder.builder(true) + TestCaseEmpty.configure(ContextBuilder.builder() .context(TestCaseEmpty.class.getName()) .snapshotLocation(SNAPSHOTS_LOCAL) .local(true)); From 0f7810188263b99080399b6c0fb4a7032a93afde Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 15:00:05 -0700 Subject: [PATCH 4/6] chore: added debug logs for registerSwitcherKey --- src/main/java/com/switcherapi/client/SwitcherContextBase.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/switcherapi/client/SwitcherContextBase.java b/src/main/java/com/switcherapi/client/SwitcherContextBase.java index 4f2fa7f..e24ba8a 100644 --- a/src/main/java/com/switcherapi/client/SwitcherContextBase.java +++ b/src/main/java/com/switcherapi/client/SwitcherContextBase.java @@ -249,6 +249,8 @@ private static void registerSwitcherKeys() { private static void registerSwitcherKey(Field[] fields) { Set switcherKeys = new HashSet<>(); + SwitcherUtils.debug(logger, "Registering Switcher Keys from context: {}", contextStr(ContextKey.CONTEXT_LOCATION)); + SwitcherUtils.debug(logger, "Found {} fields in context class", fields.length); for (Field field : fields) { if (field.isAnnotationPresent(SwitcherKey.class)) { try { From 935d80c63339008a5cc706df8d1f808261805f54 Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 15:03:06 -0700 Subject: [PATCH 5/6] chore: added debug logs for registerSwitcherKey #2 --- src/main/java/com/switcherapi/client/SwitcherContextBase.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/switcherapi/client/SwitcherContextBase.java b/src/main/java/com/switcherapi/client/SwitcherContextBase.java index e24ba8a..30daccb 100644 --- a/src/main/java/com/switcherapi/client/SwitcherContextBase.java +++ b/src/main/java/com/switcherapi/client/SwitcherContextBase.java @@ -254,7 +254,9 @@ private static void registerSwitcherKey(Field[] fields) { for (Field field : fields) { if (field.isAnnotationPresent(SwitcherKey.class)) { try { - switcherKeys.add(field.get(null).toString()); + final String keyFound = field.get(null).toString(); + SwitcherUtils.debug(logger, "Found Switcher Key: {} in field: {}", keyFound, field.getName()); + switcherKeys.add(keyFound); } catch (Exception e) { throw new SwitcherContextException( String.format("Error retrieving Switcher Key value from field %s", field.getName())); From d69c1ed0db3bea3126b5e3d4534a1638f4c662ff Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sat, 27 Jun 2026 15:19:01 -0700 Subject: [PATCH 6/6] fix: registerSwitcherKeys to load contextBase from location --- .../java/com/switcherapi/client/SwitcherContextBase.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/switcherapi/client/SwitcherContextBase.java b/src/main/java/com/switcherapi/client/SwitcherContextBase.java index 30daccb..bee47d1 100644 --- a/src/main/java/com/switcherapi/client/SwitcherContextBase.java +++ b/src/main/java/com/switcherapi/client/SwitcherContextBase.java @@ -229,11 +229,13 @@ private static void validateContext() throws SwitcherContextException { * Register Switcher Keys based on context properties */ private static void registerSwitcherKeys() { - if (Objects.nonNull(contextBase)) { + final String contextLocation = contextStr(ContextKey.CONTEXT_LOCATION); + + if (Objects.nonNull(contextBase) && contextBase.getClass().getName().equals(contextLocation)) { registerSwitcherKey(contextBase.getClass().getFields()); } else { try { - final Class clazz = Class.forName(contextStr(ContextKey.CONTEXT_LOCATION)); + final Class clazz = Class.forName(contextLocation); registerSwitcherKey(clazz.getFields()); } catch(ClassNotFoundException e){ throw new SwitcherContextException(e.getMessage());