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

Value validation for indexed properties. #8404

Merged
merged 3 commits into from
Nov 25, 2016

Conversation

MishaDemianenko
Copy link
Contributor

@MishaDemianenko MishaDemianenko commented Nov 18, 2016

Introduce validation of property values for legacy and schema indexes.
Create validators for empty/null/allowable cases. Perform validation during property updated and index population.

changelog: Add validation of schema and legacy index values: do not allow nulls, values that over exceed lucene max term size, etc.

}
if ( value instanceof String )
{
IndexValueLengthValidator.INSTANCE.validate( ((String) value).getBytes() );
Copy link
Contributor

Choose a reason for hiding this comment

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

getBytes() here and in IndexValueValidator will cause decoding of chars and copying them in a newly allocated byte array. is this ok performance wise? maybe we can calculate bytes length manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are obviously right, those guys where just automagically moved from LuceneDocumentStructure to a specific validator, maybe it's time to clean that as well even if that is not the goal of this pr...

Copy link
Member

Choose a reason for hiding this comment

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

So schema indexes already did this, right? Then it's "OK" to add this slight extra garbage to legacy indexes as well imho

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind me. This validation has already been present for schema indexes just deeper in the call stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, that was the case for schema indexes before and we definitely can take a look into that in future if that will be required, i think for now it should be fine

@@ -131,16 +132,9 @@ private static void assertValidKey( String key )
}
}

private static void assertValidValue( Object singleValue )
protected void assertValidValue( Object value )
Copy link
Member

@tinwelint tinwelint Nov 22, 2016

Choose a reason for hiding this comment

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

Looks like this methods isn't actually needed anymore, or it could at least still remain private static, couldn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that was sneaked experimentation, cleaned up

@tinwelint
Copy link
Member

@MishaDemianenko looks like it needs rebase

@tinwelint
Copy link
Member

In general I think this looks OK

@MishaDemianenko
Copy link
Contributor Author

@tinwelint cleaned up and rebased

Copy link
Contributor

@burqen burqen left a comment

Choose a reason for hiding this comment

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

Small comments on test coverage. Looks good otherwise.

getValidator().validate( RandomStringUtils.randomAlphabetic( 5 ) );
getValidator().validate( RandomStringUtils.randomAlphabetic( 10 ) );
getValidator().validate( RandomStringUtils.randomAlphabetic( 250 ) );
getValidator().validate( RandomStringUtils.randomAlphabetic( 450 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice with a test for exactly MAX_TERM_LENGTH as well.

INSTANCE.validate( RandomUtils.nextBytes( 30 ) );
INSTANCE.validate( RandomUtils.nextBytes( 300 ) );
INSTANCE.validate( RandomUtils.nextBytes( 4303 ) );
INSTANCE.validate( RandomUtils.nextBytes( 13234 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Test array of MAX_TERM_LENGTH here as well.

getValidator().validate( RandomUtils.nextBytes( 3 ) );
getValidator().validate( RandomUtils.nextBytes( 30 ) );
getValidator().validate( RandomUtils.nextBytes( 450 ) );
getValidator().validate( RandomUtils.nextBytes( 4556 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, MAX_TERM_LENGTH

@burqen
Copy link
Contributor

burqen commented Nov 22, 2016

@MishaDemianenko This would be a candidate for changelog 👍

@MishaDemianenko
Copy link
Contributor Author

@burqen additional tests added for all things except IndexValueValidatorTest since you can directly ask for those number of bytes for array since those will be encoded by array encoder. We can pretend and guess border line but i do not think we need to do that.
And change log label added and message provided

@burqen
Copy link
Contributor

burqen commented Nov 22, 2016

@MishaDemianenko Looks good! Approved by me once green.

@burqen
Copy link
Contributor

burqen commented Nov 23, 2016

@MishaDemianenko triggered another run for Linux build.
The muted test that failed, is that not related?

Introduce validation of property values for legacy and schema indexes.
Create validators for empty/null/allowable cases. Perform validation during property updated and index population.
@MishaDemianenko
Copy link
Contributor Author

@burqen ok, rebased and old failure gone now it's failing with new 3.2 non related failures

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

Successfully merging this pull request may close these issues.

4 participants