[java-support] 03/04: JSPT-88: Problematic finalize in BasicParserPool

Brent Putman putmanb at georgetown.edu
Wed Feb 19 17:18:26 EST 2020


This is an automated email from the git hooks/post-receive script.

putmanb pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=766f40f7e763167cdc6aa360b5f2c54835646485

commit 766f40f7e763167cdc6aa360b5f2c54835646485
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Feb 19 16:08:25 2020 -0500

    JSPT-88: Problematic finalize in BasicParserPool
---
 .../java/support/xml/BasicParserPool.java          |  6 ---
 .../java/support/xml/BasicParserPoolTest.java      | 48 ----------------------
 2 files changed, 54 deletions(-)

diff --git a/src/main/java/net/shibboleth/utilities/java/support/xml/BasicParserPool.java b/src/main/java/net/shibboleth/utilities/java/support/xml/BasicParserPool.java
index bdccbdc..e224b33 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/xml/BasicParserPool.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/xml/BasicParserPool.java
@@ -863,11 +863,5 @@ public class BasicParserPool extends AbstractInitializableComponent implements P
             }
         }
 
-        /** {@inheritDoc} */
-        @Override
-        protected void finalize() throws Throwable {
-            super.finalize();
-            owningPool.returnBuilder(this);
-        }
     }
 }
\ No newline at end of file
diff --git a/src/test/java/net/shibboleth/utilities/java/support/xml/BasicParserPoolTest.java b/src/test/java/net/shibboleth/utilities/java/support/xml/BasicParserPoolTest.java
index bb18e49..3510e11 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/xml/BasicParserPoolTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/xml/BasicParserPoolTest.java
@@ -578,54 +578,6 @@ public class BasicParserPoolTest {
             basicParserPool.returnBuilder(builders[i]);
         }
     }
-    /**
-     * Test issue reported in JXT-46 - a parser should not be checked into the pool multiple times
-     * via the auto-checkin mechanism by the proxy finalize().
-     * 
-     * @throws XMLParserException if something bad happens
-     * @throws ComponentInitializationException if something bad happens
-     */
-    @Test
-    public void testFinalize() throws XMLParserException, ComponentInitializationException {
-        BasicParserPool pool = new BasicParserPool();
-        pool.initialize();
-        Assert.assertEquals(0, pool.getPoolSize());
-        
-        // Check out and return a builder
-        DocumentBuilder builder = pool.getBuilder();
-        pool.returnBuilder(builder);
-        
-        Assert.assertEquals(1, pool.getPoolSize());
-        
-        // Get rid of any references to the first builder we got, so that it will be GCed
-        //builder = null;
-        // Do explicit GC and sleep a little make sure proxy finalize() gets called
-        //System.out.println("Garbage collection and sleep");
-        //System.gc();
-        //Thread.sleep(3000);
-        //System.out.println("Done sleeping");
-        
-        // Rather than relying on forcing GC behavior in the test as above, which was in initial debugging this problem,
-        // explicitly invoke finalize() to simulate.
-        // (which we can do b/c it's protected access *and* we're in the same package)
-        try {
-            ((DocumentBuilderProxy)builder).finalize();
-        } catch (Throwable e) {
-            e.printStackTrace();
-        }
-        
-        Assert.assertEquals(1, pool.getPoolSize());
-        
-        
-        // Both of these would have been the same instance pre-bug fix.
-        DocumentBuilder builder1 = ((DocumentBuilderProxy) pool.getBuilder()).getProxiedBuilder();
-        Assert.assertNotNull(builder1);
-        DocumentBuilder builder2 = ((DocumentBuilderProxy) pool.getBuilder()).getProxiedBuilder();
-        Assert.assertNotNull(builder2);
-        Assert.assertFalse(builder1.equals(builder2));
-        
-    }
-    
     
     /**
      * Test for caller (illegally) returning a builder multiple times to pool.

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list