nick-boss-tech opened a new pull request, #5094:
URL: https://github.com/apache/solr/pull/5094

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-16673
   
   Title: The Parse{Int,Long,Float,Double}FieldUpdateProcessorFactory classes 
no longer fail with a NullPointerException on an empty string value
   
   ## What happens today
   
   **An empty string in a 
Parse{Int,Long,Float,Double}FieldUpdateProcessorFactory field throws a 
NullPointerException.**
   
   `NumberFormat.parse` returns null for an empty string. The bounds check 
still passes, because the parse position and the string length are both 0. The 
code then calls a method on the null result, for example `number.intValue()` in 
[ParseIntFieldUpdateProcessorFactory.java](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java#L101).
   
   ## What this change does
   
   **An empty string that does not parse is skipped, so the value stays as it 
was.**
   
   Each of the four factories treats a null parse result as unparseable. The 
check is now `number == null || pos.getIndex() != stringVal.length()` in 
[Int](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/update/processor/ParseIntFieldUpdateProcessorFactory.java#L93),
 
[Long](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/update/processor/ParseLongFieldUpdateProcessorFactory.java#L104),
 
[Float](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/update/processor/ParseFloatFieldUpdateProcessorFactory.java#L96),
 and 
[Double](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/update/processor/ParseDoubleFieldUpdateProcessorFactory.java#L107).
 The value is then kept.
   
   ## Proof
   
   **The gate at the parent head passed, and the new test fails without the 
fix.**
   
   - Gate at `d5c19e64ba1b`: the changelog parses. Tidy returns 0. The Error 
Prone compile returns 0. The fail-before check reports PASS, so the new test 
fails on the code without the fix. `ParsingFieldUpdateProcessorsTest` passes 43 
of 43. `:solr:core:check -x test` returns 0.
   - The head is now `d7170b12f312`. The only change since that gate is the 
changelog title line. No code or test changed.
   - The new test 
[testEmptyStringIsNotParsedAsNumber](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java#L499-L514)
 sends an empty string through the four chains. It checks that the value is 
kept.
   
   ## Limits
   
   **The Schema Designer path and the other errors in the ticket sample are not 
covered.**
   
   - The test calls the four processor chains. It does not run the Schema 
Designer path, where 
[DefaultSchemaSuggester.isIntOrLong](https://github.com/nick-boss-tech/solr/blob/d7170b12f312b364cb280b943a042707e553ea64/solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java#L338)
 feeds the Long parser. The ticket reports Schema Designer failures on empty 
values. The link between the two is not tested here.
   - The same ticket sample also hits a non-string unique key and 
child-document `_root_` type errors. This change does not touch them. A 
follow-up ticket and PR can cover them on request.
   
   Changelog: `changelog/unreleased/SOLR-16673.yml` (type: fixed).
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. Nick 
Shanin directed the work and takes responsibility for this contribution.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to