-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Introduce ObjectUtils.nullSafeConciseToString()
#30286
Comments
nullSafeSimpleToString(Object)
in ObjectUtils
nullSafeConciseToString(Object)
in ObjectUtils
StringUtils.truncate() serves as central, consistent way for truncating strings used in log messages and exception failure messages, for immediate use in LogFormatUtils and ObjectUtils. See spring-projectsgh-30286 Closes spring-projectsgh-30290
nullSafeConciseToString(Object)
in ObjectUtils
ObjectUtils.nullSafeConciseToString()
ObjectUtils.nullSafeToString(Object) exists for generating a string representation of various objects in a "null-safe" manner, including support for object graphs, collections, etc. However, there are times when we would like to generate a "concise", null-safe string representation that does not include an entire object graph (or potentially a collection of object graphs). This commit introduces ObjectUtils.nullSafeConciseToString(Object) to address this need and makes use of the new feature in FieldError and ConversionFailedException. Closes gh-30286
This change in the |
@bclozel Unfortunately only |
Can you create a new issue and provide a sample showing the issue? |
@gebhardt we're currently considering what to do about this for the upcoming releases in mid July. It would be great if you could create a separate issue for the Could you please clarify how you are consuming the |
We are using the We are using
Now I get exception messages like this, that do not contain the rejected value in a readable form anymore.
Another example is a configuration file where we have created an
If I try to initialize an ApplicationContext, I get the following Exception:
However, if we use the Spring Boot FailureAnalyzer I get a meaningful output:
|
UpdateChanges made to Improvements to |
Overview
org.springframework.util.ObjectUtils.nullSafeToString(Object)
exists for generating atoString()
representation of various objects in a "null-safe" manner, including support for object graphs, collections, etc.However, there are times when we would like to generate a more "concise" null-safe
toString()
representation that does not include an entire object graph (or potentially a collection of object graphs).org.springframework.beans.BeanUtils.isSimpleValueType(Class<?>)
already provides a check for an opinionated list of "simple types"; however, that resides inspring-beans
and therefore cannot be used inspring-core
.We should introduce
ObjectUtils.nullSafeConciseToString(Object)
that generates a concise, null-safe string representation of the supplied object relying on logic similar toBeanUtils.isSimpleValueType()
to decide when to use the standardtoString()
implementation for the supplied object and when to replace the standard implementation with a more concise format -- for example, something along the lines of whatObject#toString
generates instead of including thetoString()
representation of an entire object graph recursively.Deliverables
nullSafeConciseToString(Object)
inObjectUtils
The text was updated successfully, but these errors were encountered: