summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-03-22 15:53:41 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-03-22 15:53:41 +0000
commit73da1fdb893118d67777a2e8962965d2336ca6e2 (patch)
tree9bf7b022e9596480521f05f49638fbe3e679a2a1 /sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org
parenta16f36a53eaefe3e6f60df7537baecb2ab6f9a11 (diff)
TUSCANY-4034 - plug a few more potential memory leaks
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1303855 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java5
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java9
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java17
3 files changed, 23 insertions, 8 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
index ca39ec0e62..923d13cd5e 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.interfacedef.java.jaxws;
import java.lang.annotation.Annotation;
+import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -119,8 +120,8 @@ public abstract class BaseBeanGenerator implements Opcodes {
JAVA_KEYWORDS.put("enum", "_enum");
}
- protected static final Map<Object, Class<?>> generatedClasses =
- Collections.synchronizedMap(new WeakHashMap<Object, Class<?>>());
+ protected static final Map<Object, WeakReference<Class<?>>> generatedClasses =
+ Collections.synchronizedMap(new WeakHashMap<Object, WeakReference<Class<?>>>());
protected XMLAdapterExtensionPoint xmlAdapters;
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
index 2e82428f7e..28fd2afe73 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java
@@ -23,6 +23,7 @@ import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.lang.ref.WeakReference;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -108,7 +109,11 @@ public class FaultBeanGenerator extends BaseBeanGenerator {
public Class<?> generate(Class<? extends Throwable> exceptionClass, GeneratedClassLoader cl, Operation operation) {
synchronized (exceptionClass) {
QName element = getElementName(exceptionClass, operation);
- Class<?> faultBeanClass = generatedClasses.get(element);
+ WeakReference<Class<?>> wr = generatedClasses.get(element);
+ Class<?> faultBeanClass = null;
+ if (wr != null){
+ faultBeanClass = wr.get();
+ }
if (faultBeanClass == null) {
// TUSCANY-3283 - all generated classes (including exception) should go in the namespace
@@ -122,7 +127,7 @@ public class FaultBeanGenerator extends BaseBeanGenerator {
String classSignature = "L" + classDescriptor + ";";
faultBeanClass = generate(classDescriptor, classSignature, namespace, name, getProperties(exceptionClass), cl);
- generatedClasses.put(element, faultBeanClass);
+ generatedClasses.put(element, new WeakReference<Class<?>>(faultBeanClass));
}
return faultBeanClass;
}
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
index 42151464a4..ab7036c0ce 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.interfacedef.java.jaxws;
import java.lang.annotation.Annotation;
+import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -64,7 +65,11 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
GeneratedClassLoader cl) {
synchronized (m.getDeclaringClass()) {
MethodKey key = new MethodKey(m, true);
- Class<?> wrapperClass = generatedClasses.get(key);
+ WeakReference<Class<?>> wr = generatedClasses.get(key);
+ Class<?> wrapperClass = null;
+ if (wr != null){
+ wrapperClass = wr.get();
+ }
if (wrapperClass == null) {
String wrapperClassDescriptor = wrapperClassName.replace('.', '/');
String wrapperClassSignature = "L" + wrapperClassDescriptor + ";";
@@ -110,7 +115,7 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
wrapperClass =
generate(wrapperClassDescriptor, wrapperClassSignature, wrapperNamespace, wrapperName, properties
.toArray(new BeanProperty[properties.size()]), cl);
- generatedClasses.put(key, wrapperClass);
+ generatedClasses.put(key, new WeakReference<Class<?>>(wrapperClass));
}
return wrapperClass;
@@ -134,7 +139,11 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
GeneratedClassLoader cl) {
synchronized (m.getDeclaringClass()) {
MethodKey key = new MethodKey(m, false);
- Class<?> wrapperClass = generatedClasses.get(key);
+ WeakReference<Class<?>> wr = generatedClasses.get(key);
+ Class<?> wrapperClass = null;
+ if (wr != null){
+ wrapperClass = wr.get();
+ }
if (wrapperClass == null) {
String wrapperClassDescriptor = wrapperClassName.replace('.', '/');
String wrapperClassSignature = "L" + wrapperClassDescriptor + ";";
@@ -212,7 +221,7 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
wrapperClass =
generate(wrapperClassDescriptor, wrapperClassSignature, wrapperNamespace, wrapperName, properties
.toArray(new BeanProperty[properties.size()]), cl);
- generatedClasses.put(key, wrapperClass);
+ generatedClasses.put(key, new WeakReference<Class<?>>(wrapperClass));
}
return wrapperClass;