Serialize Character values in XContent maps - #22814
Conversation
ScriptProcessor can put Character values into the ingest document map. XContentBuilder rejected them because Character was missing from the WRITERS registry. Fixes opensearch-project#14382 Signed-off-by: Burak KALAYCI <kalayciburak1996@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
❌ Gradle check result for 5975d68: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Description
XContentBuilderrejectedCharactervalues withcannot write xcontent for unknown value of type class java.lang.Character. Ingest scripts such asctx.char = (char)'a'put aCharacterinto the document map, andIngestServicethen failed while serializing that map.Register
Characterin theWRITERStable and write it as a one-character string, matchingLocale/Class.Related Issues
Resolves #14382
Check List
Test plan
Executed as a non-root user on JDK 21:
:server:test --tests org.opensearch.common.xcontent.builder.XContentBuilderTests.testWriteMapWithCharacterValuefailed withIllegalArgumentException: cannot write xcontent for unknown value of type class java.lang.CharacterJsonXContentTests.testUnknownObject:server:test --tests org.opensearch.common.xcontent.builder.XContentBuilderTests --tests org.opensearch.common.xcontent.json.JsonXContentTests --tests org.opensearch.common.xcontent.smile.SmileXContentTests.testUnknownObject --tests org.opensearch.common.xcontent.cbor.CborXContentTests.testUnknownObject --tests org.opensearch.common.xcontent.yaml.YamlXContentTests.testUnknownObjectspotlessJavaCheckBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.