diff --git a/java/fury-core/src/main/java/org/apache/fury/pool/ClassLoaderFuryPooled.java b/java/fury-core/src/main/java/org/apache/fury/pool/ClassLoaderFuryPooled.java index c1ad2adaf9..ececce993f 100644 --- a/java/fury-core/src/main/java/org/apache/fury/pool/ClassLoaderFuryPooled.java +++ b/java/fury-core/src/main/java/org/apache/fury/pool/ClassLoaderFuryPooled.java @@ -123,6 +123,7 @@ private void addFury() { } void setFactoryCallback(Consumer factoryCallback) { - this.factoryCallback = factoryCallback; + this.factoryCallback = this.factoryCallback.andThen(factoryCallback); + allFury.keySet().forEach(factoryCallback); } } diff --git a/java/fury-core/src/test/java/org/apache/fury/pool/ClassLoaderFuryPooledTest.java b/java/fury-core/src/test/java/org/apache/fury/pool/ClassLoaderFuryPooledTest.java index 9e148e78e2..c039342fc3 100644 --- a/java/fury-core/src/test/java/org/apache/fury/pool/ClassLoaderFuryPooledTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/pool/ClassLoaderFuryPooledTest.java @@ -83,6 +83,23 @@ public void testGetFuryWithIncreaseCapacity() { } } + @Test + public void testFuryAfterSetFactoryCallback() { + int minPoolSize = 4; + ClassLoaderFuryPooled pooled = getPooled(minPoolSize, 6); + + try { + pooled.setFactoryCallback( + fury -> { + throw new RuntimeException(); + }); + pooled.getFury(); + Assert.fail(); + } catch (RuntimeException e) { + // Success + } + } + @Test public void testGetFuryAwait() throws InterruptedException { int minPoolSize = 3;