Skip to content

Commit

Permalink
Remove xstream noise
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Coles authored and hcoles committed Dec 31, 2020
1 parent baa0ba9 commit 239b19b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 3 additions & 6 deletions pitest/src/test/java/org/pitest/util/PitXmlDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
*/
package org.pitest.util;

import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import com.thoughtworks.xstream.io.xml.AbstractXppDriver;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;

/**
* Pull parser driver that creates hard coded parser type to avoid clashes with
Expand All @@ -32,8 +30,7 @@ public PitXmlDriver() {
}

@Override
protected synchronized XmlPullParser createParser()
throws XmlPullParserException {
protected synchronized XmlPullParser createParser() {
return new MXParser();
}
}
10 changes: 6 additions & 4 deletions pitest/src/test/java/org/pitest/util/XStreamCloning.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.pitest.util;

import static org.pitest.util.Unchecked.translateCheckedException;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.CompactWriter;

import java.io.StringWriter;
import java.io.Writer;
import java.util.WeakHashMap;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.CompactWriter;
import static org.pitest.util.Unchecked.translateCheckedException;

public class XStreamCloning {

private static final XStream XSTREAM_INSTANCE = new XStream(
new PitXmlDriver()).set
new PitXmlDriver());
private static final WeakHashMap<ClassLoader, XStream> CACHE = new WeakHashMap<>();


Expand All @@ -32,6 +32,8 @@ private static XStream getXStreamForLoader(final ClassLoader loader) {
if (foreginXstream == null) {
foreginXstream = new XStream(new PitXmlDriver());
foreginXstream.setClassLoader(loader);
XStream.setupDefaultSecurity(foreginXstream);
foreginXstream.allowTypesByWildcard(new String[] {"**"});
// possible that more than one instance will be created
// per loader, but probably better than synchronizing the whole method
synchronized (CACHE) {
Expand Down

0 comments on commit 239b19b

Please sign in to comment.