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 1
1
[ ![ 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 )
3
3
[ ![ 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 )
4
4
5
5
# <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 3
3
import java .lang .instrument .Instrumentation ;
4
4
5
5
public class InstrumentationHolder {
6
- private static volatile Instrumentation instrumentation ;
6
+ private static Instrumentation instrumentation ;
7
7
8
- private static volatile ClassLoader agentClassLoader ;
8
+ private static ClassLoader agentClassLoader ;
9
9
10
10
public static Instrumentation getInstrumentation () {
11
11
return instrumentation ;
Original file line number Diff line number Diff line change @@ -63,9 +63,9 @@ public int hashCode() {
63
63
public boolean equals (Object other ) {
64
64
if (other instanceof WeakCache .WeakReferenceKey <?>) {
65
65
return ((WeakReferenceKey <?>) other ).get () == get ();
66
- } else {
67
- return other .equals (this );
68
66
}
67
+
68
+ return other != null && other .equals (this );
69
69
}
70
70
}
71
71
}
Original file line number Diff line number Diff line change 2
2
3
3
import static org .junit .jupiter .api .Assertions .*;
4
4
5
+ import java .lang .ref .ReferenceQueue ;
5
6
import java .util .concurrent .ForkJoinTask ;
6
7
import java .util .concurrent .TimeUnit ;
7
8
import org .junit .jupiter .api .AfterEach ;
@@ -56,4 +57,11 @@ void testNormalKeyValue() throws InterruptedException {
56
57
// check -> remove after gc
57
58
assertFalse (Cache .CAPTURED_CACHE .contains (null ));
58
59
}
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
+ }
59
67
}
You can’t perform that action at this time.
0 commit comments