Skip to content

Commit d245600

Browse files
committed
Allow removal of all values computed by a ClassLoaderValue
1 parent 244c44b commit d245600

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

utils/src/main/java/datadog/instrument/utils/ClassLoaderValue.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ public final void remove(ClassLoader cl) {
109109
}
110110
}
111111

112+
/** Removes all values computed by this {@code ClassLoaderValue}. */
113+
public final void clear() {
114+
bootValue = null;
115+
systemValue = null;
116+
otherValues.clear();
117+
}
118+
112119
/**
113120
* Visits the values computed by this {@code ClassLoaderValue}, for diagnostic purposes.
114121
*

utils/src/test/java/datadog/instrument/utils/ClassLoaderValueTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ void basicOperation() {
9595
assertThat(classLoaderValue.get(cl5)).isEqualTo("5=CL5");
9696

9797
assertEquals(6, classLoaderValue.size());
98+
99+
classLoaderValue.clear();
100+
101+
assertEquals(0, classLoaderValue.size());
98102
}
99103

100104
@Test

0 commit comments

Comments
 (0)