Author: darran.lofthouse(a)jboss.com
Date: 2009-02-10 12:18:22 -0500 (Tue, 10 Feb 2009)
New Revision: 9278
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/JavaToXSD.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/version.properties
Log:
[JBPAPP-1696] Each request results to an open file descriptor.
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/core/jaxws/handler/MessageContextJAXWS.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -21,8 +21,8 @@
*/
package org.jboss.ws.core.jaxws.handler;
-// $Id: MessageContextImpl.java 275 2006-05-04 21:36:29Z jason.greene(a)jboss.com $
-
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
@@ -37,6 +37,7 @@
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.metadata.umdm.ServiceMetaData;
+import org.jboss.wsf.common.IOUtils;
import org.jboss.xb.binding.NamespaceRegistry;
import org.xml.sax.InputSource;
@@ -135,7 +136,9 @@
{
try
{
- InputSource inputSource = new InputSource(wsdlURL.openStream());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copyStream(baos, wsdlURL.openStream()); // [JBWS-2325] ensure file
descriptors are closed
+ InputSource inputSource = new InputSource(new
ByteArrayInputStream(baos.toByteArray()));
put(MessageContext.WSDL_DESCRIPTION, inputSource);
}
catch (IOException ex)
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -25,6 +25,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;
@@ -136,11 +137,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);
@@ -166,6 +168,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/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -24,6 +24,7 @@
//$Id$
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import org.jboss.logging.Logger;
@@ -71,6 +72,7 @@
if(log.isDebugEnabled()) log.debug("parse: " + configURL);
Object wsConfig;
+ InputStream is = null;
try
{
Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
@@ -78,13 +80,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
{
@@ -100,6 +103,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/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/metadata/wsdl/xmlschema/JBossXSEntityResolver.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -21,8 +21,9 @@
*/
package org.jboss.ws.metadata.wsdl.xmlschema;
-// $Id$
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -36,6 +37,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;
@@ -157,15 +159,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);
}
}
\ No newline at end of file
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/JavaToXSD.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/JavaToXSD.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -165,6 +165,7 @@
Iterator<String> it = locs.keySet().iterator();
while (it.hasNext())
{
+ InputStream in = null;
try
{
String nsURI = it.next();
@@ -176,7 +177,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);
@@ -193,6 +194,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);
@@ -242,46 +257,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/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Writer.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -137,8 +137,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/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/RequestHandlerImpl.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -187,7 +187,7 @@
ClassLoader classLoader =
endpoint.getService().getDeployment().getRuntimeClassLoader();
if (classLoader == null)
throw new IllegalStateException("Deployment has no classloader
associated");
-
+
// Set the thread context class loader
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
@@ -204,7 +204,7 @@
{
// Reset the thread context class loader
Thread.currentThread().setContextClassLoader(ctxClassLoader);
-
+
try
{
out.close();
@@ -232,7 +232,7 @@
throw new IllegalStateException("Cannot obtain endpoint meta data");
Type type = sepMetaData.getType();
-
+
// Build the message context
CommonMessageContext msgContext;
if (type == EndpointMetaData.Type.JAXRPC)
@@ -254,12 +254,12 @@
if (invContext instanceof ServletRequestContext)
{
ServletRequestContext reqContext = (ServletRequestContext)invContext;
-
+
ServletContext servletContext = reqContext.getServletContext();
HttpServletRequest httpRequest = reqContext.getHttpServletRequest();
httpResponse = reqContext.getHttpServletResponse();
headerSource = new ServletHeaderSource(httpRequest, httpResponse);
-
+
if (type == EndpointMetaData.Type.JAXRPC)
{
msgContext.put(MessageContextJAXRPC.SERVLET_CONTEXT, servletContext);
@@ -363,8 +363,7 @@
/**
* Handle a request to this web service endpoint
*/
- private MessageAbstraction processRequest(Endpoint ep, MimeHeaderSource headerSource,
InvocationContext reqContext, InputStream inputStream)
- throws BindingException
+ private MessageAbstraction processRequest(Endpoint ep, MimeHeaderSource headerSource,
InvocationContext reqContext, InputStream inputStream) throws BindingException
{
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
@@ -482,11 +481,11 @@
private long initRequestMetrics(Endpoint endpoint)
{
long beginTime = 0;
-
+
EndpointMetrics metrics = endpoint.getEndpointMetrics();
if (metrics != null)
beginTime = metrics.processRequestMessage();
-
+
return beginTime;
}
@@ -550,7 +549,7 @@
if (ServerConfig.UNDEFINED_HOSTNAME.equals(serverConfig.getWebServiceHost()) ==
false)
wsdlHost = serverConfig.getWebServiceHost();
-
+
log.debug("WSDL request, using host: " + wsdlHost);
WSDLRequestHandler wsdlRequestHandler = new WSDLRequestHandler(epMetaData);
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/src/main/java/org/jboss/wsf/stack/jbws/WSDLFilePublisher.java 2009-02-10
17:18:22 UTC (rev 9278)
@@ -105,9 +105,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);
@@ -141,6 +142,13 @@
{
throw new WSException("Cannot publish wsdl to: " + wsdlFile, e);
}
+ finally
+ {
+ if (fWriter != null)
+ {
+ fWriter.close();
+ }
+ }
}
}
@@ -245,15 +253,21 @@
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
+ {
+ if (fos != null) fos.close();
+ }
if (log.isDebugEnabled())
log.debug("XMLSchema import published to: " + xsdURL);
- // recursivly publish imports
+ // recursively publish imports
Element subdoc = DOMUtils.parse(xsdURL.openStream());
publishSchemaImports(xsdURL, subdoc, published);
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/version.properties
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/version.properties 2009-02-10
17:07:03 UTC (rev 9277)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP04_JBPAPP-1696/version.properties 2009-02-10
17:18:22 UTC (rev 9278)
@@ -5,8 +5,8 @@
specification.vendor=JBoss (
http://www.jboss.org)
specification.version=jbossws-2.0
-version.id=2.0.1.SP2_CP04
-repository.id=2.0.1.SP2_CP04
+version.id=2.0.1.SP2_CP04_JBPAPP-1696
+repository.id=2.0.1.SP2_CP04_JBPAPP-1696
implementation.title=JBoss Web Services - Native
implementation.url=http://www.jboss.org/products/jbossws
@@ -25,7 +25,7 @@
# Dependend integration projects
jbossws-spi=1.0.0.GA_CP01-brew
-jbossws-common=1.0.0.GA_CP02-brew
+jbossws-common=1.0.0.GA_CP02_JBPAPP-1696
jbossws-framework=2.0.1.GA_CP02-brew
jbossws-jboss40=2.0.1.GA
jbossws-jboss42=2.0.1.GA_CP01