From a856b014f85fe6adc778de80d94d4410b7e78fd2 Mon Sep 17 00:00:00 2001 From: Josh Friedman <jofriedm@microsoft.com> Date: Mon, 22 Aug 2016 16:44:48 -0700 Subject: [PATCH] [Java] Support Custom ClassLoader --- .../src/com/microsoft/azure/storage/core/Utility.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java b/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java index 919c04bd869f2..dc3c3998382ff 100644 --- a/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java +++ b/microsoft-azure-storage/src/com/microsoft/azure/storage/core/Utility.java @@ -120,7 +120,11 @@ public final class Utility { /** * A factory to create SAXParser instances. */ - private static final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + private static final ThreadLocal<SAXParserFactory> saxParserFactory = new ThreadLocal<SAXParserFactory>() { + @Override public SAXParserFactory initialValue() { + return SAXParserFactory.newInstance(); + } + }; /** * A factory to create XMLStreamWriter instances. @@ -664,8 +668,8 @@ public static JsonParser getJsonParser(final InputStream inStream) throws JsonPa * @throws SAXException */ public static SAXParser getSAXParser() throws ParserConfigurationException, SAXException { - saxParserFactory.setNamespaceAware(true); - return saxParserFactory.newSAXParser(); + saxParserFactory.get().setNamespaceAware(true); + return saxParserFactory.get().newSAXParser(); } /**