Skip to content
Browse files

Ignore non-existing fields

  • Loading branch information...
1 parent 924557f commit 148daa43b06485180f9bc0d266acc1a984c30709 @jdillon jdillon committed
View
17 ...lient-core/src/main/java/org/sonatype/nexus/client/internal/rest/NexusXStreamFactory.java
@@ -12,6 +12,7 @@
*/
package org.sonatype.nexus.client.internal.rest;
+import com.thoughtworks.xstream.mapper.MapperWrapper;
import org.sonatype.nexus.client.internal.msg.ErrorMessage;
import org.sonatype.nexus.client.internal.msg.ErrorResponse;
import org.sonatype.nexus.rest.model.XStreamConfiguratorLightweight;
@@ -33,7 +34,21 @@
*/
public XStream createForXml()
{
- final XStream xstream = new XStream( new LookAheadXppDriver() );
+ final XStream xstream = new XStream(new LookAheadXppDriver())
+ {
+ // Ignore fields which are present in the payload but not on target class
+ @Override
+ protected MapperWrapper wrapMapper(final MapperWrapper next) {
+ return new MapperWrapper(next)
+ {
+ @Override
+ public boolean shouldSerializeMember(final Class definedIn, final String fieldName) {
+ return definedIn != Object.class && super.shouldSerializeMember(definedIn, fieldName);
+ }
+ };
+ }
+ };
+
xstream.setMode( XStream.NO_REFERENCES );
xstream.autodetectAnnotations( false );
return xstream;

0 comments on commit 148daa4

Please sign in to comment.
Something went wrong with that request. Please try again.