Correctly record creation stacktrace in ResourceLeakDetector.

Motivation:

We missed to correctly record the stacktrace of the creation of an ResourceLeak record. This could either have the effect to log the wrote stacktrace for creation or not log a stacktrace at all if the object was dropped on the floor after it was created.

Modifications:

Correctly create a Record on creation of the object.

Result:

Fixes https://github.com/netty/netty/issues/7781.
This commit is contained in:
Norman Maurer 2018-03-15 11:20:35 +01:00 committed by Norman Maurer
parent b0823761f4
commit de082bf4c7

View File

@ -369,7 +369,8 @@ public class ResourceLeakDetector<T> {
// be collected via the WeakReference.
trackedHash = System.identityHashCode(referent);
allLeaks.put(this, LeakEntry.INSTANCE);
headUpdater.set(this, Record.BOTTOM);
// Create a new Record so we always have the creation stacktrace included.
headUpdater.set(this, new Record(Record.BOTTOM));
this.allLeaks = allLeaks;
}