Skip to content

Commit

Permalink
fix 并行调用多例Bean时 annotationWrapper 导致的线程安全问题
Browse files Browse the repository at this point in the history
  • Loading branch information
寻芳 committed Dec 24, 2024
1 parent 2d7d345 commit 2b80268
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ private void processSofaReference(final Object bean, String beanName) {
}

if (annotationWrapper.get() == null) {
annotationWrapper.set(AnnotationWrapper.create(SofaReference.class)
.withEnvironment(applicationContext.getEnvironment())
.withBinder(DefaultPlaceHolderBinder.INSTANCE));
annotationWrapper.set(createAnnotationWrapper());
}
sofaReferenceAnnotation = annotationWrapper.get().wrap(sofaReferenceAnnotation);

Expand Down Expand Up @@ -136,9 +134,7 @@ private void processSofaReference(final Object bean, String beanName) {
}

if (annotationWrapper.get() == null) {
annotationWrapper.set(AnnotationWrapper.create(SofaReference.class)
.withEnvironment(applicationContext.getEnvironment())
.withBinder(DefaultPlaceHolderBinder.INSTANCE));
annotationWrapper.set(createAnnotationWrapper());
}
sofaReferenceAnnotation = annotationWrapper.get().wrap(sofaReferenceAnnotation);

Expand Down Expand Up @@ -192,8 +188,12 @@ public int getOrder() {
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
this.annotationWrapper.set(AnnotationWrapper.create(SofaReference.class)
.withEnvironment(applicationContext.getEnvironment())
.withBinder(DefaultPlaceHolderBinder.INSTANCE));
this.annotationWrapper.set(createAnnotationWrapper());
}

private AnnotationWrapper<SofaReference> createAnnotationWrapper() {
return AnnotationWrapper.create(SofaReference.class)
.withEnvironment(this.applicationContext.getEnvironment())
.withBinder(DefaultPlaceHolderBinder.INSTANCE);
}
}

0 comments on commit 2b80268

Please sign in to comment.