Repository navigation
WW-3666 Trim surrounding whitespace before converting to non-String types - #2039
Merged
Merged
Conversation
…non-String types
Padded request values such as " 42 " or " ACTIVE " were rejected by the
locale-aware number, enum and java.time paths, while primitive int/long
already trimmed. Boolean and Character silently misread them (" true " was
false, " x" was ' ').
XWorkBasicConverter now trims String and String[] values for scalar targets.
String/Object targets and converters registered for a type still receive the
raw value; arrays and collections trim per element. Whitespace-only input
follows the existing "" path, so boxed Boolean blank becomes null and a
whitespace-only Character keeps its first character.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 17, 2026 08:22
lukaszlenart
commented
Oct 17, 2026
| return value; | ||
| } | ||
|
|
||
| value = trimSurroundingWhitespace(value, toType); |
Member
Author
There was a problem hiding this comment.
Reassigning to method parameter is a bad idea
…reassigning the parameter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes WW-3666
Summary
Request values with surrounding whitespace (
" 42 "," ACTIVE ","\t2001-01-10\n") were rejected by most built-in converters. Only primitiveint/longalready trimmed, solongandLongdisagreed on the same input.BooleanandCharactersilently misread padded input, with no conversion error.XWorkBasicConverter.convertValuenow trimsStringandString[]values before converting to a non-String scalar target:double/float,BigInteger,BigDecimal), enums, booleans,Date/java.time,ClassconvertValueand are trimmed per elementString/Objecttargets keep the value untouched (they return before the trim), and so doList<String>elementsCharacter/char:" x"→'x'; whitespace-only input keeps its first character (" "→' '), preserving the existingtestConvertCharbehaviourWhitespace-only input now follows the existing
""path.Point 3 of the ticket ("errors should bubble up") is already covered: conversion failures are recorded and
ConversionErrorInterceptorturns them into field errors.Behaviour changes worth a migration note (7.5.0)
" true "Boolean/booleanfalsetrue" x"Character/char' ''x'""or" "Booleanfalsenull" "java.timenull(arequiredvalidator now reports it instead)" 42 "etc.java.time, arraysUnchanged:
" "intoint/longis still a conversion error." "intodouble/floatgivesnull, which is what""already gives there (a pre-existing quirk inNumberConverter.convertToDouble/convertToFloat, left alone).Test plan
XWorkConverterTestcases for numbers, enums, booleans, characters,java.time,String[]→Long[], whitespace-only boxed →null, integral primitives → conversion error — the behaviour cases watched failing before the changeString/Object/String[]targets untouched, custom converter receives the raw value) checked by mutation: trimming before the early return, or inXWorkConverterbefore the lookup, fails them (and the existingtestConvertChar)./mvnw test -DskipAssembly -pl core— 3520 tests, 0 failures./mvnw test -DskipAssembly -DskipITs(full reactor) — 4860 tests, 0 failures🤖 Generated with Claude Code