Skip to content

Commit dd7e767

Browse files
authored
Update CACHED_PROXY_CLASSES
1 parent ebc60c7 commit dd7e767

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/io/appium/java_client/proxy/Helpers.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package io.appium.java_client.proxy;
1818

1919
import com.google.common.base.Preconditions;
20+
import java.util.Map;
21+
import java.util.WeakHashMap;
2022
import lombok.Value;
2123
import net.bytebuddy.ByteBuddy;
2224
import net.bytebuddy.description.method.MethodDescription;
@@ -32,14 +34,15 @@
3234
import java.util.Collection;
3335
import java.util.Collections;
3436
import java.util.Set;
35-
import java.util.concurrent.ConcurrentHashMap;
36-
import java.util.concurrent.ConcurrentMap;
3737
import java.util.stream.Collectors;
3838
import java.util.stream.Stream;
3939

4040
import static java.util.Objects.requireNonNull;
4141
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
4242

43+
/**
44+
* The type Helpers.
45+
*/
4346
public 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

Comments
 (0)