-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
(2.8) Add new method(s) in DeserializationProblemHandler
to allow handling of format mismatch problems
#1207
Comments
…ontext` and `DeserializationProblemHandler`
Note: new methods added in
and in both cases handler may choose to try to fix the issue, or to throw custom exception. In former case it would be possible to also collect failure notification. |
More handlers added:
along with tests. No automatic wiring/chaining of exceptions, but handlers can stash problem information as contextual Attributes or such. Handlers still to add/convert:
|
…issingInstantiator()` (and supporting functionality), to replace `instantiationException(Class, String)`
…()` (and handler method in `DeserializationProblemHandler`), for the common failure mode of getting JSON token of unexpected type
Completed to the degree it will be done for 2.8 I think. |
(note: based on ideas from #1196)
Existing
DeserializationProblemHandler
only has one callback method, for handling common case of "unknown property" problem. But there are other types of failures that would probably be possible to route through such handler. One broad class of problems has to do with mismatching values, like getting a JSON String where number is expected, or getting a String with format that is not recognized as valid (such as can occur for Date/Time values).To allow dealing with such problems, it seems reasonable to add following handlers:
String
, but not limited)Note that there may be some corner cases here (f.ex., choice between (1) and (2) may not be clear for secondary/coerced values), but this should cover a few cases.
Compared to the earlier handler there are similarities and differences:
JsonParser
, and is responsible for using up or skipping any content for structured values (array, object)null
-- but since there is no way to indicate "not handled", callback MUST throw exception to halt processingOptional
...)To support proper handling, information to pass probably needs to include some of:
DeserializationContext
,JsonParser
,JsonDeserializer
in use; bean/class of bean for which value is to be usedBeanProperty
for which value is meant? (also gives logical name for error reporting)Exception
to throw?Anyway. Details method, arguments to pass etc get complicated and probably need to be refined as part of implementation.
The text was updated successfully, but these errors were encountered: