cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1397658 - in /cxf/branches/2.6.x-fixes: api/src/main/java/org/apache/cxf/configuration/jsse/ api/src/main/java/org/apache/cxf/configuration/spring/ api/src/main/java/org/apache/cxf/staxutils/ api/src/main/java/org/apache/cxf/wsdl/ rt/bindi...
Date Fri, 12 Oct 2012 18:01:58 GMT
Author: dkulp
Date: Fri Oct 12 18:01:57 2012
New Revision: 1397658

URL: http://svn.apache.org/viewvc?rev=1397658&view=rev
Log:
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.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
    cxf/branches/2.6.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
    cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
    cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
    cxf/branches/2.6.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProvider.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeanStreamSerializer.java
    cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
    cxf/branches/2.6.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
    cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/jsse/TLSClientParametersConfig.java
Fri Oct 12 18:01:57 2012
@@ -155,6 +155,8 @@ public final class TLSClientParametersCo
             throw e;
         } catch (Exception e) {
             throw new RuntimeException(e);
+        } finally {
+            StaxUtils.close(data);
         }
     }
     

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
Fri Oct 12 18:01:57 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.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/configuration/spring/JAXBBeanFactory.java
Fri Oct 12 18:01:57 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.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri
Oct 12 18:01:57 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.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Fri Oct 12 18:01:57 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.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
Fri Oct 12 18:01:57 2012
@@ -277,6 +277,7 @@ public class JAXBExtensionHelper impleme
     public ExtensibilityElement unmarshall(@SuppressWarnings("rawtypes") Class parent, 
                                            QName qname, Element element, Definition wsdl,
                                            ExtensionRegistry registry) throws WSDLException
{
+        XMLStreamReader reader = null;
         try {
             Unmarshaller u = getContext().createUnmarshaller();
         
@@ -284,7 +285,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);
             }
@@ -302,6 +303,8 @@ public class JAXBExtensionHelper impleme
             throw new WSDLException(WSDLException.PARSER_ERROR,
                                     "Error reading element " + qname,
                                     ex);
+        } finally {
+            StaxUtils.close(reader);
         }
     }
     

Modified: cxf/branches/2.6.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
Fri Oct 12 18:01:57 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.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Fri Oct 12 18:01:57 2012
@@ -127,13 +127,14 @@ public class ReadHeadersInterceptor exte
             return;
         }
         XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
-
+        boolean closeNeeded = false;
         if (xmlReader == null) {
             InputStream in = message.getContent(InputStream.class);
             if (in == null) {
                 throw new RuntimeException("Can't find input stream in message");
             }
             xmlReader = StaxUtils.createXMLStreamReader(in);
+            closeNeeded = true;
         }
 
         try {
@@ -240,6 +241,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.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelIdParser.java
Fri Oct 12 18:01:57 2012
@@ -58,6 +58,8 @@ public final class ChannelIdParser {
             }
         } catch (XMLStreamException e) {
             e.printStackTrace();
+        } finally {
+            StaxUtils.close(streamReader);
         }
         
         return 0;

Modified: cxf/branches/2.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/ChannelService.java
Fri Oct 12 18:01:57 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.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/tcp/SoapTcpUtils.java
Fri Oct 12 18:01:57 2012
@@ -168,6 +168,8 @@ public final class SoapTcpUtils {
                 }
             } catch (XMLStreamException e) {
                 e.printStackTrace();
+            } finally {
+                StaxUtils.close(xmlReader);
             }
         }
         return false;

Modified: cxf/branches/2.6.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.6.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
Fri Oct 12 18:01:57 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.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Fri Oct 12 18:01:57 2012
@@ -400,6 +400,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.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri Oct 12 18:01:57 2012
@@ -349,9 +349,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.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
Fri Oct 12 18:01:57 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.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Fri Oct 12 18:01:57 2012
@@ -149,6 +149,7 @@ public class JAXBElementProvider<T> exte
             }
         }
         
+        XMLStreamReader reader = null;
         try {
             
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
@@ -161,7 +162,7 @@ public class JAXBElementProvider<T> exte
             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);
@@ -191,6 +192,8 @@ public class JAXBElementProvider<T> exte
         } catch (Exception e) {
             LOG.warning(getStackTrace(e));
             throw new WebApplicationException(e, Response.status(400).build());        
+        } finally {
+            StaxUtils.close(reader);
         }
         // unreachable
         return null;
@@ -200,7 +203,13 @@ public class JAXBElementProvider<T> exte
         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);
     }
@@ -237,15 +246,21 @@ public class JAXBElementProvider<T> exte
     protected Object unmarshalFromInputStream(Unmarshaller unmarshaller, InputStream is,
MediaType mt) 
         throws JAXBException {
         // Try to create the read before unmarshalling the stream
-        if (is == null) {
-            Reader reader = getStreamHandlerFromCurrentMessage(Reader.class);
-            if (reader == null) {
-                LOG.severe("No InputStream, Reader, or XMStreamReader is available");
-                throw new WebApplicationException(500);
+        XMLStreamReader xmlReader = null;
+        try {
+            if (is == null) {
+                Reader reader = getStreamHandlerFromCurrentMessage(Reader.class);
+                if (reader == null) {
+                    LOG.severe("No InputStream, Reader, or XMStreamReader is available");
+                    throw new WebApplicationException(500);
+                }
+                xmlReader = StaxUtils.createXMLStreamReader(reader);
+            } else {
+                xmlReader = StaxUtils.createXMLStreamReader(is);
             }
-            return unmarshaller.unmarshal(StaxUtils.createXMLStreamReader(reader));
-        } else {
-            return unmarshaller.unmarshal(StaxUtils.createXMLStreamReader(is));
+            return unmarshaller.unmarshal(xmlReader);
+        } finally {
+            StaxUtils.close(xmlReader);
         }
     }
 

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
Fri Oct 12 18:01:57 2012
@@ -174,6 +174,7 @@ public class SourceProvider<T> extends A
             }
             try {
                 writer.flush();
+                writer.close();
             } catch (XMLStreamException e) {
                 //ignore
             }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
Fri Oct 12 18:01:57 2012
@@ -345,14 +345,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) {
@@ -478,6 +480,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();
@@ -485,7 +488,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);
 
@@ -494,6 +497,9 @@ public class DispatchImpl<T> implements 
             }
         } catch (XMLStreamException e) {
             // ignore
+        } finally {
+            StaxUtils.close(reader);
+            StaxUtils.close(resultWriter);
         }
         return null;
     }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
Fri Oct 12 18:01:57 2012
@@ -243,13 +243,16 @@ public class SwAOutInterceptor extends A
             }
         } else {
             ByteArrayOutputStream bwriter = new ByteArrayOutputStream();
-            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bwriter);
+            XMLStreamWriter writer = null;
             try {
+                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.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spi/ProviderImpl.java
Fri Oct 12 18:01:57 2012
@@ -31,6 +31,7 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.ws.Endpoint;
@@ -374,12 +375,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.6.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
Fri Oct 12 18:01:57 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.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProvider.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProvider.java
Fri Oct 12 18:01:57 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.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
Fri Oct 12 18:01:57 2012
@@ -202,11 +202,13 @@ public class JSONProvider<T> extends Abs
             }
         }
         
+        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);
+                reader = createReader(type, realStream, false);
+                copyReaderToWriter(reader, writer);
                 return type.cast(writer.getDocument());
             }
             boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(type);
@@ -248,6 +250,8 @@ public class JSONProvider<T> extends Abs
             throw e;
         } catch (Exception e) {
             throw new WebApplicationException(e, Response.status(400).build());
+        } finally {
+            StaxUtils.close(reader);
         }
         // unreachable
         return null;
@@ -341,11 +345,12 @@ public class JSONProvider<T> extends Abs
             }
             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;
             }
@@ -368,6 +373,8 @@ public class JSONProvider<T> extends Abs
             handleXMLStreamException(e, false);
         } catch (Exception e) {
             throw new WebApplicationException(e);
+        } finally {
+            StaxUtils.close(writer);
         }
     }
 

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeanStreamSerializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeanStreamSerializer.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeanStreamSerializer.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/xmlbeans/XMLBeanStreamSerializer.java
Fri Oct 12 18:01:57 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.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyAnnotationListener.java
Fri Oct 12 18:01:57 2012
@@ -28,6 +28,7 @@ import java.util.ListIterator;
 
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
@@ -421,9 +422,10 @@ public class PolicyAnnotationListener im
         if (null == src) {
             return null;
         }
-        
+        XMLStreamReader reader = null;
         try {
-            Document doc = StaxUtils.read(StaxUtils.createXMLStreamReader(src));
+            reader = StaxUtils.createXMLStreamReader(src);
+            Document doc = StaxUtils.read(reader);
             uri = getPolicyId(doc.getDocumentElement());
             if (StringUtils.isEmpty(uri)) {
                 uri = defName; 
@@ -436,6 +438,8 @@ public class PolicyAnnotationListener im
             return doc.getDocumentElement();
         } catch (XMLStreamException e) {
             return null;
+        } finally {
+            StaxUtils.close(reader);
         }
     }
     

Modified: cxf/branches/2.6.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/Stax2DOM.java
Fri Oct 12 18:01:57 2012
@@ -56,13 +56,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.6.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.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=1397658&r1=1397657&r2=1397658&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
(original)
+++ cxf/branches/2.6.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
Fri Oct 12 18:01:57 2012
@@ -154,13 +154,15 @@ public final class CustomizationParser {
             return null;
         }
         
+        XMLStreamReader reader = null;
         try {
-            XMLStreamReader reader = StaxUtils.createXMLStreamReader(uri, 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) {
@@ -478,14 +480,17 @@ public final class CustomizationParser {
     private void addBinding(String bindingFile) throws XMLStreamException {
 
         Element root = null;
+        XMLStreamReader xmlReader = null;
         try {
             URIResolver resolver = new URIResolver(bindingFile);
-            XMLStreamReader reader = StaxUtils.createXMLStreamReader(resolver.getURI().toString(),

+            xmlReader = StaxUtils.createXMLStreamReader(resolver.getURI().toString(), 
                                                                      resolver.getInputStream());
-            root = StaxUtils.read(reader, true).getDocumentElement();
+            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