Skip to content

Commit d18b208

Browse files
committed
logging clarity
1 parent b89cc99 commit d18b208

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/main/java/software/amazon/awssdk/crt/CrtResource.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,16 @@ public CrtResource() {
124124
* @param resource The resource to add a reference to
125125
*/
126126
public void addReferenceTo(CrtResource resource) {
127-
int remainingRefs = refCount.incrementAndGet();
127+
resource.addRef();
128+
128129
synchronized(this) {
129130
referencedResources.add(resource);
130131
}
131132

132133
if (debugNativeObjects) {
133134
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
134-
String.format("Instance of class %s(%d) is adding a reference to instance of class %s(%d) increasing its refcount to %d",
135-
this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id, remainingRefs));
135+
String.format("%s(%d) is adding a reference to %s(%d).",
136+
this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
136137
}
137138
}
138139

@@ -149,11 +150,11 @@ public void removeReferenceTo(CrtResource resource) {
149150
if (debugNativeObjects) {
150151
if (removed) {
151152
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
152-
String.format("Instance of class %s(%d) is removing a reference to instance of class %s(%d)",
153+
String.format("%s(%d) is removing a reference to %s(%d)",
153154
this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
154155
} else {
155156
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
156-
String.format("Instance of class %s(%d) erroneously tried to remove a reference to instance of class %s(%d) that it was not referencing",
157+
String.format("%s(%d) erroneously tried to remove a reference to %s(%d) that it was not referencing",
157158
this.getClass().getCanonicalName(), id, resource.getClass().getCanonicalName(), resource.id));
158159
}
159160
}
@@ -248,7 +249,7 @@ public void addRef() {
248249

249250
if (debugNativeObjects) {
250251
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
251-
String.format("Instance of class %s(%d) is adding a reference. RefCount is now %d",
252+
String.format("%s(%d) is adding a reference. RefCount is now %d",
252253
this.getClass().getCanonicalName(), id, remainingRefs));
253254
}
254255
}
@@ -257,11 +258,11 @@ public void addRef() {
257258
* Increments the reference count to this resource with a description.
258259
* @param desc Descrption string of why the reference is being incremented.
259260
*/
260-
public void addRefDescribe(String desc) {
261+
public void addRef(String desc) {
261262
int remainingRefs = refCount.incrementAndGet();
262263
if (debugNativeObjects) {
263264
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
264-
String.format("Instance of class %s(%d) is adding a reference for: (%s). RefCount is now %d",
265+
String.format("%s(%d) is adding a reference for: (%s). RefCount is now %d",
265266
this.getClass().getCanonicalName(), id, desc, remainingRefs));
266267
}
267268
}
@@ -313,7 +314,7 @@ public void decRef(CrtResource decRefInstigator) {
313314

314315
if (debugNativeObjects && decRefInstigator != null) {
315316
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format(
316-
"DecRef instance of class %s(%d) called by %s(%d). %d remaining refs",
317+
"DecRef on %s(%d) called by %s(%d). %d remaining refs",
317318
this.getClass().getCanonicalName(), id,
318319
decRefInstigator.getClass().getCanonicalName(), decRefInstigator.id,
319320
remainingRefs));
@@ -340,11 +341,11 @@ public void decRef(String desc) {
340341
if (debugNativeObjects) {
341342
if (desc != null) {
342343
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
343-
String.format("DecRef instance of class %s(%d) for: (%s). %d remaining refs",
344+
String.format("DecRef on %s(%d) for: (%s). %d remaining refs",
344345
this.getClass().getCanonicalName(), id, desc, remainingRefs));
345346
} else {
346347
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource,
347-
String.format("Defref instance of class %s(%d). %d remaining refs",
348+
String.format("Defref on %s(%d). %d remaining refs",
348349
this.getClass().getCanonicalName(), id, remainingRefs));
349350
}
350351
}
@@ -374,7 +375,7 @@ public void decRef() {
374375
*/
375376
protected void releaseReferences() {
376377
if (debugNativeObjects) {
377-
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("Instance of class %s(%d) closing all referenced objects", this.getClass().getCanonicalName(), id));
378+
Log.log(ResourceLogLevel, Log.LogSubject.JavaCrtResource, String.format("%s(%d) closing all referenced objects", this.getClass().getCanonicalName(), id));
378379
}
379380

380381
synchronized(this) {

0 commit comments

Comments
 (0)