cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1397666 - in /cxf/branches/2.5.x-fixes: api/src/main/java/org/apache/cxf/wsdl/ common/common/src/main/java/org/apache/cxf/configuration/spring/ common/common/src/main/java/org/apache/cxf/staxutils/ rt/bindings/coloc/src/main/java/org/apach...
Date Fri, 12 Oct 2012 18:26:24 GMT
Author: dkulp
Date: Fri Oct 12 18:26:23 2012
New Revision: 1397666

URL: http://svn.apache.org/viewvc?rev=1397666&view=rev
Log:
Merged revisions 1397658 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1397658 | dkulp | 2012-10-12 14:01:57 -0400 (Fri, 12 Oct 2012) | 11 lines

  Merged revisions 1397657 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1397657 | dkulp | 2012-10-12 13:59:30 -0400 (Fri, 12 Oct 2012) | 3 lines

    [CXF-4557] More updates to make sure the XMLStreamReader/Writers are closed
    Patch from Peng Zhang applied with very slight mods

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
    cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.5.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
    cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
    cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeanStreamSerializer.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
    cxf/branches/2.5.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
    cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSClientParametersConfig.java
    cxf/branches/2.5.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
    cxf/branches/2.5.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Fri Oct 12 18:26:23 2012
@@ -639,6 +639,7 @@ public final class EndpointReferenceUtil
             Map<String, byte[]> schemaSourcesMap = new LinkedHashMap<String, byte[]>();
             Map<String, Source> schemaSourcesMap2 = new LinkedHashMap<String, Source>();
 
+            XMLStreamWriter writer = null;
             try {
                 for (SchemaInfo si : serviceInfo.getSchemas()) {
                     Element el = si.getElement();
@@ -655,7 +656,7 @@ public final class EndpointReferenceUtil
                     DOMSource ds = new DOMSource(el, baseURI);   
                     schemaSourcesMap2.put(si.getSystemId() + ":" + si.getNamespaceURI(),
ds);
                     LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream();
-                    XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
+                    writer = StaxUtils.createXMLStreamWriter(out);
                     StaxUtils.copy(el, writer);
                     writer.flush();
                     schemaSourcesMap.put(si.getSystemId() + ":" + si.getNamespaceURI(), out.toByteArray());
@@ -712,6 +713,7 @@ public final class EndpointReferenceUtil
                         unsetReadonly(nd);
                     }
                 }
+                StaxUtils.close(writer);
             }
             serviceInfo.setProperty(Schema.class.getName(), schema);
         }

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
Fri Oct 12 18:26:23 2012
@@ -273,6 +273,7 @@ public class JAXBExtensionHelper impleme
      */
     public ExtensibilityElement unmarshall(Class parent, QName qname, Element element, Definition
wsdl,
                                            ExtensionRegistry registry) throws WSDLException
{
+        XMLStreamReader reader = null;
         try {
             Unmarshaller u = getContext().createUnmarshaller();
         
@@ -280,7 +281,7 @@ public class JAXBExtensionHelper impleme
             if (namespace == null) {
                 o = u.unmarshal(element);
             } else {
-                XMLStreamReader reader = StaxUtils.createXMLStreamReader(element);
+                reader = StaxUtils.createXMLStreamReader(element);
                 reader = new MappingReaderDelegate(reader);
                 o = u.unmarshal(reader);
             }
@@ -298,6 +299,8 @@ public class JAXBExtensionHelper impleme
             throw new WSDLException(WSDLException.PARSER_ERROR,
                                     "Error reading element " + qname,
                                     ex);
+        } finally {
+            StaxUtils.close(reader);
         }
     }
     

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Fri Oct 12 18:26:23 2012
@@ -335,9 +335,10 @@ public abstract class AbstractBeanDefini
                                             String propertyName, 
                                             Class<?> c) {
         try {
+            XMLStreamWriter xmlWriter = null;
             try {
                 StringWriter writer = new StringWriter();
-                XMLStreamWriter xmlWriter = StaxUtils.createXMLStreamWriter(writer);
+                xmlWriter = StaxUtils.createXMLStreamWriter(writer);
                 StaxUtils.copy(data, xmlWriter);
                 xmlWriter.flush();
     
@@ -363,6 +364,8 @@ public abstract class AbstractBeanDefini
                 if (obj != null) {
                     bean.addPropertyValue(propertyName, obj);
                 }
+            } finally {
+                StaxUtils.close(xmlWriter);
             }
         } catch (JAXBException e) {
             throw new RuntimeException("Could not parse configuration.", e);
@@ -402,6 +405,8 @@ public abstract class AbstractBeanDefini
             xmlWriter.flush();
         } catch (XMLStreamException e) {
             throw new RuntimeException(e);
+        } finally {
+            StaxUtils.close(xmlWriter);
         }
 
         BeanDefinitionBuilder jaxbbean 
@@ -431,6 +436,8 @@ public abstract class AbstractBeanDefini
             throw e;
         } catch (Exception e) {
             throw new RuntimeException(e);
+        } finally {
+            StaxUtils.close(data);
         }
     }
     

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
Fri Oct 12 18:26:23 2012
@@ -60,6 +60,8 @@ public final class JAXBBeanFactory {
             return obj;
         } catch (JAXBException e) {
             throw new RuntimeException(e);
+        } finally {
+            StaxUtils.close(data);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
Fri Oct 12 18:26:23 2012
@@ -458,6 +458,7 @@ public final class StaxUtils {
             } catch (XMLStreamException ex) {
                 //ignore
             }
+            StaxUtils.close(writer);
         }
     }
     public static void copy(Source source, XMLStreamWriter writer) throws XMLStreamException
{
@@ -1576,19 +1577,29 @@ public final class StaxUtils {
 
     public static String toString(Document doc) throws XMLStreamException {
         StringWriter sw = new StringWriter(1024);
-        XMLStreamWriter writer = createXMLStreamWriter(sw);
-        copy(doc, writer);
-        writer.flush();
+        XMLStreamWriter writer = null;
+        try {
+            writer = createXMLStreamWriter(sw);
+            copy(doc, writer);
+            writer.flush();
+        } finally {
+            StaxUtils.close(writer);
+        }
         return sw.toString();
     }
     public static String toString(Element el) throws XMLStreamException {
         StringWriter sw = new StringWriter(1024);
-        XMLStreamWriter writer = createXMLStreamWriter(sw);
-        copy(el, writer);
-        writer.flush();
+        XMLStreamWriter writer = null;
+        try {
+            writer = createXMLStreamWriter(sw);
+            copy(el, writer);
+            writer.flush();
+        } finally {
+            StaxUtils.close(writer);
+        }        
         return sw.toString();
     }
-    
+
     public static void close(XMLStreamReader reader) {
         if (reader != null) {
             try {

Modified: cxf/branches/2.5.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
Fri Oct 12 18:26:23 2012
@@ -259,7 +259,14 @@ public final class ColocUtil {
         DataReader<XMLStreamReader> reader =
             message.getExchange().getService().getDataBinding().createReader(XMLStreamReader.class);
         MessagePartInfo mpi = getMessageInfo(message).getMessagePart(0);
-        Object wrappedObject = reader.read(mpi, StaxUtils.createXMLStreamReader(source));
+        XMLStreamReader streamReader = null;
+        Object wrappedObject = null;
+        try {
+            streamReader = StaxUtils.createXMLStreamReader(source);
+            wrappedObject = reader.read(mpi, streamReader);
+        } finally {
+            StaxUtils.close(streamReader);
+        }
         MessageContentsList parameters = new MessageContentsList();
         parameters.put(mpi, wrappedObject);
 

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Fri Oct 12 18:26:23 2012
@@ -125,13 +125,14 @@ public class ReadHeadersInterceptor exte
             return;
         }
         XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
-
+        boolean closeNeeded = false;
         if (xmlReader == null) {
             InputStream in = (InputStream)message.getContent(InputStream.class);
             if (in == null) {
                 throw new RuntimeException("Can't find input stream in message");
             }
             xmlReader = StaxUtils.createXMLStreamReader(in);
+            closeNeeded = true;
         }
 
         try {
@@ -235,6 +236,10 @@ public class ReadHeadersInterceptor exte
             }
         } catch (XMLStreamException e) {
             throw new SoapFault(new Message("XML_STREAM_EXC", LOG), e, message.getVersion().getSender());
+        } finally {
+            if (closeNeeded) {
+                StaxUtils.close(xmlReader);
+            }
         }
     }
 }

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
Fri Oct 12 18:26:23 2012
@@ -58,6 +58,8 @@ public final class ChannelIdParser {
             }
         } catch (XMLStreamException e) {
             e.printStackTrace();
+        } finally {
+            StaxUtils.close(streamReader);
         }
         
         return 0;

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
Fri Oct 12 18:26:23 2012
@@ -37,8 +37,9 @@ public final class ChannelService {
     }
     
     public static void service(IoSession session, SoapTcpMessage message) {
+        XMLStreamReader xmlReader = null;
         try {
-            XMLStreamReader xmlReader
+            xmlReader
                 = StaxUtils.createXMLStreamReader(message.getContentAsStream(), "UTF-8");
             while (xmlReader.hasNext()) {
                 xmlReader.next();
@@ -77,6 +78,8 @@ public final class ChannelService {
             }
         } catch (XMLStreamException e) {
             e.printStackTrace();
+        } finally {
+            StaxUtils.close(xmlReader);
         }
     }
     

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
Fri Oct 12 18:26:23 2012
@@ -168,6 +168,8 @@ public final class SoapTcpUtils {
                 }
             } catch (XMLStreamException e) {
                 e.printStackTrace();
+            } finally {
+                StaxUtils.close(xmlReader);
             }
         }
         return false;

Modified: cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
Fri Oct 12 18:26:23 2012
@@ -184,12 +184,24 @@ public class StaxBuilder {
 
     public Document build(InputStream is) throws XMLStreamException {
         isReadingMidStream = false;
-        return buildInternal(StaxUtils.createXMLStreamReader(is));
+        XMLStreamReader reader = null;
+        try {
+            reader = StaxUtils.createXMLStreamReader(is);
+            return buildInternal(reader);
+        } finally {
+            StaxUtils.close(reader);
+        }        
     }
 
     public Document build(Reader reader) throws XMLStreamException {
         isReadingMidStream = false;
-        return buildInternal(StaxUtils.createXMLStreamReader(reader));
+        XMLStreamReader streamReader = null;
+        try {
+            streamReader = StaxUtils.createXMLStreamReader(reader);
+            return buildInternal(streamReader);
+        } finally {
+            StaxUtils.close(streamReader);
+        }        
     }
     
     private Document buildInternal(XMLStreamReader r) throws XMLStreamException {

Modified: cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Fri Oct 12 18:26:23 2012
@@ -397,6 +397,8 @@ public final class JAXBEncoderDecoder {
             writer.flush();
         } catch (Exception e) {
             throw new Fault(new Message("MARSHAL_ERROR", LOG, e.getMessage()), e);
+        } finally {
+            StaxUtils.close(writer);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri Oct 12 18:26:23 2012
@@ -323,9 +323,14 @@ public class JAXRSOutInterceptor extends
         if (writer instanceof CachingXmlEventWriter) {
             CachingXmlEventWriter cache = (CachingXmlEventWriter)writer;
             if (cache.getEvents().size() != 0) {
-                XMLStreamWriter origWriter = StaxUtils.createXMLStreamWriter(osOriginal);
-                for (XMLEvent event : cache.getEvents()) {
-                    StaxUtils.writeEvent(event, origWriter);
+                XMLStreamWriter origWriter = null;
+                try {
+                    origWriter = StaxUtils.createXMLStreamWriter(osOriginal);
+                    for (XMLEvent event : cache.getEvents()) {
+                        StaxUtils.writeEvent(event, origWriter);
+                    }
+                } finally {
+                    StaxUtils.close(origWriter);
                 }
             }
             m.setContent(XMLStreamWriter.class, null);

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AegisElementProvider.java
Fri Oct 12 18:26:23 2012
@@ -64,11 +64,14 @@ public class AegisElementProvider<T> ext
         AegisType typeToRead = context.getTypeMapping().getType(genericType);
         
         AegisReader<XMLStreamReader> aegisReader = context.createXMLStreamReader();
+        XMLStreamReader xmlStreamReader = null;
         try {
-            XMLStreamReader xmlStreamReader = createStreamReader(typeToRead, is);
+            xmlStreamReader = createStreamReader(typeToRead, is);
             return type.cast(aegisReader.read(xmlStreamReader, typeToRead));
         } catch (Exception e) {
             throw new WebApplicationException(e);
+        } finally {
+            StaxUtils.close(xmlStreamReader);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
Fri Oct 12 18:26:23 2012
@@ -65,13 +65,16 @@ public class DataBindingProvider<T> impl
     public T readFrom(Class<T> clazz, Type genericType, Annotation[] annotations, MediaType
type, 
                       MultivaluedMap<String, String> headers, InputStream is)
         throws IOException {
+        XMLStreamReader reader = null;
         try {
-            XMLStreamReader reader = createReader(clazz, genericType, is);
+            reader = createReader(clazz, genericType, is);
             DataReader<XMLStreamReader> dataReader = binding.createReader(XMLStreamReader.class);
             Object o = dataReader.read(null, reader, clazz);
             return o == null ? null : clazz.cast(o);
         } catch (Exception ex) {
             throw new WebApplicationException(ex);
+        } finally {
+            StaxUtils.close(reader);
         }
     }
 
@@ -94,11 +97,14 @@ public class DataBindingProvider<T> impl
     public void writeTo(T o, Class<?> clazz, Type genericType, Annotation[] annotations,

                         MediaType type, MultivaluedMap<String, Object> headers, OutputStream
os)
         throws IOException {
+        XMLStreamWriter writer = null;
         try {
-            XMLStreamWriter writer = createWriter(clazz, genericType, os);
+            writer = createWriter(clazz, genericType, os);
             writeToWriter(writer, o);
         } catch (Exception ex) {
             throw new WebApplicationException(ex);
+        } finally {
+            StaxUtils.close(writer);
         }
     }
     

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Fri Oct 12 18:26:23 2012
@@ -156,6 +156,7 @@ public class JAXBElementProvider extends
             }
         }
         
+        XMLStreamReader reader = null;
         try {
             
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
@@ -168,7 +169,7 @@ public class JAXBElementProvider extends
             if (JAXBElement.class.isAssignableFrom(type) 
                 || !isCollection && (unmarshalAsJaxbElement  
                 || jaxbElementClassMap != null && jaxbElementClassMap.containsKey(theType.getName())))
{
-                XMLStreamReader reader = getStreamReader(is, type, mt);
+                reader = getStreamReader(is, type, mt);
                 reader = TransformUtils.createNewReaderIfNeeded(reader, is);
                 if (JAXBElement.class.isAssignableFrom(type) && type == theType)
{
                     response = unmarshaller.unmarshal(reader);
@@ -198,6 +199,8 @@ public class JAXBElementProvider extends
         } catch (Exception e) {
             LOG.warning(getStackTrace(e));
             throw new WebApplicationException(e, Response.status(400).build());        
+        } finally {
+            StaxUtils.close(reader);
         }
         // unreachable
         return null;
@@ -207,7 +210,13 @@ public class JAXBElementProvider extends
         throws JAXBException {
         XMLStreamReader reader = getStreamReader(is, type, mt);
         if (reader != null) {
-            return unmarshalFromReader(unmarshaller, reader, mt);
+            try {
+                return unmarshalFromReader(unmarshaller, reader, mt);
+            } catch (JAXBException e) {
+                throw e;
+            } finally {
+                StaxUtils.close(reader);
+            }
         }
         return unmarshalFromInputStream(unmarshaller, is, mt);
     }
@@ -244,7 +253,12 @@ public class JAXBElementProvider extends
     protected Object unmarshalFromInputStream(Unmarshaller unmarshaller, InputStream is,
MediaType mt) 
         throws JAXBException {
         // Try to create the read before unmarshalling the stream
-        return unmarshaller.unmarshal(StaxUtils.createXMLStreamReader(is));
+        XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(is);
+        try {
+            return unmarshaller.unmarshal(xmlReader);
+        } finally {
+            StaxUtils.close(xmlReader);
+        }
     }
 
     protected Object unmarshalFromReader(Unmarshaller unmarshaller, XMLStreamReader reader,
MediaType mt) 

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Fri Oct 12 18:26:23 2012
@@ -209,12 +209,14 @@ public class JSONProvider extends Abstra
             }
         }
         
+        XMLStreamReader reader = null;
         try {
             InputStream realStream = getInputStream(type, genericType, is);
             if (Document.class.isAssignableFrom(type)) {
                 W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
-                copyReaderToWriter(createReader(type, realStream, false), writer);
-                return writer.getDocument();
+                reader = createReader(type, realStream, false);
+                copyReaderToWriter(reader, writer);
+                return type.cast(writer.getDocument());
             }
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
             Class<?> theGenericType = isCollection ? InjectionUtils.getActualType(genericType)
: type;
@@ -255,6 +257,8 @@ public class JSONProvider extends Abstra
             throw e;
         } catch (Exception e) {
             throw new WebApplicationException(e, Response.status(400).build());
+        } finally {
+            StaxUtils.close(reader);
         }
         // unreachable
         return null;
@@ -348,11 +352,12 @@ public class JSONProvider extends Abstra
             }
             throw new IOException(sb.toString());
         }
+        XMLStreamWriter writer = null;
         try {
             
             String enc = HttpUtils.getSetEncoding(m, headers, "UTF-8");
             if (Document.class.isAssignableFrom(cls)) {
-                XMLStreamWriter writer = createWriter(obj, cls, genericType, enc, os, false);
+                writer = createWriter(obj, cls, genericType, enc, os, false);
                 copyReaderToWriter(StaxUtils.createXMLStreamReader((Document)obj), writer);
                 return;
             }
@@ -375,6 +380,8 @@ public class JSONProvider extends Abstra
             handleXMLStreamException(e, false); 
         } catch (Exception e) {
             throw new WebApplicationException(e);
+        } finally {
+            StaxUtils.close(writer);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
Fri Oct 12 18:26:23 2012
@@ -174,6 +174,7 @@ public class SourceProvider extends Abst
             }
             try {
                 writer.flush();
+                writer.close();
             } catch (XMLStreamException e) {
                 //ignore
             }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeanStreamSerializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeanStreamSerializer.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeanStreamSerializer.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeanStreamSerializer.java
Fri Oct 12 18:26:23 2012
@@ -51,7 +51,7 @@ public class XMLBeanStreamSerializer {
     public void serialize(XmlObject xObj, XMLStreamWriter writer) throws IOException, XMLStreamException
{
 
         File tmpFile = null;
-
+        XMLStreamReader rdr = null;
         try {
 
             // create tmp file
@@ -61,7 +61,7 @@ public class XMLBeanStreamSerializer {
             xObj.save(tmpFile);
 
             InputStream tmpIn = new FileInputStream(tmpFile);
-            XMLStreamReader rdr = StaxUtils.createXMLStreamReader(tmpIn);
+            rdr = StaxUtils.createXMLStreamReader(tmpIn);
 
             while (rdr.hasNext()) {
 
@@ -124,6 +124,7 @@ public class XMLBeanStreamSerializer {
 
                 tmpFile.delete();
             }
+            StaxUtils.close(rdr);
         }
     }
 }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Fri Oct 12 18:26:23 2012
@@ -344,14 +344,16 @@ public class DispatchImpl<T> implements 
             if (findDispatchOp && !payloadOPMap.isEmpty()) {
                 String payloadElementName = null;              
                 if (obj instanceof javax.xml.transform.Source) {
+                    XMLStreamReader reader = null;
                     try {
-                        XMLStreamReader reader = StaxUtils
-                            .createXMLStreamReader((javax.xml.transform.Source)obj);
+                        reader = StaxUtils.createXMLStreamReader((javax.xml.transform.Source)obj);
                         Document document = StaxUtils.read(reader);
                         createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
                         payloadElementName = getPayloadElementName(document.getDocumentElement());
                     } catch (Exception e) {                        
                         // ignore, we are trying to get the operation name
+                    } finally {
+                        StaxUtils.close(reader);
                     }
                 }
                 if (obj instanceof SOAPMessage) {
@@ -477,6 +479,7 @@ public class DispatchImpl<T> implements 
         DataWriter<XMLStreamWriter> dbwriter = dataBinding.createWriter(XMLStreamWriter.class);
         StringWriter stringWriter = new StringWriter();
         XMLStreamWriter resultWriter = StaxUtils.createXMLStreamWriter(stringWriter);
+        DepthXMLStreamReader reader = null;
         try {
             dbwriter.write(object, resultWriter);
             resultWriter.flush();
@@ -484,7 +487,7 @@ public class DispatchImpl<T> implements 
                 ByteArrayInputStream binput = new ByteArrayInputStream(stringWriter.getBuffer().toString()
                     .getBytes());
                 XMLStreamReader xmlreader = StaxUtils.createXMLStreamReader(binput);
-                DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlreader);
+                reader = new DepthXMLStreamReader(xmlreader);
 
                 StaxUtils.skipToStartOfElement(reader);
 
@@ -493,6 +496,9 @@ public class DispatchImpl<T> implements 
             }
         } catch (XMLStreamException e) {
             // ignore
+        } finally {
+            StaxUtils.close(reader);
+            StaxUtils.close(resultWriter);
         }
         return null;
     }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Fri Oct 12 18:26:23 2012
@@ -242,13 +242,16 @@ public class SwAOutInterceptor extends A
             }
         } else {
             ByteArrayOutputStream bwriter = new ByteArrayOutputStream();
-            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bwriter);
+            XMLStreamWriter writer = null;
             try {
-                StaxUtils.copy((Source)o, writer);
+                writer = StaxUtils.createXMLStreamWriter(bwriter);
+                StaxUtils.copy(o, writer);
                 writer.flush();
                 ds = new ByteDataSource(bwriter.toByteArray(), ct);
             } catch (XMLStreamException e1) {
                 throw new Fault(e1);
+            } finally {
+                StaxUtils.close(writer);
             }
         }
         return ds;

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
Fri Oct 12 18:26:23 2012
@@ -30,6 +30,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.EndpointReference;
@@ -324,12 +325,16 @@ public class ProviderImpl extends javax.
     }
 
     public EndpointReference readEndpointReference(Source eprInfoset) {
+        XMLStreamReader reader = null;
         try {
             Unmarshaller unmarshaller = getJAXBContext().createUnmarshaller();
-            return (EndpointReference)unmarshaller.unmarshal(StaxUtils.createXMLStreamReader(eprInfoset));
+            reader = StaxUtils.createXMLStreamReader(eprInfoset);
+            return (EndpointReference)unmarshaller.unmarshal(reader);
         } catch (JAXBException e) {
             throw new WebServiceException(new Message("ERROR_UNMARSHAL_ENDPOINTREFERENCE",
LOG).toString(),
                                           e);
+        } finally {
+            StaxUtils.close(reader);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
Fri Oct 12 18:26:23 2012
@@ -78,6 +78,8 @@ public class WSDLGetInterceptor extends 
             throw new WSDLQueryException(new org.apache.cxf.common.i18n.Message("COULD_NOT_PROVIDE_WSDL",
                                                                                 LOG,
                                                                                 base), e);
+        } finally {
+            StaxUtils.close(writer);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSClientParametersConfig.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSClientParametersConfig.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSClientParametersConfig.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/configuration/jsse/spring/TLSClientParametersConfig.java
Fri Oct 12 18:26:23 2012
@@ -144,6 +144,8 @@ public final class TLSClientParametersCo
             throw e;
         } catch (Exception e) {
             throw new RuntimeException(e);
+        } finally {
+            StaxUtils.close(data);
         }
     }
 

Modified: cxf/branches/2.5.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
(original)
+++ cxf/branches/2.5.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
Fri Oct 12 18:26:23 2012
@@ -57,13 +57,16 @@ public class Stax2DOM {
 
     public Document getDocument(URL url) throws ToolException {
         InputStream input = null;
+        XMLStreamReader reader = null;
         try {
             input = url.openStream();
             StreamSource src = new StreamSource(input, url.toExternalForm());
-            return StaxUtils.read(StaxUtils.createXMLStreamReader(src), true);
+            reader = StaxUtils.createXMLStreamReader(src);
+            return StaxUtils.read(reader, true);
         } catch (Exception e) {
             throw new ToolException(e);
         } finally {
+            StaxUtils.close(reader);
             if (input != null) {
                 try {
                     input.close();

Modified: cxf/branches/2.5.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=1397666&r1=1397665&r2=1397666&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/branches/2.5.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Fri Oct 12 18:26:23 2012
@@ -154,11 +154,20 @@ public final class CustomizationParser {
             return null;
         }
         
+        XMLStreamReader reader = null;
         try {
-            doc = DOMUtils.readXml(ins);
+            reader = StaxUtils.createXMLStreamReader(uri, ins);
+            doc = StaxUtils.read(reader, true);
         } catch (Exception e) {
             Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {uri});
             throw new ToolException(msg, e);
+        } finally {
+            StaxUtils.close(reader);
+            try {
+                ins.close();
+            } catch (IOException ex) {
+                //ignore
+            }
         }
         try {
             doc.setDocumentURI(uri);
@@ -463,12 +472,17 @@ public final class CustomizationParser {
     private void addBinding(String bindingFile) throws XMLStreamException {
 
         Element root = null;
+        XMLStreamReader xmlReader = null;
         try {
             URIResolver resolver = new URIResolver(bindingFile);
-            root = DOMUtils.readXml(resolver.getInputStream()).getDocumentElement();
+            xmlReader = StaxUtils.createXMLStreamReader(resolver.getURI().toString(),
+                                                                     resolver.getInputStream());
+            root = StaxUtils.read(xmlReader, true).getDocumentElement();
         } catch (Exception e1) {
             Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] {bindingFile});
             throw new ToolException(msg, e1);
+        } finally {
+            StaxUtils.close(xmlReader);
         }
         XMLStreamReader reader = StaxUtils.createXMLStreamReader(root);
         StaxUtils.toNextTag(reader);



Mime
View raw message