You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2005/06/02 18:11:40 UTC
svn commit: r179600 - in
/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm:
axis/handlers/AnnotatedWebServiceDeploymentHandler.java
model/jsr181/InitParamInfo.java model/jsr181/Jsr181ObjectModelStore.java
processor/apt/MirrorTypeInfo.java processor/apt/WsmAnnotationProcessor.java
Author: ekoneil
Date: Thu Jun 2 09:11:38 2005
New Revision: 179600
URL: http://svn.apache.org/viewcvs?rev=179600&view=rev
Log:
Fix three more InputStream leaks in WSM.
These were mostly related to the Jsr181ObjectModelStore.load(InputStream) method.
BB: self
DRT: WSM pass
Modified:
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/InitParamInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/MirrorTypeInfo.java
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java?rev=179600&r1=179599&r2=179600&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java Thu Jun 2 09:11:38 2005
@@ -80,8 +80,7 @@
* types were still being sent even with literal Use. Forcing it
* to not send the types unless encoded.
*/
- mc.setProperty(Call.SEND_TYPE_ATTR, new Boolean(Use.ENCODED
- .equals(ss.getUse())));
+ mc.setProperty(Call.SEND_TYPE_ATTR, new Boolean(Use.ENCODED.equals(ss.getUse())));
// blow away the real path to bypass the regular JWSHandler
mc.removeProperty(Constants.MC_REALPATH);
@@ -112,8 +111,7 @@
if(null != clazz) {
ss = soapServices.get(clazz.getName());
if(null == ss) {
- ss = createSOAPService(Jsr181ObjectModelStore.load(clazz),
- clazz);
+ ss = createSOAPService(Jsr181ObjectModelStore.load(clazz), clazz);
}
}
return ss;
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/InitParamInfo.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/InitParamInfo.java?rev=179600&r1=179599&r2=179600&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/InitParamInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/InitParamInfo.java Thu Jun 2 09:11:38 2005
@@ -1,7 +1,4 @@
package org.apache.beehive.wsm.model.jsr181;
-
-import javax.jws.soap.InitParam;
-
/*
* Copyright 2004 The Apache Software Foundation
*
@@ -19,6 +16,8 @@
*
* $Header:$
*/
+
+import javax.jws.soap.InitParam;
public class InitParamInfo
implements java.io.Serializable {
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java?rev=179600&r1=179599&r2=179600&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/model/jsr181/Jsr181ObjectModelStore.java Thu Jun 2 09:11:38 2005
@@ -34,6 +34,7 @@
* Encapsulates all knowledge about where and how object models are persisted.
*/
public class Jsr181ObjectModelStore {
+
private final static String EXTENSION = ".ser";
private final static String LOCATOR = ".webservices";
@@ -71,9 +72,21 @@
*/
public static BeehiveWsTypeMetadata load(Class clazz)
throws IOException, ClassNotFoundException {
+
String resourceName = getLocation(clazz.getName()).toString();
URL url = clazz.getClassLoader().getResource(resourceName);
- return load(url.openStream());
+
+ BeehiveWsTypeMetadata typeMetadata = null;
+ InputStream is = null;
+ try {
+ is = url.openStream();
+ typeMetadata = load(is);
+ }
+ finally {
+ if(is != null)
+ is.close();
+ }
+ return typeMetadata;
}
/**
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/MirrorTypeInfo.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/MirrorTypeInfo.java?rev=179600&r1=179599&r2=179600&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/MirrorTypeInfo.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/MirrorTypeInfo.java Thu Jun 2 09:11:38 2005
@@ -38,9 +38,9 @@
public class MirrorTypeInfo
implements JavaTypeInfo {
- protected TypeDeclaration decl;
- protected AnnotationProcessorEnvironment env;
- protected Collection<JavaMethodInfo> methods = new ArrayList<JavaMethodInfo>();
+ private TypeDeclaration decl;
+ private AnnotationProcessorEnvironment env;
+ private Collection<JavaMethodInfo> methods = new ArrayList<JavaMethodInfo>();
public MirrorTypeInfo(TypeDeclaration decl, AnnotationProcessorEnvironment env) {
if(null == decl) {
Modified: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java?rev=179600&r1=179599&r2=179600&view=diff
==============================================================================
--- incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java (original)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java Thu Jun 2 09:11:38 2005
@@ -20,6 +20,9 @@
import java.util.HashSet;
import java.util.Set;
+import java.io.InputStream;
+import java.io.File;
+import java.io.IOException;
import javax.jws.WebService;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
@@ -47,9 +50,6 @@
private Set<TypeDeclaration> handledDecls = new HashSet<TypeDeclaration>();
private Jsr181ObjectModelStore oms;
- /**
- * Constructor.
- */
public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
super(atds, env);
oms = new Jsr181ObjectModelStore(env);
@@ -77,7 +77,8 @@
}
WebService wsAnnotation = _decl.getAnnotation(WebService.class);
if(null == wsAnnotation) {
- messager.printError(_decl.getPosition(), "@WebService annotation missing; unable to process: " + ((TypeDeclaration)_decl).getQualifiedName());
+ messager.printError(_decl.getPosition(),
+ "@WebService annotation missing; unable to process: " + ((TypeDeclaration)_decl).getQualifiedName());
}
// store declaration so we don't handle it multiple times
@@ -135,8 +136,6 @@
messager.printError(_decl.getPosition(), "found unsupported type of TypeDeclaration:" + _decl.getSimpleName());
}
}
-
- // if an exception or error ocurred log it and return
catch(Throwable t) {
messager.printError(_decl.getPosition(), t.getMessage());
}
@@ -153,11 +152,23 @@
private BeehiveWsTypeMetadata getEndpointInterfaceObjectModel(String endpointInterface) {
BeehiveWsTypeMetadata om = null;
+
// search for persistent object model
+ InputStream is = null;
try {
- om = Jsr181ObjectModelStore.load(getClass().getClassLoader().getResourceAsStream(Jsr181ObjectModelStore.getLocation(endpointInterface).toString()));
+ File file = Jsr181ObjectModelStore.getLocation(endpointInterface);
+ assert file != null : "Found null endpoint location file";
+ is = getClass().getClassLoader().getResourceAsStream(file.toString());
+ om = Jsr181ObjectModelStore.load(is);
}
- catch(Throwable t) {
+ catch(Exception e) {
+ /* todo: this is bad -- some logging / error reporting needs to be done here! */
+ }
+ finally {
+ if(is != null) {
+ try {is.close();}
+ catch(IOException ignore) {}
+ }
}
// try to generate object model
@@ -165,9 +176,20 @@
try {
_env.getMessager().printNotice("-> loading object model for required endpoint interface:" + endpointInterface);
check(_env.getTypeDeclaration(endpointInterface));
- om = Jsr181ObjectModelStore.load(getClass().getClassLoader().getResourceAsStream(Jsr181ObjectModelStore.getLocation(endpointInterface).toString()));
- }
- catch(Throwable t) {
+
+ File file = Jsr181ObjectModelStore.getLocation(endpointInterface);
+ assert file != null : "Found null endpoint interface file";
+ is = getClass().getClass().getResourceAsStream(file.toString());
+ om = Jsr181ObjectModelStore.load(is);
+ }
+ catch(Exception e) {
+ /* todo: this is bad -- some logging / error reporting needs to be done here! */
+ }
+ finally {
+ if(is != null) {
+ try {is.close();}
+ catch(IOException ignore) {}
+ }
}
}
return om;