This is an automated email from the ASF dual-hosted git repository.
brusdev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new b9243cc ARTEMIS-3654 Fix AllClassesTest leaks
b9243cc is described below
commit b9243cc999003f2d0b77a69fe125a5a33b82113f
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Mon Jan 24 13:42:48 2022 +0100
ARTEMIS-3654 Fix AllClassesTest leaks
---
.../apache/activemq/artemis/tests/unit/AllClassesTest.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java
index 2aefc3e..d831a5b 100644
---
a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java
+++
b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java
@@ -90,8 +90,18 @@ public class AllClassesTest {
Assume.assumeTrue("Cannot create " + targetClass.getName(),
targetInstance != null);
- String targetOutput = targetInstance.toString();
- log.debug("targetOutput: " + targetOutput);
+ try {
+ String targetOutput = targetInstance.toString();
+ log.debug("targetOutput: " + targetOutput);
+ } finally {
+ if (targetInstance instanceof AutoCloseable) {
+ try {
+ ((AutoCloseable)targetInstance).close();
+ } catch (Throwable t) {
+ log.debug("Error closing the instance of " +
targetClass.getName() + ": " + t);
+ }
+ }
+ }
}
private Object newInstance(Class targetClass) {