Skip to content
Permalink
Browse files
BATCHEE-65 removed unnecessary try/catch
  • Loading branch information
rsandtner committed Nov 9, 2015
1 parent 6d7a20d commit a212f4fb597b98492f3ca2651d83f51060ce4450
Showing 1 changed file with 20 additions and 25 deletions.
@@ -31,33 +31,28 @@
public class CDIBatchArtifactFactory extends DefaultBatchArtifactFactory {
@Override
public Instance load(final String batchId) {
try {
final BeanManager bm = getBeanManager();
if (bm == null) {
return super.load(batchId);
}
final BeanManager bm = getBeanManager();
if (bm == null) {
return super.load(batchId);
}

final Set<Bean<?>> beans = bm.getBeans(batchId);
final Bean<?> bean = bm.resolve(beans);
if (bean == null) { // fallback to try to instantiate it from TCCL as per the spec
return super.load(batchId);
}
final Class<?> clazz = bean.getBeanClass();
final CreationalContext creationalContext = bm.createCreationalContext(bean);
final Object artifactInstance = bm.getReference(bean, clazz, creationalContext);
if (Dependent.class.equals(bean.getScope()) || !bm.isNormalScope(bean.getScope())) { // need to be released
return new Instance(artifactInstance, new Closeable() {
@Override
public void close() throws IOException {
creationalContext.release();
}
});
}
return new Instance(artifactInstance, null);
} catch (final Exception e) {
// no-op
final Set<Bean<?>> beans = bm.getBeans(batchId);
final Bean<?> bean = bm.resolve(beans);
if (bean == null) { // fallback to try to instantiate it from TCCL as per the spec
return super.load(batchId);
}
final Class<?> clazz = bean.getBeanClass();
final CreationalContext creationalContext = bm.createCreationalContext(bean);
final Object artifactInstance = bm.getReference(bean, clazz, creationalContext);
if (Dependent.class.equals(bean.getScope()) || !bm.isNormalScope(bean.getScope())) { // need to be released
return new Instance(artifactInstance, new Closeable() {
@Override
public void close() throws IOException {
creationalContext.release();
}
});
}
return null;
return new Instance(artifactInstance, null);
}

@Override

0 comments on commit a212f4f

Please sign in to comment.