Skip to content

Commit

Permalink
Log leaked native resources using error log level in waitForNoResourc… (
Browse files Browse the repository at this point in the history
  • Loading branch information
zoewangg committed Feb 23, 2024
1 parent 732a549 commit 717db5e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/software/amazon/awssdk/crt/CrtResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,13 @@ public static void collectNativeResource(Consumer<ResourceInstance> fn) {
* Debug method to log all of the currently un-closed CRTResource objects.
*/
public static void logNativeResources() {
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, "Dumping native object set:");
logNativeResources(ResourceLogLevel);
}

public static void logNativeResources(Log.LogLevel logLevel) {
Log.log(logLevel, Log.LogSubject.JavaCrtResource, "Dumping native object set:");
collectNativeResource((resource) -> {
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, resource.getWrapper().getResourceLogDescription());
Log.log(logLevel, Log.LogSubject.JavaCrtResource, resource.getWrapper().getResourceLogDescription());
});
}

Expand Down Expand Up @@ -436,7 +440,7 @@ public static void waitForNoResources() {

if (resourceCount != 0) {
Log.log(Log.LogLevel.Error, Log.LogSubject.JavaCrtResource, "waitForNoResources - timeOut");
logNativeResources();
logNativeResources(Log.LogLevel.Error);
throw new InterruptedException();
}
} catch (InterruptedException e) {
Expand Down

0 comments on commit 717db5e

Please sign in to comment.