changeset 6417:20943f5b3791

RT-36087 JavaBeanProperty: memory leak?
author Martin Sladecek <martin.sladecek@oracle.com>
date Tue, 04 Mar 2014 14:11:49 +0100
parents 085d0c62f4c8
children 1e707c916396
files modules/base/src/main/java/javafx/beans/property/adapter/DescriptorListenerCleaner.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanBooleanProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanDoubleProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanFloatProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanIntegerProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanLongProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanObjectProperty.java modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanStringProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanBooleanProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanDoubleProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanFloatProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanLongProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanObjectProperty.java modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanStringProperty.java
diffstat 15 files changed, 58 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/DescriptorListenerCleaner.java	Tue Mar 04 14:11:49 2014 +0100
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javafx.beans.property.adapter;
+
+import com.sun.javafx.property.adapter.ReadOnlyPropertyDescriptor;
+
+class DescriptorListenerCleaner implements Runnable{
+
+    private final ReadOnlyPropertyDescriptor pd;
+    private final ReadOnlyPropertyDescriptor.ReadOnlyListener<?> l;
+
+    DescriptorListenerCleaner(ReadOnlyPropertyDescriptor pd, ReadOnlyPropertyDescriptor.ReadOnlyListener<?> l) {
+        this.pd = pd;
+        this.l = l;
+
+    }
+
+    @Override
+    public void run() {
+        pd.removeListener(l);
+    }
+}
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanBooleanProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanBooleanProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Boolean>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanBooleanProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanDoubleProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanDoubleProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanDoubleProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanFloatProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanFloatProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanFloatProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanIntegerProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanIntegerProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanIntegerProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanLongProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanLongProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanLongProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanObjectProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanObjectProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -79,9 +79,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<T>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanObjectProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanStringProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/JavaBeanStringProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -77,9 +77,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new Listener<String>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            JavaBeanStringProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanBooleanProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanBooleanProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Boolean>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanBooleanProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanDoubleProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanDoubleProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanDoubleProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanFloatProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanFloatProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanFloatProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanIntegerProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanIntegerProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanLongProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanLongProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<Number>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanLongProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanObjectProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanObjectProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -68,9 +68,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<T>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanObjectProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**
--- a/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanStringProperty.java	Tue Mar 04 14:55:10 2014 +0400
+++ b/modules/base/src/main/java/javafx/beans/property/adapter/ReadOnlyJavaBeanStringProperty.java	Tue Mar 04 14:11:49 2014 +0100
@@ -66,9 +66,7 @@
         this.descriptor = descriptor;
         this.listener = descriptor.new ReadOnlyListener<String>(bean, this);
         descriptor.addListener(listener);
-        Cleaner.create(this, () -> {
-            ReadOnlyJavaBeanStringProperty.this.descriptor.removeListener(listener);
-        });
+        Cleaner.create(this, new DescriptorListenerCleaner(descriptor, listener));
     }
 
     /**