/hg/release/icedtea7-forest-2.4/jaxws: 5 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Tue Apr 15 20:50:22 UTC 2014


changeset 45a5daf8e5f5 in /hg/release/icedtea7-forest-2.4/jaxws
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.4/jaxws?cmd=changeset;node=45a5daf8e5f5
author: mkos
date: Thu Feb 13 18:20:10 2014 +0100

	8025030: Enhance stream handling
	Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Iaroslav Savytskyi, Alexander Fomin
	Reviewed-by: ahgross, mgrebac, skoivu


changeset 8cc8b2723913 in /hg/release/icedtea7-forest-2.4/jaxws
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.4/jaxws?cmd=changeset;node=8cc8b2723913
author: mkos
date: Tue Nov 12 11:22:53 2013 +0100

	8025152: Enhance activation set up
	Summary: fix also reviewed by Alexander Fomin
	Reviewed-by: dfuchs, hawtin
	Contributed-by: bill.shannon at oracle.com


changeset e48f6c97d9e0 in /hg/release/icedtea7-forest-2.4/jaxws
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.4/jaxws?cmd=changeset;node=e48f6c97d9e0
author: mkos
date: Mon Feb 17 13:32:02 2014 -0800

	8026188: Enhance envelope factory
	Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
	Reviewed-by: ahgross, mgrebac, skoivu


changeset f63e9e536eb7 in /hg/release/icedtea7-forest-2.4/jaxws
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.4/jaxws?cmd=changeset;node=f63e9e536eb7
author: mkos
date: Thu Feb 06 11:06:01 2014 +0100

	8026801: Enhance endpoint addressing
	Summary: Caching data initialized via TCCL in static context; fix also reviewed by Iaroslav Savytskyi, Alexander Fomin
	Reviewed-by: ahgross, mgrebac, skoivu


changeset bd9a50a78d04 in /hg/release/icedtea7-forest-2.4/jaxws
details: http://icedtea.classpath.org/hg/release/icedtea7-forest-2.4/jaxws?cmd=changeset;node=bd9a50a78d04
author: mkos
date: Fri Dec 13 16:37:37 2013 +0100

	8028388: 9 jaxws tests failed in nightly build with java.lang.ClassCastException
	Summary: test regression; fix also reviewed by Bill Shannon, Alexander Fomin
	Reviewed-by: mgrebac


diffstat:

 src/share/jaf_classes/javax/activation/CommandMap.java                                                         |   31 ++-
 src/share/jaf_classes/javax/activation/DataHandler.java                                                        |    9 +-
 src/share/jaf_classes/javax/activation/FileTypeMap.java                                                        |   38 ++-
 src/share/jaf_classes/javax/activation/MailcapCommandMap.java                                                  |   16 +-
 src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java                                               |   16 +-
 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java                     |   86 +++++++
 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties               |   27 ++
 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java                                |   13 +-
 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java                |   12 +-
 src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java            |   86 +++++++
 src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.properties      |   27 ++
 src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java                       |   11 +-
 src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java                                   |   37 ++-
 src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.java                                                |   48 ++++
 src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.properties                                          |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java                                  |    3 +-
 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.properties                            |    5 +-
 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java                |   24 +-
 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java                 |   18 +-
 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java             |   19 +-
 src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java                       |  108 ++++-----
 src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java                  |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties            |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java                          |   55 ++--
 src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java                        |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties                  |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java                                |   11 +-
 src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java                     |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties               |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java                      |   47 ++--
 src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java                      |   66 +++--
 src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java                                       |   59 +++++-
 src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java                         |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.properties                   |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java               |   13 +-
 src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java                                        |   32 +--
 src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java         |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties   |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java |   12 +-
 src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java                               |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties                         |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java                                          |   11 +-
 src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java                          |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties                    |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java                                          |   28 +-
 src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java                            |   86 +++++++
 src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties                      |   27 ++
 src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java                         |   11 +-
 src/share/jaxws_classes/javax/xml/bind/DatatypeConverterImpl.java                                              |   41 ++-
 src/share/jaxws_classes/javax/xml/bind/Messages.java                                                           |    4 +-
 src/share/jaxws_classes/javax/xml/bind/Messages.properties                                                     |    5 +-
 src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java                                    |    4 +-
 52 files changed, 1638 insertions(+), 326 deletions(-)

diffs (truncated from 2910 to 500 lines):

diff -r 622332638ead -r bd9a50a78d04 src/share/jaf_classes/javax/activation/CommandMap.java
--- a/src/share/jaf_classes/javax/activation/CommandMap.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaf_classes/javax/activation/CommandMap.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
 
 package javax.activation;
 
+import java.util.Map;
+import java.util.WeakHashMap;
+
 
 /**
  * The CommandMap class provides an interface to a registry of
@@ -38,6 +41,8 @@
  */
 public abstract class CommandMap {
     private static CommandMap defaultCommandMap = null;
+    private static Map<ClassLoader,CommandMap> map =
+                                new WeakHashMap<ClassLoader,CommandMap>();
 
     /**
      * Get the default CommandMap.
@@ -56,11 +61,18 @@
      *
      * @return the CommandMap
      */
-    public static CommandMap getDefaultCommandMap() {
-        if (defaultCommandMap == null)
-            defaultCommandMap = new MailcapCommandMap();
+    public static synchronized CommandMap getDefaultCommandMap() {
+        if (defaultCommandMap != null)
+            return defaultCommandMap;
 
-        return defaultCommandMap;
+        // fetch per-thread-context-class-loader default
+        ClassLoader tccl = SecuritySupport.getContextClassLoader();
+        CommandMap def = map.get(tccl);
+        if (def == null) {
+            def = new MailcapCommandMap();
+            map.put(tccl, def);
+        }
+        return def;
     }
 
     /**
@@ -71,7 +83,7 @@
      * @exception SecurityException if the caller doesn't have permission
      *                                  to change the default
      */
-    public static void setDefaultCommandMap(CommandMap commandMap) {
+    public static synchronized void setDefaultCommandMap(CommandMap commandMap) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             try {
@@ -79,13 +91,16 @@
                 security.checkSetFactory();
             } catch (SecurityException ex) {
                 // otherwise, we also allow it if this code and the
-                // factory come from the same class loader (e.g.,
+                // factory come from the same (non-system) class loader (e.g.,
                 // the JAF classes were loaded with the applet classes).
-                if (CommandMap.class.getClassLoader() !=
+                if (CommandMap.class.getClassLoader() == null ||
+                    CommandMap.class.getClassLoader() !=
                             commandMap.getClass().getClassLoader())
                     throw ex;
             }
         }
+        // remove any per-thread-context-class-loader CommandMap
+        map.remove(SecuritySupport.getContextClassLoader());
         defaultCommandMap = commandMap;
     }
 
diff -r 622332638ead -r bd9a50a78d04 src/share/jaf_classes/javax/activation/DataHandler.java
--- a/src/share/jaf_classes/javax/activation/DataHandler.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaf_classes/javax/activation/DataHandler.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -368,7 +368,12 @@
         // if it's not set, set it...
         if (transferFlavors == emptyFlavors)
             transferFlavors = getDataContentHandler().getTransferDataFlavors();
-        return transferFlavors;
+
+        if (transferFlavors == emptyFlavors)
+            return transferFlavors;
+        else
+            return transferFlavors.clone();
+
     }
 
     /**
diff -r 622332638ead -r bd9a50a78d04 src/share/jaf_classes/javax/activation/FileTypeMap.java
--- a/src/share/jaf_classes/javax/activation/FileTypeMap.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaf_classes/javax/activation/FileTypeMap.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package javax.activation;
 
 import java.io.File;
+import java.util.Map;
+import java.util.WeakHashMap;
 
 /**
  * The FileTypeMap is an abstract class that provides a data typing
@@ -48,6 +50,8 @@
 public abstract class FileTypeMap {
 
     private static FileTypeMap defaultMap = null;
+    private static Map<ClassLoader,FileTypeMap> map =
+                                new WeakHashMap<ClassLoader,FileTypeMap>();
 
     /**
      * The default constructor.
@@ -78,11 +82,11 @@
      * Sets the default FileTypeMap for the system. This instance
      * will be returned to callers of getDefaultFileTypeMap.
      *
-     * @param map The FileTypeMap.
+     * @param fileTypeMap The FileTypeMap.
      * @exception SecurityException if the caller doesn't have permission
      *                                  to change the default
      */
-    public static void setDefaultFileTypeMap(FileTypeMap map) {
+    public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             try {
@@ -90,14 +94,17 @@
                 security.checkSetFactory();
             } catch (SecurityException ex) {
                 // otherwise, we also allow it if this code and the
-                // factory come from the same class loader (e.g.,
+                // factory come from the same (non-system) class loader (e.g.,
                 // the JAF classes were loaded with the applet classes).
-                if (FileTypeMap.class.getClassLoader() !=
-                        map.getClass().getClassLoader())
+                if (FileTypeMap.class.getClassLoader() == null ||
+                    FileTypeMap.class.getClassLoader() !=
+                        fileTypeMap.getClass().getClassLoader())
                     throw ex;
             }
         }
-        defaultMap = map;
+        // remove any per-thread-context-class-loader FileTypeMap
+        map.remove(SecuritySupport.getContextClassLoader());
+        defaultMap = fileTypeMap;
     }
 
     /**
@@ -109,10 +116,17 @@
      * @return The default FileTypeMap
      * @see javax.activation.FileTypeMap#setDefaultFileTypeMap
      */
-    public static FileTypeMap getDefaultFileTypeMap() {
-        // XXX - probably should be synchronized
-        if (defaultMap == null)
-            defaultMap = new MimetypesFileTypeMap();
-        return defaultMap;
+    public static synchronized FileTypeMap getDefaultFileTypeMap() {
+        if (defaultMap != null)
+            return defaultMap;
+
+        // fetch per-thread-context-class-loader default
+        ClassLoader tccl = SecuritySupport.getContextClassLoader();
+        FileTypeMap def = map.get(tccl);
+        if (def == null) {
+            def = new MimetypesFileTypeMap();
+            map.put(tccl, def);
+        }
+        return def;
     }
 }
diff -r 622332638ead -r bd9a50a78d04 src/share/jaf_classes/javax/activation/MailcapCommandMap.java
--- a/src/share/jaf_classes/javax/activation/MailcapCommandMap.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaf_classes/javax/activation/MailcapCommandMap.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -120,11 +120,7 @@
 public class MailcapCommandMap extends CommandMap {
     /*
      * We manage a collection of databases, searched in order.
-     * The default database is shared between all instances
-     * of this class.
-     * XXX - Can we safely share more databases between instances?
      */
-    private static MailcapFile defDB = null;
     private MailcapFile[] DB;
     private static final int PROG = 0;  // programmatically added entries
 
@@ -164,14 +160,10 @@
         loadAllResources(dbv, "META-INF/mailcap");
 
         LogSupport.log("MailcapCommandMap: load DEF");
-        synchronized (MailcapCommandMap.class) {
-            // see if another instance has created this yet.
-            if (defDB == null)
-                defDB = loadResource("/META-INF/mailcap.default");
-        }
+        mf = loadResource("/META-INF/mailcap.default");
 
-        if (defDB != null)
-            dbv.add(defDB);
+        if (mf != null)
+            dbv.add(mf);
 
         DB = new MailcapFile[dbv.size()];
         DB = (MailcapFile[])dbv.toArray(DB);
diff -r 622332638ead -r bd9a50a78d04 src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java
--- a/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,11 +69,7 @@
 public class MimetypesFileTypeMap extends FileTypeMap {
     /*
      * We manage a collection of databases, searched in order.
-     * The default database is shared between all instances
-     * of this class.
-     * XXX - Can we safely share more databases between instances?
      */
-    private static MimeTypeFile defDB = null;
     private MimeTypeFile[] DB;
     private static final int PROG = 0;  // programmatically added entries
 
@@ -114,14 +110,10 @@
         loadAllResources(dbv, "META-INF/mime.types");
 
         LogSupport.log("MimetypesFileTypeMap: load DEF");
-        synchronized (MimetypesFileTypeMap.class) {
-            // see if another instance has created this yet.
-            if (defDB == null)
-                defDB = loadResource("/META-INF/mimetypes.default");
-        }
+        mf = loadResource("/META-INF/mimetypes.default");
 
-        if (defDB != null)
-            dbv.addElement(defDB);
+        if (mf != null)
+            dbv.addElement(mf);
 
         DB = new MimeTypeFile[dbv.size()];
         dbv.copyInto(DB);
diff -r 622332638ead -r bd9a50a78d04 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java	Fri Dec 13 16:37:37 2013 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.ws.wsdl.parser;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+    private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+    private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+    public V get() throws Error {
+        ClassLoader tccl = getContextClassLoader();
+        V instance = CACHE.get(tccl);
+        if (instance == null) {
+            instance = createNewInstance();
+            CACHE.put(tccl, instance);
+        }
+        return instance;
+    }
+
+    public void set(V instance) {
+        CACHE.put(getContextClassLoader(), instance);
+    }
+
+    protected abstract V initialValue() throws Exception;
+
+    private V createNewInstance() {
+        try {
+            return initialValue();
+        } catch (Exception e) {
+            throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+        }
+    }
+
+    private static String format(String property, Object... args) {
+        String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+        return MessageFormat.format(text, args);
+    }
+
+    private static ClassLoader getContextClassLoader() {
+        return (ClassLoader)
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        ClassLoader cl = null;
+                        try {
+                            cl = Thread.currentThread().getContextClassLoader();
+                        } catch (SecurityException ex) {
+                        }
+                        return cl;
+                    }
+                });
+    }
+}
+
diff -r 622332638ead -r bd9a50a78d04 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties	Fri Dec 13 16:37:37 2013 +0100
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
+
diff -r 622332638ead -r bd9a50a78d04 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,8 +65,15 @@
  * @author Vivek Pandey
  */
 public class Internalizer {
-    private static final XPathFactory xpf = XPathFactory.newInstance();
-    private final XPath xpath = xpf.newXPath();
+
+    private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
+        @Override
+        protected XPathFactory initialValue() throws Exception {
+            return XPathFactory.newInstance();
+        }
+    };
+
+    private final XPath xpath = xpf.get().newXPath();
     private final WsimportOptions options;
     private final DOMForest forest;
     private final ErrorReceiver errorReceiver;
diff -r 622332638ead -r bd9a50a78d04 src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java
--- a/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java	Wed Mar 26 16:03:43 2014 +0000
+++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java	Fri Dec 13 16:37:37 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,8 +56,14 @@
  */
 public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler {
 
-    private static final XPathFactory xpf = XPathFactory.newInstance();
-    private final XPath xpath = xpf.newXPath();
+    private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
+        @Override
+        protected XPathFactory initialValue() throws Exception {
+            return XPathFactory.newInstance();
+        }
+    };
+
+    private final XPath xpath = xpf.get().newXPath();
 
     public JAXWSBindingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap) {
         super(extensionHandlerMap);
diff -r 622332638ead -r bd9a50a78d04 src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/ContextClassloaderLocal.java	Fri Dec 13 16:37:37 2013 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.xjc.reader.internalizer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal<V> {
+
+    private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+    private WeakHashMap<ClassLoader, V> CACHE = new WeakHashMap<ClassLoader, V>();
+
+    public V get() throws Error {
+        ClassLoader tccl = getContextClassLoader();
+        V instance = CACHE.get(tccl);
+        if (instance == null) {
+            instance = createNewInstance();
+            CACHE.put(tccl, instance);
+        }


More information about the distro-pkg-dev mailing list