Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed circular ref false positive during property resolution with mul… #269

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

ikasarov
Copy link
Contributor

@ikasarov ikasarov commented Aug 2, 2024

…tiple references

LMCROSSITXSADEPLOY-2936

Using multiple references linking to same variable was incorrectly detected as a circular reference - Fixed ref key context to reset on each subsequent ref.
Fixed error message in Tester class

@@ -171,8 +181,7 @@ protected Object resolveReferenceInDepth(Reference reference, Map<String, Object
currentProperty = resolveKeyInIterable(keyPart, (Collection<?>) currentProperty, deepReferenceKey);
keyPart = "";
} else if (currentProperty instanceof Map) {
@SuppressWarnings("unchecked")
Object subProperty = MapUtils.getObject((Map<Object, ?>) currentProperty, keyPart);
@SuppressWarnings("unchecked") Object subProperty = MapUtils.getObject((Map<Object, ?>) currentProperty, keyPart);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rest of the code @SuppressWarnings("unchecked") is on a separate row, please align

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

boolean resolutionContextWasCreated = false;
HashSet<String> contextKeysBackup = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to use Collections.emptySet() for collections instead of null.

@@ -171,8 +181,7 @@ protected Object resolveReferenceInDepth(Reference reference, Map<String, Object
currentProperty = resolveKeyInIterable(keyPart, (Collection<?>) currentProperty, deepReferenceKey);
keyPart = "";
} else if (currentProperty instanceof Map) {
@SuppressWarnings("unchecked")
Object subProperty = MapUtils.getObject((Map<Object, ?>) currentProperty, keyPart);
@SuppressWarnings("unchecked") Object subProperty = MapUtils.getObject((Map<Object, ?>) currentProperty, keyPart);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

void testResolve(String parameterName, String parameterValue, Expectation expectation) {
PropertiesResolver testResolver = new PropertiesResolver(null, irrelevant -> replacementValues, ReferencePattern.PLACEHOLDER,
"test-", false, Collections.emptySet());
tester.test(() -> testResolver.visit(parameterName, parameterValue), expectation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why invoked method was changed from resolveReferenceInDepth to visit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous method only tested a small portion of the code and couldn't resolve variables in depth (variables containing refs to other refs)

@ikasarov ikasarov merged commit 1037192 into master Aug 5, 2024
3 checks passed
@ikasarov ikasarov deleted the circular-ref-fix branch August 5, 2024 11:46
Copy link

sonarcloud bot commented Aug 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants