From 5bf0bb3ea42ba7469ad7d74b5140fc91d8d43ee2 Mon Sep 17 00:00:00 2001 From: Ammar Khaku Date: Thu, 13 Oct 2022 12:35:54 -0700 Subject: [PATCH] Catch and ignore more errors when reflecting into container subclass With #2830 we added support for 4.x of the Cassandra driver. It was done in a way to allow a user to use either the 3.x or 4.x driver while excluding the other one. However if using 4.x and excluding 3.x, GenericContainer#canBeReused throws an exception during reflection since the Cluster class returned by CassandraContainer#getCluster is missing. This PR works around that issue by catching and ignoring the thrown NoClassDefFoundError. --- .../java/org/testcontainers/containers/GenericContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/containers/GenericContainer.java b/core/src/main/java/org/testcontainers/containers/GenericContainer.java index 7163ea40a93..bc65cb22040 100644 --- a/core/src/main/java/org/testcontainers/containers/GenericContainer.java +++ b/core/src/main/java/org/testcontainers/containers/GenericContainer.java @@ -360,7 +360,7 @@ protected boolean canBeReused() { logger().warn("{} can't be reused because it overrides {}", getClass(), method.getName()); return false; } - } catch (NoSuchMethodException e) { + } catch (NoSuchMethodException | NoClassDefFoundError e) { // ignore } }