You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2025/11/01 16:57:23 UTC
(cxf) branch 4.0.x-fixes updated (7361721dbe7 -> ecf51859f9e)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a change to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
from 7361721dbe7 Recording .gitmergeinfo Changes
new a44cb4264cd Bump com.fasterxml.jackson.core:jackson-databind from 2.20.0 to 2.20.1 (#2696)
new af99685bb58 Update JUnit Jupiter to 5.14.1
new 38adf23f92a CXF-9171: DelayedCachedOutputStreamCleaner thread accumulation after CVE-2025-23184 fix (#2684)
new ecf51859f9e Recording .gitmergeinfo Changes
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitmergeinfo | 2 +
.../java/org/apache/cxf/io/CachedConstants.java | 9 ++
.../cxf/io/DelayedCachedOutputStreamCleaner.java | 164 +++++++++++++++++++--
.../io/DelayedCachedOutputStreamCleanerTest.java | 58 ++++++--
parent/pom.xml | 6 +-
5 files changed, 211 insertions(+), 28 deletions(-)
(cxf) 01/04: Bump com.fasterxml.jackson.core:jackson-databind from 2.20.0 to 2.20.1 (#2696)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a44cb4264cde5ac0db2a9212f8dba3ccaef46899
Author: dependabot[bot] <49...@users.noreply.github.com>
AuthorDate: Fri Oct 31 12:53:39 2025 -0400
Bump com.fasterxml.jackson.core:jackson-databind from 2.20.0 to 2.20.1 (#2696)
* Bump com.fasterxml.jackson.core:jackson-databind from 2.20.0 to 2.20.1
Bumps [com.fasterxml.jackson.core:jackson-databind](https://github.com/FasterXML/jackson) from 2.20.0 to 2.20.1.
- [Commits](https://github.com/FasterXML/jackson/commits)
---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
dependency-version: 2.20.1
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <su...@github.com>
* Update parent/pom.xml
---------
Signed-off-by: dependabot[bot] <su...@github.com>
Co-authored-by: dependabot[bot] <49...@users.noreply.github.com>
Co-authored-by: Andriy Redko <dr...@gmail.com>
(cherry picked from commit cda672af823aad3b9121f1a311907d1a874abcdc)
# Conflicts:
# parent/pom.xml
---
parent/pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index f986ecb240b..9b2dcfe5414 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -131,8 +131,8 @@
<cxf.httpcomponents.core.version>4.4.16</cxf.httpcomponents.core.version>
<cxf.httpcomponents.client5.version>5.3.1</cxf.httpcomponents.client5.version>
<cxf.httpcomponents.core5.version>5.2.5</cxf.httpcomponents.core5.version>
- <cxf.jackson.version>2.20.0</cxf.jackson.version>
- <cxf.jackson.databind.version>2.20.0</cxf.jackson.databind.version>
+ <cxf.jackson.version>2.20.1</cxf.jackson.version>
+ <cxf.jackson.databind.version>2.20.1</cxf.jackson.databind.version>
<cxf.jackson.annotations.version>2.20</cxf.jackson.annotations.version>
<cxf.jacorb.version>3.9</cxf.jacorb.version>
<cxf.jaeger.version>1.8.1</cxf.jaeger.version>
(cxf) 04/04: Recording .gitmergeinfo Changes
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit ecf51859f9e594870b1939eda675f1a4a81a68ac
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Nov 1 12:49:23 2025 -0400
Recording .gitmergeinfo Changes
---
.gitmergeinfo | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitmergeinfo b/.gitmergeinfo
index 54d103228da..9e1f61ffb29 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -540,6 +540,7 @@ M baec16565652e02e471889c3a13ba619af1057b7
M baecda4dbe0d4acfb65c8b5fe8e3ae970a608ba4
M bafe38b4e5fa7e8cdd162891d2fa56b60bd60c9a
M bb1ea6bac4f980144becebcd79533ca736b44342
+M bb53cc7fdc7e87a028da2f2988f3f468fa434b06
M bba0417ee2a454c291d7573e06216ca40e35ca97
M bbf373beac4393c1bc4dee5a3378f95d9dd6144a
M bca6dd3c53ad6666f0361c8a27bac2a874f9f5de
@@ -589,6 +590,7 @@ M cc210dfd2b87bf45bcf5a28fe9519b417b045031
M cc2c51c31d9db6715919e7a1a8cc57f7e57cbf5f
M cc425ef8ff016611e877fd3b3b3a16ee78547084
M cd53e4953d90fed16cd99d131b905cefcd748935
+M cda672af823aad3b9121f1a311907d1a874abcdc
M cdaac75da63f45e336b4e144a34c7c8bca9ba03d
M ce13e155bcdf28611177a35f4d29e4967cc07828
M ce193aa401ba11213f8048cebc20b1bdfa7aa530
(cxf) 02/04: Update JUnit Jupiter to 5.14.1
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit af99685bb5880fa43869df1c54930ee5a423a5f3
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Nov 1 11:20:45 2025 -0400
Update JUnit Jupiter to 5.14.1
(cherry picked from commit bb53cc7fdc7e87a028da2f2988f3f468fa434b06)
---
parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/parent/pom.xml b/parent/pom.xml
index 9b2dcfe5414..6cd85370207 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -170,7 +170,7 @@
<cxf.json.bind-api.version>2.0.0</cxf.json.bind-api.version>
<cxf.jsr250.api.version>1.0</cxf.jsr250.api.version>
<cxf.junit.version>4.13.2</cxf.junit.version>
- <cxf.junit5.version>5.14.0</cxf.junit5.version>
+ <cxf.junit5.version>5.14.1</cxf.junit5.version>
<cxf.kerby.version>2.0.3</cxf.kerby.version>
<cxf.ldapsdk.version>7.0.3</cxf.ldapsdk.version>
<cxf.littleproxy.version>2.4.6</cxf.littleproxy.version>
(cxf) 03/04: CXF-9171: DelayedCachedOutputStreamCleaner thread accumulation after CVE-2025-23184 fix (#2684)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 38adf23f92af3e6115e431aef694377dcec5efd1
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Nov 1 12:36:38 2025 -0400
CXF-9171: DelayedCachedOutputStreamCleaner thread accumulation after CVE-2025-23184 fix (#2684)
* CXF-9171: DelayedCachedOutputStreamCleaner thread accumulation after CVE-2025-23184 fix
* Address code review comments
(cherry picked from commit 1ce9fe1cbf779629e77f7b5f4f62bdb8d4322bcb)
---
.../java/org/apache/cxf/io/CachedConstants.java | 9 ++
.../cxf/io/DelayedCachedOutputStreamCleaner.java | 164 +++++++++++++++++++--
.../io/DelayedCachedOutputStreamCleanerTest.java | 58 ++++++--
3 files changed, 206 insertions(+), 25 deletions(-)
diff --git a/core/src/main/java/org/apache/cxf/io/CachedConstants.java b/core/src/main/java/org/apache/cxf/io/CachedConstants.java
index 7b45d0861b8..1f5ddb9ba01 100644
--- a/core/src/main/java/org/apache/cxf/io/CachedConstants.java
+++ b/core/src/main/java/org/apache/cxf/io/CachedConstants.java
@@ -87,6 +87,15 @@ public final class CachedConstants {
public static final String CLEANER_CLEAN_ON_SHUTDOWN_BUS_PROP =
"bus.io.CachedOutputStreamCleaner.CleanOnShutdown";
+ /**
+ * The strategy to be used for cleaning up unclosed {@code CachedOutputStream} instances. By default,
+ * there cleaner implementation creates a timer per each {@link Bus} instance. However, in certain
+ * deployments it could lead to excessive number of timers being created, so there is an alternative
+ * strategy that uses single timer instance. The supported strategies are: default, single-timer.
+ */
+ public static final String CLEANER_STRATEGY_BUS_PROP =
+ "bus.io.CachedOutputStreamCleaner.Strategy";
+
private CachedConstants() {
// complete
}
diff --git a/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java b/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java
index 77721d115ff..f1e79649236 100644
--- a/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java
+++ b/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java
@@ -30,6 +30,8 @@ import java.util.TimerTask;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Function;
import java.util.logging.Logger;
import jakarta.annotation.Resource;
@@ -41,6 +43,8 @@ import org.apache.cxf.common.logging.LogUtils;
public final class DelayedCachedOutputStreamCleaner implements CachedOutputStreamCleaner, BusLifeCycleListener {
private static final Logger LOG = LogUtils.getL7dLogger(DelayedCachedOutputStreamCleaner.class);
private static final long MIN_DELAY = 2000; /* 2 seconds */
+ private static final String DEFAULT_STRATEGY = "default";
+ private static final String SINGLE_TIMER_STRATEGY = "single-timer";
private static final DelayedCleaner NOOP_CLEANER = new DelayedCleaner() {
// NOOP
};
@@ -74,25 +78,145 @@ public final class DelayedCachedOutputStreamCleaner implements CachedOutputStrea
}
}
- private static final class DelayedCleanerImpl implements DelayedCleaner {
+ private static final class SingleTimerDelayedCleaner implements DelayedCleaner {
+ private static final Timer TIMER = new Timer("DelayedCachedOutputStreamCleaner", true);
+
private final long delay; /* default is 30 minutes, in milliseconds */
private final DelayQueue<DelayedCloseable> queue = new DelayQueue<>();
- private final Timer timer;
-
- DelayedCleanerImpl(final long delay) {
+ private final Object lock = new Object();
+ private TimerTask timerTask;
+
+ SingleTimerDelayedCleaner(final long delay) {
this.delay = delay;
- this.timer = new Timer("DelayedCachedOutputStreamCleaner", true);
- this.timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- clean();
+ }
+
+ @Override
+ public void register(final Closeable closeable) {
+ TimerTask newTimerTask = null;
+
+ synchronized (lock) {
+ queue.put(new DelayedCloseable(closeable, delay));
+ if (timerTask == null) {
+ timerTask = new TimerTask() {
+ @Override
+ public void run() {
+ clean();
+ }
+ };
+ newTimerTask = timerTask;
+ }
+ }
+
+ if (newTimerTask != null) {
+ TIMER.scheduleAtFixedRate(newTimerTask, 0, Math.max(MIN_DELAY, delay >> 1));
+ }
+ }
+
+ @Override
+ public void unregister(final Closeable closeable) {
+ TimerTask oldTimerTask = null;
+ synchronized (lock) {
+ queue.remove(new DelayedCloseable(closeable, delay));
+ if (queue.isEmpty() && timerTask != null) {
+ oldTimerTask = timerTask;
+ timerTask = null;
+ }
+ }
+ if (oldTimerTask != null) {
+ oldTimerTask.cancel();
+ }
+ }
+
+ @Override
+ public void clean() {
+ final Collection<DelayedCloseable> closeables = new ArrayList<>();
+ TimerTask oldTimerTask = null;
+ synchronized (lock) {
+ queue.drainTo(closeables);
+ if (queue.isEmpty() && timerTask != null) {
+ oldTimerTask = timerTask;
+ timerTask = null;
+ }
+ }
+ if (oldTimerTask != null) {
+ oldTimerTask.cancel();
+ }
+ clean(closeables);
+ }
+
+ @Override
+ public void forceClean() {
+ TimerTask oldTimerTask = null;
+ synchronized (lock) {
+ clean(queue);
+ if (timerTask != null) {
+ oldTimerTask = timerTask;
+ timerTask = null;
+ }
+ }
+ if (oldTimerTask != null) {
+ oldTimerTask.cancel();
+ }
+ }
+
+ @Override
+ public void close() {
+ TimerTask oldTimerTask = null;
+ synchronized (lock) {
+ queue.clear();
+ if (timerTask != null) {
+ oldTimerTask = timerTask;
+ timerTask = null;
+ }
+ }
+ if (oldTimerTask != null) {
+ oldTimerTask.cancel();
+ }
+ }
+
+ @Override
+ public int size() {
+ return queue.size();
+ }
+
+ private void clean(Collection<DelayedCloseable> closeables) {
+ final Iterator<DelayedCloseable> iterator = closeables.iterator();
+ while (iterator.hasNext()) {
+ final DelayedCloseable next = iterator.next();
+ try {
+ iterator.remove();
+ LOG.warning("Unclosed (leaked?) stream detected: " + next.closeable.hashCode());
+ next.closeable.close();
+ } catch (final IOException | RuntimeException ex) {
+ LOG.warning("Unable to close (leaked?) stream: " + ex.getMessage());
}
- }, 0, Math.max(MIN_DELAY, delay >> 1));
+ }
+ }
+ }
+
+ private static final class DefaultDelayedCleaner implements DelayedCleaner {
+ private final long delay; /* default is 30 minutes, in milliseconds */
+ private final DelayQueue<DelayedCloseable> queue = new DelayQueue<>();
+ private final AtomicBoolean initialized = new AtomicBoolean(false);
+ private volatile Timer timer;
+
+ DefaultDelayedCleaner(final long delay) {
+ this.delay = delay;
}
@Override
public void register(Closeable closeable) {
queue.put(new DelayedCloseable(closeable, delay));
+ // Initialize timer lazily only when at least one closeable is registered
+ if (initialized.compareAndSet(false, true)) {
+ this.timer = new Timer("DelayedCachedOutputStreamCleaner", true);
+ this.timer.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ clean();
+ }
+ }, 0, Math.max(MIN_DELAY, delay >> 1));
+ }
}
@Override
@@ -114,7 +238,10 @@ public final class DelayedCachedOutputStreamCleaner implements CachedOutputStrea
@Override
public void close() {
- timer.cancel();
+ final Timer t = timer;
+ if (t != null) {
+ t.cancel();
+ }
queue.clear();
}
@@ -186,11 +313,22 @@ public final class DelayedCachedOutputStreamCleaner implements CachedOutputStrea
Number delayValue = null;
BusLifeCycleManager busLifeCycleManager = null;
Boolean cleanupOnShutdownValue = null;
+ Function<Long, DelayedCleaner> delayedCleanerStrategy = DefaultDelayedCleaner::new;
if (bus != null) {
delayValue = (Number) bus.getProperty(CachedConstants.CLEANER_DELAY_BUS_PROP);
cleanupOnShutdownValue = (Boolean) bus.getProperty(CachedConstants.CLEANER_CLEAN_ON_SHUTDOWN_BUS_PROP);
busLifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
+ final String strategy = (String) bus.getProperty(CachedConstants.CLEANER_STRATEGY_BUS_PROP);
+ if (strategy == null || DEFAULT_STRATEGY.equalsIgnoreCase(strategy)) {
+ delayedCleanerStrategy = DefaultDelayedCleaner::new;
+ } else if (SINGLE_TIMER_STRATEGY.equalsIgnoreCase(strategy)) {
+ delayedCleanerStrategy = SingleTimerDelayedCleaner::new;
+ } else {
+ throw new IllegalArgumentException("The value of " + CachedConstants.CLEANER_STRATEGY_BUS_PROP
+ + " property is invalid: " + strategy + " (should be " + DEFAULT_STRATEGY + " or "
+ + SINGLE_TIMER_STRATEGY);
+ }
}
if (cleaner != null) {
@@ -205,11 +343,11 @@ public final class DelayedCachedOutputStreamCleaner implements CachedOutputStrea
if (delayValue == null) {
// Default delay is set to 30 mins
- cleaner = new DelayedCleanerImpl(TimeUnit.MILLISECONDS.convert(30, TimeUnit.MINUTES));
+ cleaner = delayedCleanerStrategy.apply(TimeUnit.MILLISECONDS.convert(30, TimeUnit.MINUTES));
} else {
final long value = delayValue.longValue();
if (value > 0 && value >= MIN_DELAY) {
- cleaner = new DelayedCleanerImpl(value); /* already in milliseconds */
+ cleaner = delayedCleanerStrategy.apply(value); /* already in milliseconds */
} else {
cleaner = NOOP_CLEANER;
if (value != 0) {
diff --git a/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java b/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
index 562b3a18f25..6e408d66096 100644
--- a/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
+++ b/core/src/test/java/org/apache/cxf/io/DelayedCachedOutputStreamCleanerTest.java
@@ -33,6 +33,8 @@ import org.apache.cxf.bus.extension.ExtensionManagerBus;
import org.junit.After;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -40,9 +42,20 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+@RunWith(Parameterized.class)
public class DelayedCachedOutputStreamCleanerTest {
+ private final String strategy;
private Bus bus;
+ public DelayedCachedOutputStreamCleanerTest(final String strategy) {
+ this.strategy = strategy;
+ }
+
+ @Parameterized.Parameters(name = CachedConstants.CLEANER_STRATEGY_BUS_PROP + "= {0}")
+ public static String[] strategies() throws Exception {
+ return new String[] {"default", "single-timer", null};
+ }
+
@After
public void tearDown() {
if (bus != null) {
@@ -50,21 +63,30 @@ public class DelayedCachedOutputStreamCleanerTest {
bus = null;
}
}
-
+
@Test
public void testNoop() {
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 0);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class)); /* noop */
assertNoopCleaner(cleaner);
}
-
+
+ @Test
+ public void testNoTimer() {
+ final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500);
+ bus = createBus(properties);
+
+ final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
+ assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class));
+ }
+
@Test
public void testForceClean() throws InterruptedException {
- bus = new ExtensionManagerBus();
+ bus = createBus();
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class));
@@ -88,7 +110,7 @@ public class DelayedCachedOutputStreamCleanerTest {
/* Delay of 2.5 seconds */
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
cleaner.register(closeable1);
@@ -101,7 +123,7 @@ public class DelayedCachedOutputStreamCleanerTest {
@Test
public void testForceCleanForEmpty() throws InterruptedException {
- bus = new ExtensionManagerBus();
+ bus = createBus();
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class));
@@ -121,7 +143,7 @@ public class DelayedCachedOutputStreamCleanerTest {
@Test
public void testForceCleanException() throws InterruptedException {
- bus = new ExtensionManagerBus();
+ bus = createBus();
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class));
@@ -149,7 +171,7 @@ public class DelayedCachedOutputStreamCleanerTest {
public void testCleanOnShutdown() throws InterruptedException {
/* Delay of 5 seconds */
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 5000);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final AtomicBoolean latch = new AtomicBoolean();
final Closeable closeable = () -> latch.compareAndSet(false, true);
@@ -170,7 +192,7 @@ public class DelayedCachedOutputStreamCleanerTest {
final Map<String, Object> properties = new HashMap<>();
properties.put(CachedConstants.CLEANER_DELAY_BUS_PROP, 3000); /* 3 seconds */
properties.put(CachedConstants.CLEANER_CLEAN_ON_SHUTDOWN_BUS_PROP, false);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final AtomicBoolean latch = new AtomicBoolean();
final Closeable closeable = () -> latch.compareAndSet(false, true);
@@ -188,7 +210,7 @@ public class DelayedCachedOutputStreamCleanerTest {
@Test
public void testNegativeDelay() throws InterruptedException {
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, -1);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class)); /* noop */
@@ -199,7 +221,7 @@ public class DelayedCachedOutputStreamCleanerTest {
@Test
public void testTooSmallDelay() throws InterruptedException {
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 1500);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class)); /* noop */
@@ -215,7 +237,7 @@ public class DelayedCachedOutputStreamCleanerTest {
/* Delay of 5 seconds */
final Map<String, Object> properties = Collections.singletonMap(CachedConstants.CLEANER_DELAY_BUS_PROP, 2500);
- bus = new ExtensionManagerBus(new HashMap<>(), properties);
+ bus = createBus(properties);
final CachedOutputStreamCleaner cleaner = bus.getExtension(CachedOutputStreamCleaner.class);
cleaner.register(closeable1);
@@ -232,6 +254,18 @@ public class DelayedCachedOutputStreamCleanerTest {
assertThat(cleaner, instanceOf(DelayedCachedOutputStreamCleaner.class));
}
+ private Bus createBus() {
+ return createBus(Collections.emptyMap());
+ }
+
+ private Bus createBus(Map<String, Object> properties) {
+ final Map<String, Object> combined = new HashMap<>(properties);
+ if (strategy != null) {
+ combined.put(CachedConstants.CLEANER_STRATEGY_BUS_PROP, strategy);
+ }
+ return new ExtensionManagerBus(new HashMap<>(), combined);
+ }
+
private void assertNoopCleaner(final CachedOutputStreamCleaner cleaner) {
final AtomicBoolean latch = new AtomicBoolean(false);
final Closeable closeable = () -> latch.compareAndSet(false, true);