remove IllegalStateException catch block
That will ALWAYS get wrapped in a InvocationTargetException anyway, as we
are calling it via reflection.
diff --git a/jbatch/src/main/java/org/apache/batchee/container/cdi/BatchCDIInjectionExtension.java b/jbatch/src/main/java/org/apache/batchee/container/cdi/BatchCDIInjectionExtension.java
index abc6c14..f7d47ac 100755
--- a/jbatch/src/main/java/org/apache/batchee/container/cdi/BatchCDIInjectionExtension.java
+++ b/jbatch/src/main/java/org/apache/batchee/container/cdi/BatchCDIInjectionExtension.java
@@ -111,13 +111,10 @@
try {
return (BeanManager) CDI_GET_BEAN_MANAGER_METHOD.invoke(CDI_CURRENT_METHOD.invoke(null));
} catch (Exception e) {
- if (e instanceof IllegalStateException) {
+ if (e instanceof InvocationTargetException && e.getCause() instanceof IllegalStateException) {
// all fine, that just means that no CDI container is available right now.
// Maybe we only have the spec jar in the classpath, but no container is started?
- return null;
- }
- if (e instanceof InvocationTargetException && e.getCause() instanceof IllegalStateException) {
- // same as above
+ // we always get it wrapped in a InvocationTargetException as we use reflection.
return null;
}