Skip to content

Commit d56e18f

Browse files
committed
Handle UnsupportedOperationException in BeanFinalizer
1 parent 18f5abe commit d56e18f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/com/coditory/quark/context/BeanFinalizer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ private static void closeBean(Object bean, BeanDescriptor<?> descriptor, Method
3434
try {
3535
Object[] args = resolveArguments(method, context);
3636
method.invoke(bean, args);
37+
log.debug("Closed bean {} using method {} in {}", descriptor.toShortString(), simplifyMethodName(method), timer.measureAndFormat());
38+
} catch (UnsupportedOperationException e) {
39+
log.debug("Could not close bean {} because of UnsupportedOperationException thrown from {}", descriptor.toShortString(), simplifyMethodName(method));
3740
} catch (Exception e) {
38-
if (e instanceof UnsupportedOperationException) {
39-
log.debug("Bean {} threw UnsupportedOperationException from {}", descriptor.toShortString(), simplifyMethodName(method));
40-
} else {
41-
throw new BeanFinalizationException("Could not close bean: " + descriptor.toShortString() + " using method: " + simplifyMethodName(method), e);
42-
}
41+
throw new BeanFinalizationException("Could not close bean: " + descriptor.toShortString() + " using method: " + simplifyMethodName(method), e);
4342
}
44-
log.debug("Closed bean {} using method {} in {}", descriptor.toShortString(), simplifyMethodName(method), timer.measureAndFormat());
4543
}
4644

4745
private static void closeBean(Closeable bean, BeanDescriptor<?> descriptor) {
4846
Timer timer = Timer.start();
4947
try {
5048
bean.close();
49+
log.debug("Closed bean {} in {}", descriptor.toShortString(), timer.measureAndFormat());
50+
} catch (UnsupportedOperationException e) {
51+
log.debug("Could not close bean {} because of UnsupportedOperationException", descriptor.toShortString());
5152
} catch (Exception e) {
5253
throw new BeanFinalizationException("Could not close bean: " + descriptor.toShortString(), e);
5354
}
54-
log.debug("Closed bean {} in {}", descriptor.toShortString(), timer.measureAndFormat());
5555
}
5656
}

0 commit comments

Comments
 (0)