-
Notifications
You must be signed in to change notification settings - Fork 219
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
Add handling nested properties during resolving jwt placeholders #1996
Add handling nested properties during resolving jwt placeholders #1996
Conversation
@dimabarbul thanks a lot for the PR. |
@thjaeckle Give me some time (couple of days or so), please, I want to make another version with HashSet instead of Stream for comparison. I haven't checked performance, but I'm pretty sure, HashSet version should be better. |
HashSet version is: private static Set<String> resolveValues(final JsonValue jsonValue, final JsonPointer jsonPointer) {
final Set<String> result = new HashSet<>();
resolveValuesInner(jsonValue, jsonPointer, result);
return result;
}
private static void resolveValuesInner(
final JsonValue jsonValue, final JsonPointer jsonPointer, final Set<String> result) {
jsonPointer.getRoot()
.ifPresentOrElse(
root -> {
if (jsonValue.isArray()) {
jsonValue.asArray().stream()
.forEach(item -> resolveValuesInner(item, jsonPointer, result));
} else if (jsonValue.isObject()) {
jsonValue.asObject().getValue(root)
.ifPresent(v -> resolveValuesInner(v, jsonPointer.nextLevel(), result));
}
},
() -> {
if (jsonValue.isArray()) {
jsonValue.asArray().stream().map(JsonValue::formatAsString).forEach(result::add);
} else {
result.add(jsonValue.formatAsString());
}
});
} I've roughly measured performance of HashSet and Stream versions (using |
Signed-off-by: Dmitriy Barbul <dimabarbul@gmail.com>
cebc31d
to
de633fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimabarbul LGTM 👍
I just rebased from master
branch and removed the "mutablity" unit test - as this is no longer possible to do with the updated Java version 21 (which was merged in the meantime on master).
Thanks a lot.
Resolves #1985