-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atomic operations for BeanDefinitionProducer #11570
base: 4.8.x
Are you sure you want to change the base?
Conversation
Replace the BeanDefinitionProducer API with atomic operations. This removes patterns like `if (producer.isReferenceEnabled()) producer.getReference()` which could cause TOCTOU concurrency issues. Should fix #11569
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK though it'd be good to have a comment justifying this sort of very fine grained parallelism with performance numbers. There are some unintuitive states possible here (e.g. reference == null whilst definition is not the sentinel). I can see why bean management would be performance sensitive, but how much difference does all this really make?
@@ -2078,7 +2080,7 @@ protected void initializeContext( | |||
if (CollectionUtils.isNotEmpty(parallelBeans)) { | |||
processParallelBeans(parallelBeans); | |||
} | |||
ForkJoinPool.commonPool().execute(() -> beanDefinitionsClasses.forEach(p -> p.isReferenceEnabled(this))); | |||
ForkJoinPool.commonPool().execute(() -> beanDefinitionsClasses.forEach(p -> p.getReferenceIfEnabled(this))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this line trying to do originally? It looks a bit odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's kicking off async loading of all bean definitions that were not initialized by the previous code
inject/src/main/java/io/micronaut/context/DefaultBeanContext.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have tests for this?
Replace the BeanDefinitionProducer API with atomic operations. This removes patterns like
if (producer.isReferenceEnabled()) producer.getReference()
which could cause TOCTOU concurrency issues.Should fix #11569