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
[JBPM-9558] KIE using XStream does not complain on unknown fields #2369
Conversation
e968f70
to
a9c33a1
Compare
c3761e5
to
ddd70b3
Compare
...t/kie-server-api/src/main/java/org/kie/server/api/marshalling/xstream/XStreamMarshaller.java
Outdated
Show resolved
Hide resolved
...t/kie-server-api/src/main/java/org/kie/server/api/marshalling/xstream/XStreamMarshaller.java
Outdated
Show resolved
Hide resolved
marshaller is created upon deployment and cached so there is not need for multithread. You can add user space objects during creation to the marshaller and ignore them as upon deployment you will have access to any java class in the kjar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs another approach
Changed to use Custom mapper and thread local |
d51c0c5
to
4171af3
Compare
@elguardian Ready to re-review |
...t/kie-server-api/src/main/java/org/kie/server/api/marshalling/xstream/XStreamMarshaller.java
Outdated
Show resolved
Hide resolved
...t/kie-server-api/src/main/java/org/kie/server/api/marshalling/xstream/XStreamMarshaller.java
Outdated
Show resolved
Hide resolved
...t/kie-server-api/src/main/java/org/kie/server/api/marshalling/xstream/XStreamMarshaller.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor clean up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment, others are just cosmetic changes here.
kie-server-parent/kie-server-api/src/main/java/org/kie/server/api/marshalling/Marshaller.java
Outdated
Show resolved
Hide resolved
...-server-api/src/test/java/org/kie/server/api/marshalling/CustomXstreamMarshallerBuilder.java
Outdated
Show resolved
Hide resolved
...arent/kie-server-api/src/test/java/org/kie/server/api/marshalling/XStreamMarshallerTest.java
Outdated
Show resolved
Hide resolved
@@ -35,7 +35,8 @@ public Marshaller build(Set<Class<?>> classes, MarshallingFormat format, ClassLo | |||
return new XStreamMarshaller(classes, classLoader) { | |||
@Override | |||
protected void buildMarshaller(Set<Class<?>> classes, ClassLoader classLoader) { | |||
xstream = XStreamUtils.createNonTrustingXStream(new PureJavaReflectionProvider(), new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_"))); | |||
xstream = XStreamUtils.createNonTrustingXStream(new PureJavaReflectionProvider(), new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")) | |||
, next -> new CustomElementIgnore(next)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only way to get a buildMarshaller with this ignoreUnknownFields
feature is by using and passing this new CustomElementIgnore
- so I'm just thinking whether it would be worth to make it public
instead of protected
- otherwise we are forcing customer to create a package with the same structure - or am I wrong? wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is intended to be used only in inherited classes, so protected is right
Adding ElementIgnoringMapper custom implementation.
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @fjtirado!
@elguardian I think we are ready to go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a comment in the test for adding false flag
In order to "relax" deserialization requirements, user can specifiy as parameter of contentype, ignoreUnknown=true, which will ignore unknown fields durign xstream deserialization.
JIRA:
link
Depends on
kiegroup/kie-soup#173