File tree Expand file tree Collapse file tree 4 files changed +13
-5
lines changed
main/java/io/arex/agent/bootstrap
test/java/io/arex/agent/bootstrap/internal Expand file tree Collapse file tree 4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11[ ![ Build Status] ( https://github.com/arextest/arex-agent-java/actions/workflows/build.yml/badge.svg?branch=main )] ( https://github.com/arextest/arex-agent-java/actions/workflows/build.yml )
2- [ ![ codecov ] ( https://codecov .io/gh/arextest/arex -agent-java/branch/main/graph/badge.svg )] ( https://app.codecov. io/gh/arextest/arex -agent-java )
2+ [ ![ Coverage ] ( https://sonarcloud .io/api/project_badges/measure?project=arextest_arex -agent-java&metric=coverage )] ( https://sonarcloud. io/summary/overall?id=arextest_arex -agent-java )
33[ ![ Quality Gate Status] ( https://sonarcloud.io/api/project_badges/measure?project=arextest_arex-agent-java&metric=alert_status )] ( https://sonarcloud.io/summary/new_code?id=arextest_arex-agent-java )
44
55# <img src =" https://avatars.githubusercontent.com/u/103105168?s=200&v=4 " alt =" Arex Icon " width =" 27 " height =" " > AREX
Original file line number Diff line number Diff line change 33import java .lang .instrument .Instrumentation ;
44
55public class InstrumentationHolder {
6- private static volatile Instrumentation instrumentation ;
6+ private static Instrumentation instrumentation ;
77
8- private static volatile ClassLoader agentClassLoader ;
8+ private static ClassLoader agentClassLoader ;
99
1010 public static Instrumentation getInstrumentation () {
1111 return instrumentation ;
Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ public int hashCode() {
6363 public boolean equals (Object other ) {
6464 if (other instanceof WeakCache .WeakReferenceKey <?>) {
6565 return ((WeakReferenceKey <?>) other ).get () == get ();
66- } else {
67- return other .equals (this );
6866 }
67+
68+ return other != null && other .equals (this );
6969 }
7070 }
7171}
Original file line number Diff line number Diff line change 22
33import static org .junit .jupiter .api .Assertions .*;
44
5+ import java .lang .ref .ReferenceQueue ;
56import java .util .concurrent .ForkJoinTask ;
67import java .util .concurrent .TimeUnit ;
78import org .junit .jupiter .api .AfterEach ;
@@ -56,4 +57,11 @@ void testNormalKeyValue() throws InterruptedException {
5657 // check -> remove after gc
5758 assertFalse (Cache .CAPTURED_CACHE .contains (null ));
5859 }
60+
61+ @ Test
62+ void testWeakReferenceKeyEqualsReturnsFalse () {
63+ WeakCache .WeakReferenceKey <String > key = new WeakCache .WeakReferenceKey <>("test" , new ReferenceQueue <>());
64+ assertFalse (key .equals (null ));
65+ assertFalse (key .equals ("test" ));
66+ }
5967}
You can’t perform that action at this time.
0 commit comments