Details
Description
When something goes wrong in serialization, I'd like the ability to choose how the error is processed.
Rather than throwing an exception, I'd like a callback (ErrorHandler) to occur so I can choose to barf, ignore, recover, log, etc.
Issue Links
Activity
Joe Walnes
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Affects Version/s | 0.7 [ 10492 ] | |
| Affects Version/s | 0.5 [ 10490 ] |
Joe Walnes
made changes -
| Fix Version/s | 0.7 [ 10492 ] |
Joe Walnes
made changes -
| Fix Version/s | 1.1 [ 10710 ] | |
| Fix Version/s | 0.7 [ 10492 ] |
Joe Walnes
made changes -
| Fix Version/s | 1.1.2 [ 11464 ] | |
| Fix Version/s | 1.1 [ 10710 ] |
Joe Walnes
made changes -
| Fix Version/s | 1.1.2 [ 11464 ] | |
| Fix Version/s | 1.1.1 [ 11463 ] |
Joe Walnes
made changes -
| Fix Version/s | 1.1.2 [ 11464 ] | |
| Fix Version/s | 1.1.1 [ 11463 ] |
Joe Walnes
made changes -
| Fix Version/s | Upcoming [ 11541 ] | |
| Fix Version/s | 1.2 [ 10743 ] |
Mauro Talevi
made changes -
| Affects Version/s | 1.2 [ 10743 ] | |
| Fix Version/s | Upcoming [ 11541 ] | |
| Affects Version/s | 0.1 [ 10305 ] | |
| Fix Version/s | 1.2 [ 10743 ] |
Jörg Schaible
made changes -
Jörg Schaible
made changes -
This would provide a solution to the following issue posed to user@xstream.codehause.org
–
Hello all.
Is anyone aware of a way to have XStream ignore elements that don't map? I don't mean the "ommitField" method. What I need is a global setting that instructs XStream to ignore exceptions caused by an element found in the xml being parsed but which has no corresponding property on the java side. We are using XStream to process an XML file that is not only used by us. As a result, the xml file may be modified to included additional fields which are needed by other projects. It would be nice if we didn't have to keep updating our Java objects to include these extra fields. The xml is handled this way because it is third-party generated and not all consumers are java clients.
Example XML:
<someObject>
<field1>test</field1>
<field2>foo</field2>
<field3>bar</field3>
</someObject>
Example POJO:
public class SomeObject{
String field1;
String field2;
//No property for "field3" ... causes error
//Setters/Getters
}
Would be nice to have XStream.ignoreUnmappedElements() which would ignore the error generated above. Perhaps with overloaded versions that took a specific class or type to ignore elements that don't map that the specific class or type. Maybe even an overloaded version that takes a regular expression.
Any thoughts?