I think we can use the native method trim() of String instead of iterating through String in trimWhitespace of StringUtils. This is simpler and secondarily more efficient.

Comment From: snicoll

Thanks for the PR but this was already done as part of #27769. Not that the replacement is strip(), not trim().