[OGNL-102] Improves performance when null was returned#140
Closed
lukaszlenart wants to merge 1 commit intomasterfrom
Closed
[OGNL-102] Improves performance when null was returned#140lukaszlenart wants to merge 1 commit intomasterfrom
lukaszlenart wants to merge 1 commit intomasterfrom
Conversation
137eadc to
54b18de
Compare
54b18de to
e5e2491
Compare
Collaborator
Author
Contributor
|
Hi @lukaszlenart , I'm sorry about the slow response (as always)! So, is With the following test, for example, the for-loop is still evaluated for the second node and the similar exception is thrown :
public void testNullHnadling() throws Exception {
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null, new DefaultMemberAccess(false));
Map<String, Object> root = new HashMap<>();
root.put("key1", null);
String expr = "key1.key2.key3";
assertNull(Ognl.getValue(expr, context, root));
} |
Collaborator
Author
|
Right, but if I did that on |
Contributor
|
Yes, it will change the designed behavior and @davoustp seems to be aware. I'll just show some tests that emphasizes the difference in behavior. public void testNullValue() throws Exception {
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null, new DefaultMemberAccess(false));
Map<String, Object> root = new HashMap<>();
root.put("key1", null);
String expr = "key1.key2.key3";
assertNull(Ognl.getValue(expr, context, root)); // FAIL : OgnlException
}
public void testEmptyRoot() throws Exception {
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null, new DefaultMemberAccess(false));
Map<String, Object> root = new HashMap<>();
String expr = "key1.key2.key3";
assertNull(Ognl.getValue(expr, context, root)); // FAIL : OgnlException
}
public void testNullRoot() throws Exception {
OgnlContext context = (OgnlContext) Ognl.createDefaultContext(null, new DefaultMemberAccess(false));
Map<String, Object> root = null;
String expr = "key1.key2.key3";
assertNull(Ognl.getValue(expr, context, root)); // PASS
} |
Collaborator
Author
|
Changes will be moved into #155 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improves performance of chained expressions in case if the
rootisnullRefs OGNL-102