17
17
package io .appium .java_client .proxy ;
18
18
19
19
import com .google .common .base .Preconditions ;
20
+ import java .util .Map ;
21
+ import java .util .WeakHashMap ;
20
22
import lombok .Value ;
21
23
import net .bytebuddy .ByteBuddy ;
22
24
import net .bytebuddy .description .method .MethodDescription ;
32
34
import java .util .Collection ;
33
35
import java .util .Collections ;
34
36
import java .util .Set ;
35
- import java .util .concurrent .ConcurrentHashMap ;
36
- import java .util .concurrent .ConcurrentMap ;
37
37
import java .util .stream .Collectors ;
38
38
import java .util .stream .Stream ;
39
39
40
40
import static java .util .Objects .requireNonNull ;
41
41
import static net .bytebuddy .matcher .ElementMatchers .namedOneOf ;
42
42
43
+ /**
44
+ * The type Helpers.
45
+ */
43
46
public class Helpers {
44
47
public static final Set <String > OBJECT_METHOD_NAMES = Stream .of (Object .class .getMethods ())
45
48
.map (Method ::getName )
@@ -52,6 +55,16 @@ public class Helpers {
52
55
// of proxy instances.
53
56
private static final Map <ProxyClassSignature , Class <?>> CACHED_PROXY_CLASSES = Collections .synchronizedMap (new WeakHashMap <>());
54
57
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
+
55
68
private Helpers () {
56
69
}
57
70
@@ -115,6 +128,7 @@ public static <T> T createProxy(
115
128
@ Nullable ElementMatcher <MethodDescription > extraMethodMatcher
116
129
) {
117
130
var signature = ProxyClassSignature .of (cls , constructorArgTypes , extraMethodMatcher );
131
+ System .out .println ("CACHED_PROXY_CLASSES size = " + CACHED_PROXY_CLASSES .size ());
118
132
var proxyClass = CACHED_PROXY_CLASSES .computeIfAbsent (signature , k -> {
119
133
Preconditions .checkArgument (constructorArgs .length == constructorArgTypes .length ,
120
134
String .format (
0 commit comments