[jbossws-commits] JBossWS SVN: r8363 - in stack/native/trunk/modules/core/src/main/java/org/jboss: ws/metadata/config and 3 other directories.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Tue Oct 7 02:24:57 EDT 2008
Author: richard.opalka at jboss.com
Date: 2008-10-07 02:24:56 -0400 (Tue, 07 Oct 2008)
New Revision: 8363
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.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] always close streams
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2008-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -23,6 +23,7 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
@@ -137,11 +138,12 @@
if (storeType == null)
storeType = "jks";
- KeyStore keyStore = null;
+ KeyStore keyStore = null;
+ InputStream stream = null;
try
{
log.debug("loadStore: " + storeURL);
- InputStream stream = storeURL.openStream();
+ stream = storeURL.openStream();
if (stream == null)
throw new WSSecurityException("Cannot load store from: " + storeURL);
@@ -167,6 +169,20 @@
{
throw new WSSecurityException("Problems loading " + type + ": " + ex.getMessage(), ex);
}
+ finally
+ {
+ if (stream != null)
+ {
+ try
+ {
+ stream.close();
+ }
+ catch (IOException ioe)
+ {
+ log.warn(ioe.getMessage(), ioe);
+ }
+ }
+ }
return keyStore;
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2008-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -22,6 +22,7 @@
package org.jboss.ws.metadata.config;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import org.jboss.logging.Logger;
@@ -69,6 +70,7 @@
if(log.isDebugEnabled()) log.debug("parse: " + configURL);
Object wsConfig;
+ InputStream is = null;
try
{
Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
@@ -76,13 +78,14 @@
unmarshaller.setSchemaValidation(true);
String nsURI = getNamespaceURI(configURL);
+ is = configURL.openStream();
if (URN_JAXRPC_CONFIG.equals(nsURI))
{
- wsConfig = unmarshaller.unmarshal(configURL.openStream(), new OMFactoryJAXRPC(), null);
+ wsConfig = unmarshaller.unmarshal(is, new OMFactoryJAXRPC(), null);
}
else if (URN_JAXWS_CONFIG.equals(nsURI))
{
- wsConfig = unmarshaller.unmarshal(configURL.openStream(), new OMFactoryJAXWS(), null);
+ wsConfig = unmarshaller.unmarshal(is, new OMFactoryJAXWS(), null);
}
else
{
@@ -98,6 +101,20 @@
{
throw new WSException("Failed to read config file: " + configURL, e);
}
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException ioe)
+ {
+ if(log.isDebugEnabled()) log.warn(ioe.getMessage(), ioe);
+ }
+ }
+ }
return wsConfig;
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java 2008-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.metadata.wsdl.xmlschema;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -34,6 +36,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.core.utils.ResourceURL;
+import org.jboss.wsf.common.IOUtils;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -155,15 +158,19 @@
private XMLInputSource getXMLInputSource(URL url, XMLResourceIdentifier resId) throws IOException
{
- InputStream inputStream = new ResourceURL(url).openStream();
- InputSource inputSource = new InputSource(inputStream);
+ InputStream urlStream = new ResourceURL(url).openStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, urlStream); // [JBWS-2325]
+ InputSource inputSource = new InputSource(new ByteArrayInputStream(baos.toByteArray()));
return getXMLInputSource(inputSource, resId);
}
- private XMLInputSource getXMLInputSource(InputSource inputSource, XMLResourceIdentifier resId)
+ private XMLInputSource getXMLInputSource(InputSource inputSource, XMLResourceIdentifier resId) throws IOException
{
String encoding = inputSource.getEncoding();
- InputStream byteStream = inputSource.getByteStream();
- return new XMLInputSource(resId.getPublicId(), resId.getExpandedSystemId(), resId.getBaseSystemId(), byteStream, encoding);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, inputSource.getByteStream()); // [JBWS-2325]
+ InputStream is = new ByteArrayInputStream(baos.toByteArray());
+ return new XMLInputSource(resId.getPublicId(), resId.getExpandedSystemId(), resId.getBaseSystemId(), is, encoding);
}
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2008-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -163,6 +163,7 @@
Iterator<String> it = locs.keySet().iterator();
while (it.hasNext())
{
+ InputStream in = null;
try
{
String nsURI = it.next();
@@ -174,7 +175,7 @@
XMLInputSource inputSource = new XMLInputSource(null, url.toExternalForm(), null);
InputSource tmpSrc = resolver.resolveEntity(null, url.toExternalForm());
- InputStream in = tmpSrc.getByteStream() != null ? tmpSrc.getByteStream() : new ResourceURL(url).openStream();
+ in = tmpSrc.getByteStream() != null ? tmpSrc.getByteStream() : new ResourceURL(url).openStream();
inputSource.setByteStream(in);
SchemaGrammar grammar = (SchemaGrammar)loader.loadGrammar(inputSource);
@@ -191,6 +192,20 @@
{
throw new IllegalStateException("Cannot parse schema", ex);
}
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException ioe)
+ {
+ log.warn(ioe.getMessage(), ioe);
+ }
+ }
+ }
}
XSModel xsmodel = new XSModelImpl(gs);
@@ -240,46 +255,4 @@
helper.setWsdlStyle(style);
}
- //******************************************************************
- // PRIVATE METHODS
- //******************************************************************
-
- /**
- * FIXME: JBXB-33
- */
- private SchemaBindingResolver getSchemaBindingResolver(final Map<String, URL> map)
- {
- return new SchemaBindingResolver()
- {
- public String getBaseURI()
- {
- throw new UnsupportedOperationException("getBaseURI is not implemented.");
- }
-
- public void setBaseURI(String baseURI)
- {
- throw new UnsupportedOperationException("setBaseURI is not implemented.");
- }
-
- public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation)
- {
- throw new UnsupportedOperationException("resolve is not implemented.");
- }
-
- public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation)
- {
- URL url = map.get(nsUri);
- if (url != null)
- try
- {
- return new LSInputAdaptor(url.openStream(), null);
- }
- catch (IOException e)
- {
- log.error("URL is bad for schema parsing");
- }
- return null;
- }
- };
- }
}
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-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -605,7 +605,6 @@
{
log.debug("handleWSDLRequest: " + endpoint.getName());
- InputStream inStream = null;
try
{
if (context instanceof ServletRequestContext)
@@ -619,8 +618,7 @@
throw new IllegalArgumentException("Invalid endpoint address: " + epAddress);
URL wsdlUrl = new URL(epAddress + "?wsdl");
- inStream = wsdlUrl.openStream();
- IOUtils.copyStream(outStream, inStream);
+ IOUtils.copyStream(outStream, wsdlUrl.openStream());
}
}
catch (RuntimeException rte)
@@ -641,20 +639,6 @@
{
throw new WSException(ioe);
}
- finally
- {
- if (inStream != null)
- {
- try
- {
- inStream.close();
- }
- catch (IOException ioe)
- {
- throw new WSException(ioe);
- }
- }
- }
}
}
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-10-07 05:01:19 UTC (rev 8362)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2008-10-07 06:24:56 UTC (rev 8363)
@@ -258,14 +258,7 @@
}
finally
{
- try
- {
- if (fos != null) fos.close();
- }
- finally
- {
- is.close();
- }
+ if (fos != null) fos.close();
}
log.debug("XMLSchema import published to: " + xsdURL);
More information about the jbossws-commits
mailing list