Add AnnotationClassOrMethodPointcut.hashCode() impl

Due to the absence of a `hashCode()` implementation, proxies for the `AnnotationClassOrMethodPointcut` class are regenerated each time, 
which causes them to be stored in the `org.springframework.cglib.core.internal.LoadingCache` (with `RetryConfiguration.AnnotationClassOrMethodPointcut` being part of the composite key for this object).
This results in an excessive accumulation of generated proxies in memory, ultimately leading to metaspace overflow.
This commit is contained in:
Evgeny Lazarev
2024-09-23 21:15:16 +03:00
committed by GitHub
parent 4886b75d0b
commit 76b41e8dac

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -68,6 +69,7 @@ import org.springframework.util.ReflectionUtils;
* @author Markus Heiden
* @author Gary Russell
* @author Yanming Zhou
* @author Evgeny Lazarev
* @since 1.1
*
*/
@@ -242,6 +244,11 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
return ObjectUtils.nullSafeEquals(this.methodResolver, otherAdvisor.methodResolver);
}
@Override
public int hashCode() {
return Objects.hash(this.methodResolver);
}
}
private final class AnnotationClassOrMethodFilter extends AnnotationClassFilter {