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

MODE-2637 : NullPointerException in IndexChangeAdapter #1606

Merged
merged 1 commit into from Nov 16, 2016

Conversation

okulikov
Copy link
Member

PR provides fix which substitutes empty array instead of null as value for not assigned multiple-value property.

@@ -803,6 +803,11 @@ public NodeTypesChangeAdapter( String property,
assert this.property != null;
}

private static Object[] valuesOf(Property property) {
return property.getValuesAsArray() != null ?
property.getValuesAsArray() : new Object[]{};
Copy link
Member

Choose a reason for hiding this comment

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

I think new Object[0]| is more concise, since an empty array initializer doesn't make sense

@FixFor("MODE-2637")
public void copyNodeWithEmptyMultiValueProperty() throws Exception {
// start a repository with some indexes
String configuration =
Copy link
Member

Choose a reason for hiding this comment

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

this should be extracted in a separate JSON configuration file

@hchiorean
Copy link
Member

@okulikov : this fixes the symptom of the bug, but I'm not convinced it fixes the original cause: the current code checks that a property !isEmpty() prior to reading the values from the property. However, it seems to me that isEmpty() return false for a multi-value property with a null value ?!

If that is the case, IMO this should be fixed and not the current extra checks from IndexChangeAdapter

@okulikov okulikov force-pushed the MODE-2637 branch 2 times, most recently from 87ae7bf to 3c62662 Compare November 15, 2016 10:23
@hchiorean
Copy link
Member

@okulikov: looks great

@hchiorean hchiorean merged commit f0884f0 into ModeShape:master Nov 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants