-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
} | ||
if ( value instanceof String ) | ||
{ | ||
IndexValueLengthValidator.INSTANCE.validate( ((String) value).getBytes() ); |
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.
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?
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.
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...
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.
So schema indexes already did this, right? Then it's "OK" to add this slight extra garbage to legacy indexes as well imho
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.
Never mind me. This validation has already been present for schema indexes just deeper in the call stack.
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.
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 ) |
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.
Looks like this methods isn't actually needed anymore, or it could at least still remain private static, couldn't it?
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.
yeah that was sneaked experimentation, cleaned up
@MishaDemianenko looks like it needs rebase |
In general I think this looks OK |
c13cc21
to
3aabfc7
Compare
@tinwelint cleaned up and rebased |
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.
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 ) ); |
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.
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 ) ); |
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.
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 ) ); |
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.
Again, MAX_TERM_LENGTH
@MishaDemianenko This would be a candidate for changelog 👍 |
3aabfc7
to
5a341c1
Compare
@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. |
@MishaDemianenko Looks good! Approved by me once green. |
@MishaDemianenko triggered another run for Linux build. |
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.
5a341c1
to
ec654a5
Compare
@burqen ok, rebased and old failure gone now it's failing with new 3.2 non related failures |
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.