diff -r 7386eca865e1 -r 8f2986ff0235 src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Thu May 30 10:58:13 2013 -0700 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Wed Jun 12 14:47:09 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -42,6 +42,7 @@ import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -53,6 +54,7 @@ * * @author Kohsuke Kawaguchi */ +@SuppressWarnings("StaticNonFinalUsedInInitialization") public abstract class XMLStreamWriterFactory { private static final Logger LOGGER = Logger.getLogger(XMLStreamWriterFactory.class.getName()); @@ -80,8 +82,19 @@ // this system property can be used to disable the pooling altogether, // in case someone hits an issue with pooling in the production system. - if(!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) - f = Zephyr.newInstance(xof); + if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) { + try { + Class clazz = xof.createXMLStreamWriter(new StringWriter()).getClass(); + if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) { + f = new Zephyr(xof,clazz); + } + } catch (XMLStreamException ex) { + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); + } catch (NoSuchMethodException ex) { + Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex); + } + } + if(f==null) { // is this Woodstox? if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory")) @@ -91,7 +104,9 @@ f = new Default(xof); theInstance = f; - LOGGER.fine("XMLStreamWriterFactory instance is = "+theInstance); + if (LOGGER.isLoggable(Level.FINE)) { + LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f); + } } /** @@ -165,6 +180,7 @@ * @param f * must not be null. */ + @SuppressWarnings({"null", "ConstantConditions"}) public static void set(@NotNull XMLStreamWriterFactory f) { if(f==null) throw new IllegalArgumentException(); theInstance = f; @@ -220,10 +236,12 @@ this.xof = xof; } + @Override public XMLStreamWriter doCreate(OutputStream out) { return doCreate(out,"UTF-8"); } + @Override public synchronized XMLStreamWriter doCreate(OutputStream out, String encoding) { try { XMLStreamWriter writer = xof.createXMLStreamWriter(out,encoding); @@ -233,6 +251,7 @@ } } + @Override public void doRecycle(XMLStreamWriter r) { // no recycling } @@ -284,10 +303,12 @@ return sr; } + @Override public XMLStreamWriter doCreate(OutputStream out) { return doCreate(out,"UTF-8"); } + @Override public XMLStreamWriter doCreate(OutputStream out, String encoding) { XMLStreamWriter xsw = fetch(); if(xsw!=null) { @@ -311,6 +332,7 @@ return new HasEncodingWriter(xsw, encoding); } + @Override public void doRecycle(XMLStreamWriter r) { if (r instanceof HasEncodingWriter) { r = ((HasEncodingWriter)r).getWriter(); @@ -340,10 +362,12 @@ this.xof = xof; } + @Override public XMLStreamWriter doCreate(OutputStream out) { return doCreate(out, SOAPBindingCodec.UTF8_ENCODING); } + @Override public XMLStreamWriter doCreate(OutputStream out, String encoding) { try { XMLStreamWriter writer = xof.createXMLStreamWriter(out,encoding); @@ -353,6 +377,7 @@ } } + @Override public void doRecycle(XMLStreamWriter r) { // no recycling } @@ -367,6 +392,7 @@ this.encoding = encoding; } + @Override public String getEncoding() { return encoding; }