Author: richard.opalka(a)jboss.com
Date: 2008-09-29 07:55:34 -0400 (Mon, 29 Sep 2008)
New Revision: 8284
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
Log:
[JBWS-2325] fixing issue
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2008-09-29
11:01:57 UTC (rev 8283)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2008-09-29
11:55:34 UTC (rev 8284)
@@ -138,8 +138,14 @@
appendDefinitions(builder, namespace);
appendBody(builder, namespace);
- writeBuilder(builder, resolved.writer, resolved.charset);
- resolved.writer.close();
+ try
+ {
+ writeBuilder(builder, resolved.writer, resolved.charset);
+ }
+ finally
+ {
+ resolved.writer.close();
+ }
}
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-09-29
11:01:57 UTC (rev 8283)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-09-29
11:55:34 UTC (rev 8284)
@@ -347,6 +347,14 @@
// clear thread local storage
ThreadLocalAssociation.clear();
DOMUtils.clearThreadLocals();
+ try
+ {
+ outStream.close();
+ }
+ catch (IOException ex)
+ {
+ WSException.rethrow(ex);
+ }
}
}
@@ -384,8 +392,15 @@
SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
DOMDocumentSerializer serializer = new DOMDocumentSerializer();
- serializer.setOutputStream(output);
- serializer.serialize(soapEnv);
+ try
+ {
+ serializer.setOutputStream(output);
+ serializer.serialize(soapEnv);
+ }
+ finally
+ {
+ output.close();
+ }
}
// JSON support
else if (epMetaData.isFeatureEnabled(JsonEncodingFeature.class) &&
resMessage instanceof SOAPMessage)
@@ -400,7 +415,14 @@
}
else
{
- resMessage.writeTo(output);
+ try
+ {
+ resMessage.writeTo(output);
+ }
+ finally
+ {
+ output.close();
+ }
}
}
}
@@ -583,6 +605,7 @@
{
log.debug("handleWSDLRequest: " + endpoint.getName());
+ InputStream inStream = null;
try
{
if (context instanceof ServletRequestContext)
@@ -596,7 +619,7 @@
throw new IllegalArgumentException("Invalid endpoint address: "
+ epAddress);
URL wsdlUrl = new URL(epAddress + "?wsdl");
- InputStream inStream = wsdlUrl.openStream();
+ inStream = wsdlUrl.openStream();
IOUtils.copyStream(outStream, inStream);
}
}
@@ -608,6 +631,31 @@
{
throw new WSException(ex);
}
+ finally
+ {
+ try
+ {
+ outStream.close();
+ }
+ catch (IOException ioe)
+ {
+ throw new WSException(ioe);
+ }
+ finally
+ {
+ if (inStream != null)
+ {
+ try
+ {
+ inStream.close();
+ }
+ catch (IOException ioe)
+ {
+ throw new WSException(ioe);
+ }
+ }
+ }
+ }
}
private void handleWSDLRequestFromServletContext(Endpoint endpoint, OutputStream
outputStream, InvocationContext context) throws MalformedURLException, IOException
@@ -635,8 +683,16 @@
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
Document document = wsdlRequestHandler.getDocumentForPath(reqURL, wsdlHost,
resPath);
- OutputStreamWriter writer = new OutputStreamWriter(outputStream);
- new DOMWriter(writer).setPrettyprint(true).print(document.getDocumentElement());
+ OutputStreamWriter writer = null;
+ try
+ {
+ writer = new OutputStreamWriter(outputStream);
+ new
DOMWriter(writer).setPrettyprint(true).print(document.getDocumentElement());
+ }
+ finally
+ {
+ writer.close();
+ }
}
private void handleException(Exception ex) throws ServletException
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2008-09-29
11:01:57 UTC (rev 8283)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2008-09-29
11:55:34 UTC (rev 8284)
@@ -104,9 +104,10 @@
wsdlFile.getParentFile().mkdirs();
// Get the wsdl definition and write it to the wsdl publish location
+ Writer fWriter = null;
try
{
- Writer fWriter = IOUtils.getCharsetFileWriter(wsdlFile,
Constants.DEFAULT_XML_CHARSET);
+ fWriter = IOUtils.getCharsetFileWriter(wsdlFile,
Constants.DEFAULT_XML_CHARSET);
WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
new WSDLWriter(wsdlDefinitions).write(fWriter,
Constants.DEFAULT_XML_CHARSET);
@@ -140,6 +141,13 @@
{
throw new WSException("Cannot publish wsdl to: " + wsdlFile, e);
}
+ finally
+ {
+ if (fWriter != null)
+ {
+ fWriter.close();
+ }
+ }
}
}
@@ -242,16 +250,37 @@
if (is == null)
throw new IllegalArgumentException("Cannot find schema import
in deployment: " + resourcePath);
- FileOutputStream fos = new FileOutputStream(targetFile);
- IOUtils.copyStream(fos, is);
- fos.close();
- is.close();
+ FileOutputStream fos = null;
+ try
+ {
+ fos = new FileOutputStream(targetFile);
+ IOUtils.copyStream(fos, is);
+ }
+ finally
+ {
+ try
+ {
+ if (fos != null) fos.close();
+ }
+ finally
+ {
+ is.close();
+ }
+ }
log.debug("XMLSchema import published to: " + xsdURL);
- // recursivly publish imports
- Element subdoc = DOMUtils.parse(xsdURL.openStream());
- publishSchemaImports(xsdURL, subdoc, published);
+ // recursively publish imports
+ InputStream xsdStream = xsdURL.openStream();
+ try
+ {
+ Element subdoc = DOMUtils.parse(xsdStream);
+ publishSchemaImports(xsdURL, subdoc, published);
+ }
+ finally
+ {
+ xsdStream.close();
+ }
}
}
}