aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/scheme
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme')
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/Marshaller.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Marshaller.java b/src/main/java/at/gv/egiz/moazs/scheme/Marshaller.java
index 1a86079..bf502c0 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/Marshaller.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/Marshaller.java
@@ -9,6 +9,8 @@ import java.io.InputStream;
import java.io.StringWriter;
import java.util.HashMap;
+import static at.gv.egiz.moazs.util.JAXBClassNotFoundFix.runInTheadWithClassClassLoader;
+
/**
* @author xerx593
* Source: https://stackoverflow.com/questions/44676532/how-to-use-spring-to-marshal-and-unmarshal-xml
@@ -32,17 +34,22 @@ public class Marshaller {
}
public <T> String marshallXml(final T obj) {
+
if (obj == null) {
return "null";
}
StringWriter sw = new StringWriter();
Result result = new StreamResult(sw);
- jaxbMarshaller.marshal(obj, result);
- return sw.toString();
+
+ return runInTheadWithClassClassLoader(() -> {
+ jaxbMarshaller.marshal(obj, result);
+ return sw.toString();
+ });
}
public <T> T unmarshallXml(final InputStream xml) {
- return (T) jaxbMarshaller.unmarshal(new StreamSource(xml));
+ return runInTheadWithClassClassLoader(
+ () -> (T) jaxbMarshaller.unmarshal(new StreamSource(xml)));
}
}