From 76b41e8dac252128749ac8d7ac914f1b847fee9d Mon Sep 17 00:00:00 2001 From: Evgeny Lazarev Date: Mon, 23 Sep 2024 21:15:16 +0300 Subject: [PATCH] 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. --- .../retry/annotation/RetryConfiguration.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java b/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java index d277436..5bf0f0a 100644 --- a/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java +++ b/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java @@ -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 {