Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ public static void checkValidProjectId(String idToCheck) {
* @param managers Varargs of the managers to clean
*/
public static void cleanResources(ResourceManager... managers) {
cleanResources(false, managers);
}

/**
* Cleanup Resources from the given ResourceManagers. It will guarantee that all the cleanups are
* invoked, but still throws / bubbles the first exception at the end if something went wrong.
*
* @param failOnCleanup Throw exception if cleanup fails.
* @param managers Varargs of the managers to clean
*/
public static void cleanResources(boolean failOnCleanup, ResourceManager... managers) {

if (managers == null || managers.length == 0) {
return;
Expand All @@ -159,8 +170,12 @@ public static void cleanResources(ResourceManager... managers) {
}
}

if (bubbleException != null) {
if (bubbleException != null && failOnCleanup) {
throw new RuntimeException("Error cleaning up resources", bubbleException);
} else if (bubbleException != null) {
LOG.warn(
"Error cleaning up resources. This is not configured to fail the test: {}",
bubbleException.getMessage());
}
}

Expand Down
Loading