Remove CacheUtil and CacheTestUtil 00/82800/9
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 29 Jun 2019 11:11:12 +0000 (13:11 +0200)
committerHema Gopalakrishnan <hema.gopalkrishnan@ericsson.com>
Sun, 26 Jul 2020 11:20:27 +0000 (11:20 +0000)
CacheUtil has only a single user in netvirt, which is being removed
and CacheTestUtil has only a single internal user. Remove them both.

Change-Id: I6e7e4311f60f82ec87e13a248657bc89d1bb759d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
itm/itm-impl/src/test/java/org/opendaylight/genius/itm/tests/ItmTest.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/cache/CacheUtil.java [deleted file]
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/utils/cache/CacheTestUtil.java [deleted file]

index 7cab3e3e617ac2c0bf9f96d2343bdb69d876b96e..daa7dd51c27459b5dbcc7beb7f11b6ebf171d481 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorEventsWait
 import org.opendaylight.genius.datastoreutils.testutils.JobCoordinatorTestModule;
 import org.opendaylight.genius.datastoreutils.testutils.TestableDataTreeChangeListenerModule;
 import org.opendaylight.genius.itm.impl.ItmTestUtils;
-import org.opendaylight.genius.utils.cache.CacheTestUtil;
 import org.opendaylight.infrautils.caches.testutils.CacheModule;
 import org.opendaylight.infrautils.inject.guice.testutils.GuiceRule;
 import org.opendaylight.infrautils.testutils.LogCaptureRule;
@@ -48,11 +47,10 @@ public class ItmTest {
         clearCaches();
     }
 
-    private void clearCaches() {
+    private static void clearCaches() {
         // Explicitly clear stupid static caches
         // (TODO which really need to be de-static-ified instead of doing this..)
         ItmTestUtils.clearAllItmCaches();
-        CacheTestUtil.clearAllCaches();
     }
 
     @Test
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/cache/CacheUtil.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/utils/cache/CacheUtil.java
deleted file mode 100644 (file)
index f2bc895..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.genius.utils.cache;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Cache wannabe.
- *
- * <p>This class wanted to be Cache when it was grown up. Currently it's actually just
- * a nested ConcurrentMap, and thus has fairly limited real value.
- *
- * <p>The usage of static methods here, instead of an (OSGi) "service"
- * (dependency inject-able in tests!) makes it impossible to easily properly
- * use code relying on this in component tests (as there would be no automatic
- * reset between tests; you would have to manually {@link #destroyCache(String)}
- * {@literal @}Before each test).
- *
- * <p>This class' "static" Singleton doesn't play nice with OSGi e.g. for hot reload.
- *
- * <p>This class' (necessary) use &lt;?&gt; generics causes {@literal @}SuppressWarnings("unchecked") when used.
- *
- * <p>Perhaps you would like to use <a href="https://github.com/google/guava/wiki/CachesExplained">
- * Google Guava's simple Caches</a>, if not a full blown JSR 107 javax.cache (JCache) implementation,
- * such as <a href="http://infinispan.org">Infinispan</a> or <a href="http://www.ehcache.org">Ehcache</a>,
- * instead of this class?
- *
- * @deprecated We now recommend you simply use your own {@code new ConcurrentHashMap<>()} instead.
- *
- * @author unascribed (Ericsson India?) - original code
- * @author Michael Vorburger.ch - JavaDoc
- */
-@Deprecated
-public final class CacheUtil {
-
-    // package local instead of private for CacheTestUtil
-    static final ConcurrentMap<String, ConcurrentMap<?, ?>> MAP_OF_MAP = new ConcurrentHashMap<>();
-
-    private CacheUtil() {
-
-    }
-
-    public static ConcurrentMap<?, ?> getCache(String cacheName) {
-        return MAP_OF_MAP.get(cacheName);
-    }
-
-    public static void createCache(String cacheName) {
-        MAP_OF_MAP.computeIfAbsent(cacheName, k -> new ConcurrentHashMap<>());
-    }
-
-    public static boolean isCacheValid(String cacheName) {
-        return MAP_OF_MAP.containsKey(cacheName);
-    }
-
-    public static void destroyCache(String cacheName) {
-        MAP_OF_MAP.remove(cacheName);
-    }
-}
diff --git a/mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/utils/cache/CacheTestUtil.java b/mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/utils/cache/CacheTestUtil.java
deleted file mode 100644 (file)
index d22e178..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.genius.utils.cache;
-
-/**
- * Utility for use in tests which cover code that still ;-( use the deprecated CacheUtil.
- *
- * @author Michael Vorburger
- */
-public final class CacheTestUtil {
-
-    private CacheTestUtil() {
-    }
-
-    @SuppressWarnings("deprecation")
-    public static void clearAllCaches() {
-        CacheUtil.MAP_OF_MAP.clear();
-    }
-}