diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index 1759faf..0347aac 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Get PR details id: pr - uses: actions/github-script@v7 + uses: actions/github-script@v9 with: script: | const pr = await github.rest.pulls.get({ diff --git a/pom.xml b/pom.xml index 16f092c..bcd322c 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 2.0.18 - 5.3.2 + 5.4.0 5.14.4 1.9.1 1.14.4 @@ -73,11 +73,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 diff --git a/src/main/java/com/switcherapi/client/SwitcherContextBase.java b/src/main/java/com/switcherapi/client/SwitcherContextBase.java index 83a6bed..126eb0f 100644 --- a/src/main/java/com/switcherapi/client/SwitcherContextBase.java +++ b/src/main/java/com/switcherapi/client/SwitcherContextBase.java @@ -230,11 +230,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()); @@ -250,10 +252,14 @@ 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 { - 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()));