-
-
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
Index is never set for Collection and Array in InvalidFormatException.Reference #506
Comments
Thank you for reporting this. Intent is indeed to report correct index... |
Forgot one thing: this has only been supported on serialization side, since that is where it is more obviously needed. But it would be nice on deserialization too, given that generally collection entry counts and JSON index (which would be available via |
Fixed for 4 relevant deserializers; please let me know if I missed something. Also added basic unit tests. |
I've just tested this change and this is perfect. You have added the missing reference of collection/array and attached the index to it. Thanks. |
Just on thing, the index is well set, but the "InvalidFormatException.Reference#_from" is a Class instead of the true Collection/Array reference. |
@fabdouglas Right, the problem with array is that one is only instantiated after collecting all entries (since arrays are not resizable). With collections this may not be the case, so I should go back and add a reference if possible. I realize that non-type-safety between |
One possible thing to do would be to create incomplete arrays, although this would only be for purposes of error reporting. But I am wondering if this might not actually be a good thing: it'd be possible to indicate (for example) what was the preceding non-erroneous element. |
Indeed, the array copy may cause serious performance issues for large objects. |
BTW, the target Milestone is currently 1.9.13 instead of 2.4.2 |
@fabdouglas Thanks, fixed milestone. And yes, perhaps consider further improvements later on; while constructing array can be useful, it could also be problematic, so might want to use heuristics to determine that... i.e. needs more thinking. |
There are a couple places you use |
Sounds plausible. Can you point me to those so I can fix them? |
Probably all ones using ix. It gets periodically reset as it is just the index into a temporary buffer. So index 13 might get misreported as index 0. Unless I am misreading it badly... See here for example: I can pull together the full list and try to reproduce in a test case if this doesn't look convincing to you. |
Yes I see, you are absolutely right. Thanks! |
Is there a chance to attach this issue to the next milstone? |
It'll go in 2.5, but if someone wants to do a PR for 2.4 branch I can merge. |
When a InvalidFormatException is created, index values is always '-1'.
Indeed, in StringCollectionDeserializer, and CollectionDeserializer the exception is not caught.
The JsonMappingException shoud be caught and the index should be added and based on the "result" size.
Without this information, there is no way to get the index of the item involved in the mapping error.
The text was updated successfully, but these errors were encountered: