diff --git a/prj/test/functional/executor/src/main/java/executor/AbstractCESSingleClusterTests.java b/prj/test/functional/executor/src/main/java/executor/AbstractCESSingleClusterTests.java index adb8f497721b8..c4d13fd90855d 100644 --- a/prj/test/functional/executor/src/main/java/executor/AbstractCESSingleClusterTests.java +++ b/prj/test/functional/executor/src/main/java/executor/AbstractCESSingleClusterTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. + * Copyright (c) 2000, 2023, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -8,6 +8,7 @@ import com.oracle.coherence.concurrent.executor.util.Caches; +import com.tangosol.net.CacheService; import executor.common.SingleClusterForAllTests; import executor.common.Utils; @@ -28,13 +29,17 @@ public abstract class AbstractCESSingleClusterTests { // ----- test lifecycle ------------------------------------------------- + @SuppressWarnings("resource") @Override public void cleanup() { + CacheService service = getCacheService(); + if (service != null) + { + Caches.tasks(service).clear(); + Caches.assignments(service).clear(); + } super.cleanup(); - - Caches.tasks(getCacheService()).clear(); - Caches.assignments(getCacheService()).clear(); } // ----- constructors --------------------------------------------------- diff --git a/prj/test/functional/executor/src/main/java/executor/AbstractClusteredExecutorServiceTests.java b/prj/test/functional/executor/src/main/java/executor/AbstractClusteredExecutorServiceTests.java index 8ea9a5d0d2c1a..85ef275764efc 100644 --- a/prj/test/functional/executor/src/main/java/executor/AbstractClusteredExecutorServiceTests.java +++ b/prj/test/functional/executor/src/main/java/executor/AbstractClusteredExecutorServiceTests.java @@ -63,6 +63,7 @@ import com.tangosol.io.Serializer; +import com.tangosol.net.CacheFactory; import com.tangosol.net.CacheService; import com.tangosol.net.ConfigurableCacheFactory; import com.tangosol.net.NamedCache; @@ -123,7 +124,7 @@ * @author lh * @since 21.12 */ -@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings({"rawtypes", "unchecked", "resource"}) public abstract class AbstractClusteredExecutorServiceTests extends AbstractTaskExecutorServiceTests { @@ -182,6 +183,11 @@ public void setup() public void cleanup() { String sMsg = ">>>>> Finished test: " + f_watcher.getMethodName(); + if (m_cacheFactory != null && m_cacheFactory.isActive()) + { + m_cacheFactory.dispose(); + m_cacheFactory = null; + } for (CoherenceClusterMember member : getCoherence().getCluster()) { if (member != null) @@ -201,6 +207,7 @@ public void cleanup() Eventually.assertDeferred(() -> m_taskExecutorService.isShutdown(), is(true)); } + CacheFactory.shutdown(); } // ----- contract ------------------------------------------------------- @@ -238,10 +245,12 @@ protected void initCluster() clusterResource.getCluster(); // connect as an *Extend client + System.setProperty("coherence.client", "remote-fixed"); m_cacheFactory = clusterResource.createSession(( SessionBuilders.extendClient(m_extendConfig, SystemProperty.of(EXECUTOR_LOGGING_PROPERTY, "true"), SystemProperty.of("coherence.client", "remote-fixed")))); + m_cacheFactory.activate(); } // ----- test methods --------------------------------------------------- @@ -1443,7 +1452,8 @@ public static void ensureExecutorProxyAvailable(CoherenceCluster cluster) public CacheService getCacheService() { - return m_taskExecutorService.getCacheService(); + return m_taskExecutorService == null + ? null : m_taskExecutorService.getCacheService(); } /**