mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
fix bug in JAXBStore, see http://jaxb.java.net/guide/Performance_and_thread_safety.html
This commit is contained in:
@@ -39,13 +39,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.SCMContext;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@@ -53,7 +50,6 @@ import java.net.URLClassLoader;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
@@ -45,7 +45,6 @@ import java.io.File;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -72,11 +71,7 @@ public class JAXBStore<T> implements Store<T>
|
||||
{
|
||||
try
|
||||
{
|
||||
JAXBContext context = JAXBContext.newInstance(type);
|
||||
|
||||
marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
unmarshaller = context.createUnmarshaller();
|
||||
context = JAXBContext.newInstance(type);
|
||||
this.configFile = configFile;
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
@@ -102,7 +97,7 @@ public class JAXBStore<T> implements Store<T>
|
||||
{
|
||||
try
|
||||
{
|
||||
result = (T) unmarshaller.unmarshal(configFile);
|
||||
result = (T) context.createUnmarshaller().unmarshal(configFile);
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
@@ -132,6 +127,9 @@ public class JAXBStore<T> implements Store<T>
|
||||
|
||||
try
|
||||
{
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
marshaller.marshal(object, configFile);
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
@@ -146,8 +144,5 @@ public class JAXBStore<T> implements Store<T>
|
||||
private File configFile;
|
||||
|
||||
/** Field description */
|
||||
private Marshaller marshaller;
|
||||
|
||||
/** Field description */
|
||||
private Unmarshaller unmarshaller;
|
||||
private JAXBContext context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user