File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
it/common/src/main/java/org/apache/beam/it/common/utils Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,17 @@ public static void checkValidProjectId(String idToCheck) {
137137 * @param managers Varargs of the managers to clean
138138 */
139139 public static void cleanResources (ResourceManager ... managers ) {
140+ cleanResources (false , managers );
141+ }
142+
143+ /**
144+ * Cleanup Resources from the given ResourceManagers. It will guarantee that all the cleanups are
145+ * invoked, but still throws / bubbles the first exception at the end if something went wrong.
146+ *
147+ * @param failOnCleanup Throw exception if cleanup fails.
148+ * @param managers Varargs of the managers to clean
149+ */
150+ public static void cleanResources (boolean failOnCleanup , ResourceManager ... managers ) {
140151
141152 if (managers == null || managers .length == 0 ) {
142153 return ;
@@ -159,8 +170,12 @@ public static void cleanResources(ResourceManager... managers) {
159170 }
160171 }
161172
162- if (bubbleException != null ) {
173+ if (bubbleException != null && failOnCleanup ) {
163174 throw new RuntimeException ("Error cleaning up resources" , bubbleException );
175+ } else if (bubbleException != null ) {
176+ LOG .warn (
177+ "Error cleaning up resources. This is not configured to fail the test: {}" ,
178+ bubbleException .getMessage ());
164179 }
165180 }
166181
You can’t perform that action at this time.
0 commit comments