Код: Выделить всё
@Slf4j
@Lazy(false)
@Configuration
@EnableConfigurationProperties(AwsProperties.class)
public class AwsConfig {
@Bean(destroyMethod = "close")
public S3Client awsS3Client(AwsProperties awsProperties) {
return S3Client.builder()
.region(Region.of(awsProperties.region()))
.build();
}
}
< /code>
[b] Проблема: < /strong>
Когда я вызываю лямбду несколько раз в последовательности, среда AWS, по -видимому, создает новый S3Client < /code> до того, как предыдущий будет собрана мусор. Это приводит к следующей ошибке: < /p>
No duplicate IdentityProperty names allowed but both IdentityProperties 7890fbf9 and 25f0f461 have the same namespace (java.lang.String) and name (Bucket). IdentityProperty should be referenced from a shared static constant to protect against erroneous or unexpected collisions.
Код: Выделить всё
private static final ConcurrentMap prev = NAME_HISTORY.putIfAbsent(Pair.of(namespace, name), this);
Validate.isTrue(prev == null,
"No duplicate IdentityProperty names allowed but both IdentityProperties %s and %s have the same "
+ "namespace (%s) and name (%s). IdentityProperty should be referenced from a shared static constant to "
+ "protect against erroneous or unexpected collisions.",
Integer.toHexString(System.identityHashCode(prev)),
Integer.toHexString(System.identityHashCode(this)),
namespace,
name);
}
Что я пробовал: [/b]
- Объявление s3client как статическая переменная класса
- @scope ("Прототип") для bean ("A" @scope ("Prototype") взломать) Удаление свойства из name_history карта через отражение (которая только что привела к аналогичной ошибке для другого свойства)
- Различные другие стратегии жизненного цикла и экологически чистых целей
Подробнее здесь: https://stackoverflow.com/questions/797 ... d-s3client