Avoid unnecessary explicit initialization of Atomics
Constructor calls like new AtomicInteger(0) cause a volatile write that can be saved in cases where the constructor parameter is the default value. See gh-23575
This commit is contained in:
committed by
Stephane Nicoll
parent
48c2f4d9cc
commit
ecee9c0f9b
@@ -87,7 +87,7 @@ class Neo4jHealthIndicatorTests {
|
||||
ResultSummary resultSummary = ResultSummaryMock.createResultSummary("4711", "My Home", "");
|
||||
Session session = mock(Session.class);
|
||||
Result statementResult = mockStatementResult(resultSummary, "some edition");
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
given(session.run(anyString())).will((invocation) -> {
|
||||
if (count.compareAndSet(0, 1)) {
|
||||
throw new SessionExpiredException("Session expired");
|
||||
|
||||
@@ -66,7 +66,7 @@ class Neo4jReactiveHealthIndicatorTest {
|
||||
ResultSummary resultSummary = ResultSummaryMock.createResultSummary("4711", "My Home", "");
|
||||
RxSession session = mock(RxSession.class);
|
||||
RxResult statementResult = mockStatementResult(resultSummary, "some edition");
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
given(session.run(anyString())).will((invocation) -> {
|
||||
if (count.compareAndSet(0, 1)) {
|
||||
throw new SessionExpiredException("Session expired");
|
||||
|
||||
Reference in New Issue
Block a user