dev@jaxb.java.net

Re: [PATCH] removing the finalize method from UnmarshallerImpl as it is not effective

From: Gareth Davis <gadavis_at_expedia.com>
Date: Mon, 16 Sep 2013 13:27:48 +0100

Couldn't actually see any where to attach the patch on the issue (https://java.net/jira/browse/JAXB-978)

Gareth Davis

From: Gareth Davis <gadavis_at_expedia.com<mailto:gadavis_at_expedia.com>>
Reply-To: "dev_at_jaxb.java.net<mailto:dev_at_jaxb.java.net>" <dev_at_jaxb.java.net<mailto:dev_at_jaxb.java.net>>
Date: Monday, 16 September 2013 13:25
To: "dev_at_jaxb.java.net<mailto:dev_at_jaxb.java.net>" <dev_at_jaxb.java.net<mailto:dev_at_jaxb.java.net>>
Subject: [PATCH] removing the finalize method from UnmarshallerImpl as it is not effective


The previous implementation called ClassFactory.clearCache() which in turn clears
the thread local cache. The flaw in this is that the finalize method is actually called
in the finalizer thread, thus attempting to clear thread local state in a finalize
method is pointless.

There is evidence that this under heavy use can effect the parallelism of the
garbage collector.

(http://mail.openjdk.java.net/pipermail/hotspot-gc-use/2013-September/001593.html)
---
 .../sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl.java | 10 ----------
 1 file changed, 10 deletions(-)
diff --git a/jaxb-ri/runtime/impl/src/main/java/com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl.java b/jaxb-ri/runtime/impl/src/main/java/com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl.java
index d8e6f5c..b71d1e0 100644
--- a/jaxb-ri/runtime/impl/src/main/java/com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl.java
+++ b/jaxb-ri/runtime/impl/src/main/java/com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl.java
@@ -613,16 +613,6 @@ import org.xml.sax.helpers.DefaultHandler;
         return coordinator;
     }
-    @Override
-    @SuppressWarnings("FinalizeDeclaration")
-    protected void finalize() throws Throwable {
-        try {
-            ClassFactory.cleanCache();
-        } finally {
-            super.finalize();
-        }
-    }
-
     /**
      *  Must be called from same thread which created the UnmarshallerImpl instance.
      * @throws IOException
--
1.8.4