1717package io .appium .java_client .proxy ;
1818
1919import com .google .common .base .Preconditions ;
20+ import java .util .Map ;
21+ import java .util .WeakHashMap ;
2022import lombok .Value ;
2123import net .bytebuddy .ByteBuddy ;
2224import net .bytebuddy .description .method .MethodDescription ;
3234import java .util .Collection ;
3335import java .util .Collections ;
3436import java .util .Set ;
35- import java .util .concurrent .ConcurrentHashMap ;
36- import java .util .concurrent .ConcurrentMap ;
3737import java .util .stream .Collectors ;
3838import java .util .stream .Stream ;
3939
4040import static java .util .Objects .requireNonNull ;
4141import static net .bytebuddy .matcher .ElementMatchers .namedOneOf ;
4242
43+ /**
44+ * The type Helpers.
45+ */
4346public class Helpers {
4447 public static final Set <String > OBJECT_METHOD_NAMES = Stream .of (Object .class .getMethods ())
4548 .map (Method ::getName )
@@ -52,6 +55,16 @@ public class Helpers {
5255 // of proxy instances.
5356 private static final Map <ProxyClassSignature , Class <?>> CACHED_PROXY_CLASSES = Collections .synchronizedMap (new WeakHashMap <>());
5457
58+ /**
59+ * Gets CACHED_PROXY_CLASSES size.
60+ * Used for cache clear up tests.
61+ *
62+ * @return the cached proxy classes size
63+ */
64+ public static int getCachedProxyClassesSize () {
65+ return CACHED_PROXY_CLASSES .size ();
66+ }
67+
5568 private Helpers () {
5669 }
5770
@@ -115,6 +128,7 @@ public static <T> T createProxy(
115128 @ Nullable ElementMatcher <MethodDescription > extraMethodMatcher
116129 ) {
117130 var signature = ProxyClassSignature .of (cls , constructorArgTypes , extraMethodMatcher );
131+ System .out .println ("CACHED_PROXY_CLASSES size = " + CACHED_PROXY_CLASSES .size ());
118132 var proxyClass = CACHED_PROXY_CLASSES .computeIfAbsent (signature , k -> {
119133 Preconditions .checkArgument (constructorArgs .length == constructorArgTypes .length ,
120134 String .format (
0 commit comments