orpiske commented on code in PR #14641:
URL: https://github.com/apache/camel/pull/14641#discussion_r1654756707
##########
components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java:
##########
@@ -144,15 +145,16 @@ public void beforeAll(ExtensionContext context) {
testConfigurationBuilder.withCreateCamelContextPerClass(perClassPresent);
contextManager =
contextManagerFactory.createContextManager(ContextManagerFactory.Type.BEFORE_ALL,
testConfigurationBuilder, camelContextConfiguration);
+ ExtensionContext.Store globalStore =
context.getStore(ExtensionContext.Namespace.GLOBAL);
+ contextManager.setGlobalStore(globalStore);
}
-
- ExtensionContext.Store globalStore =
context.getStore(ExtensionContext.Namespace.GLOBAL);
- contextManager.setGlobalStore(globalStore);
}
@Override
public void afterAll(ExtensionContext context) {
- contextManager.stop();
+ if(Objects.nonNull(contextManager)) {
+ contextManager.stop();
+ }
Review Comment:
Just do it like I did on my other PR.
##########
components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/CamelTestSupport.java:
##########
@@ -144,15 +145,16 @@ public void beforeAll(ExtensionContext context) {
testConfigurationBuilder.withCreateCamelContextPerClass(perClassPresent);
contextManager =
contextManagerFactory.createContextManager(ContextManagerFactory.Type.BEFORE_ALL,
testConfigurationBuilder, camelContextConfiguration);
+ ExtensionContext.Store globalStore =
context.getStore(ExtensionContext.Namespace.GLOBAL);
+ contextManager.setGlobalStore(globalStore);
}
-
- ExtensionContext.Store globalStore =
context.getStore(ExtensionContext.Namespace.GLOBAL);
- contextManager.setGlobalStore(globalStore);
}
@Override
public void afterAll(ExtensionContext context) {
- contextManager.stop();
+ if(Objects.nonNull(contextManager)) {
+ contextManager.stop();
+ }
Review Comment:
For instance:
```
if (contextManager != null) {
// It may be null in some occasion, such as when failing to
initialize the context
contextManager.stop();
}
```
--
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]