gnodet commented on code in PR #11829:
URL: https://github.com/apache/maven/pull/11829#discussion_r2994811825
##########
impl/maven-testing/src/main/java/org/apache/maven/api/di/testing/MavenDIExtension.java:
##########
@@ -123,10 +135,11 @@ protected void setupContainer() {
*/
@Override
public void afterEach(ExtensionContext context) throws Exception {
+ Injector injector =
context.getStore(MAVEN_DI_EXTENSION).get(Injector.class, Injector.class);
if (injector != null) {
Review Comment:
Suggestion: if `injector.dispose()` throws, the ThreadLocal is never cleaned
up. Consider wrapping in try-finally:
```java
try {
Injector injector =
context.getStore(MAVEN_DI_EXTENSION).get(Injector.class, Injector.class);
if (injector != null) {
injector.dispose();
}
} finally {
EXTENSION_CONTEXT_THREAD_LOCAL.remove();
}
```
_Claude Code on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]