1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Fri Feb 14 10:53:55 2014 +0100 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Fri Feb 14 11:13:45 2014 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -63,39 +63,43 @@ 1.11 1.12 private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName()); 1.13 1.14 + private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; 1.15 + 1.16 /** 1.17 * Singleton instance. 1.18 */ 1.19 - private static volatile @NotNull XMLStreamReaderFactory theInstance; 1.20 + private static volatile ContextClassloaderLocal<XMLStreamReaderFactory> streamReader = 1.21 + new ContextClassloaderLocal<XMLStreamReaderFactory>() { 1.22 1.23 - private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory"; 1.24 + @Override 1.25 + protected XMLStreamReaderFactory initialValue() { 1.26 1.27 - static { 1.28 - XMLInputFactory xif = getXMLInputFactory(); 1.29 - XMLStreamReaderFactory f=null; 1.30 + XMLInputFactory xif = getXMLInputFactory(); 1.31 + XMLStreamReaderFactory f=null; 1.32 1.33 - // this system property can be used to disable the pooling altogether, 1.34 - // in case someone hits an issue with pooling in the production system. 1.35 - if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { 1.36 - f = Zephyr.newInstance(xif); 1.37 - } 1.38 + // this system property can be used to disable the pooling altogether, 1.39 + // in case someone hits an issue with pooling in the production system. 1.40 + if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) { 1.41 + f = Zephyr.newInstance(xif); 1.42 + } 1.43 1.44 - if(f==null) { 1.45 - // is this Woodstox? 1.46 - if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { 1.47 - f = new Woodstox(xif); 1.48 - } 1.49 - } 1.50 + if(f==null) { 1.51 + // is this Woodstox? 1.52 + if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) { 1.53 + f = new Woodstox(xif); 1.54 + } 1.55 + } 1.56 1.57 - if (f==null) { 1.58 - f = new Default(); 1.59 - } 1.60 + if (f==null) { 1.61 + f = new Default(); 1.62 + } 1.63 1.64 - theInstance = f; 1.65 - if (LOGGER.isLoggable(Level.FINE)) { 1.66 - LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance); 1.67 - } 1.68 - } 1.69 + if (LOGGER.isLoggable(Level.FINE)) { 1.70 + LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f); 1.71 + } 1.72 + return f; 1.73 + } 1.74 + }; 1.75 1.76 private static XMLInputFactory getXMLInputFactory() { 1.77 XMLInputFactory xif = null; 1.78 @@ -126,11 +130,11 @@ 1.79 if(f==null) { 1.80 throw new IllegalArgumentException(); 1.81 } 1.82 - theInstance = f; 1.83 + streamReader.set(f); 1.84 } 1.85 1.86 public static XMLStreamReaderFactory get() { 1.87 - return theInstance; 1.88 + return streamReader.get(); 1.89 } 1.90 1.91 public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {