Drop explicit zeroing at instantiation of Atomic* objects

This commit is contained in:
Сергей Цыпанов 2020-09-30 22:57:04 +03:00 committed by Juergen Hoeller
parent b7e1553c9d
commit 8a04910bdd
35 changed files with 64 additions and 64 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -182,7 +182,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
@Aspect
public static class MyAspect {
private final AtomicInteger count = new AtomicInteger(0);
private final AtomicInteger count = new AtomicInteger();
@org.aspectj.lang.annotation.Before("execution(* scheduled())")
public void checkTransaction() {
@ -200,7 +200,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
@Repository
static class MyRepositoryImpl implements MyRepository {
private final AtomicInteger count = new AtomicInteger(0);
private final AtomicInteger count = new AtomicInteger();
@Transactional
@Scheduled(fixedDelay = 5)
@ -226,7 +226,7 @@ class ScheduledAndTransactionalAnnotationIntegrationTests {
@Repository
static class MyRepositoryWithScheduledMethodImpl implements MyRepositoryWithScheduledMethod {
private final AtomicInteger count = new AtomicInteger(0);
private final AtomicInteger count = new AtomicInteger();
@Autowired(required = false)
private MyAspect myAspect;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
@Nullable
private final String methodName;
private final AtomicInteger evaluations = new AtomicInteger(0);
private final AtomicInteger evaluations = new AtomicInteger();
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -286,7 +286,7 @@ public class FactoryBeanTests {
}
AtomicInteger c = count.get(beanName);
if (c == null) {
c = new AtomicInteger(0);
c = new AtomicInteger();
count.put(beanName, c);
}
c.incrementAndGet();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -113,7 +113,7 @@ public class CacheProxyFactoryBeanTests {
static class SimpleGreeter implements Greeter {
private final AtomicBoolean cacheMiss = new AtomicBoolean(false);
private final AtomicBoolean cacheMiss = new AtomicBoolean();
@Override
public boolean isCacheMiss() {

View File

@ -474,7 +474,7 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen
* The total number of references contained in this segment. This includes chained
* references and references that have been garbage collected but not purged.
*/
private final AtomicInteger count = new AtomicInteger(0);
private final AtomicInteger count = new AtomicInteger();
/**
* The threshold when resizing of the references should occur. When {@code count}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ public class CustomizableThreadCreator implements Serializable {
@Nullable
private ThreadGroup threadGroup;
private final AtomicInteger threadCount = new AtomicInteger(0);
private final AtomicInteger threadCount = new AtomicInteger();
/**

View File

@ -28,7 +28,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class SimpleIdGenerator implements IdGenerator {
private final AtomicLong leastSigBits = new AtomicLong(0);
private final AtomicLong leastSigBits = new AtomicLong();
@Override

View File

@ -71,11 +71,11 @@ public class SpelExpression implements Expression {
// Count of many times as the expression been interpreted - can trigger compilation
// when certain limit reached
private final AtomicInteger interpretedCount = new AtomicInteger(0);
private final AtomicInteger interpretedCount = new AtomicInteger();
// The number of times compilation was attempted and failed - enables us to eventually
// give up trying to compile it when it just doesn't seem to be possible.
private final AtomicInteger failedAttempts = new AtomicInteger(0);
private final AtomicInteger failedAttempts = new AtomicInteger();
/**

View File

@ -63,7 +63,7 @@ public abstract class AbstractBrokerMessageHandler
@Nullable
private ApplicationEventPublisher eventPublisher;
private AtomicBoolean brokerAvailable = new AtomicBoolean(false);
private AtomicBoolean brokerAvailable = new AtomicBoolean();
private final BrokerAvailabilityEvent availableEvent = new BrokerAvailabilityEvent(true, this);

View File

@ -52,7 +52,7 @@ public class OrderedMessageChannelDecorator implements MessageChannel {
private final Queue<Message<?>> messages = new ConcurrentLinkedQueue<>();
private final AtomicBoolean sendInProgress = new AtomicBoolean(false);
private final AtomicBoolean sendInProgress = new AtomicBoolean();
public OrderedMessageChannelDecorator(MessageChannel channel, Log logger) {

View File

@ -185,7 +185,7 @@ public class DefaultRSocketRequesterTests {
@Test
public void retrieveMonoVoid() {
AtomicBoolean consumed = new AtomicBoolean(false);
AtomicBoolean consumed = new AtomicBoolean();
Mono<Payload> mono = Mono.delay(MILLIS_10).thenReturn(toPayload("bodyA")).doOnSuccess(p -> consumed.set(true));
this.rsocket.setPayloadMonoToReturn(mono);
this.requester.route("").data("").retrieveMono(Void.class).block(Duration.ofSeconds(5));
@ -215,7 +215,7 @@ public class DefaultRSocketRequesterTests {
@Test
public void retrieveFluxVoid() {
AtomicBoolean consumed = new AtomicBoolean(false);
AtomicBoolean consumed = new AtomicBoolean();
Flux<Payload> flux = Flux.just("bodyA", "bodyB")
.delayElements(MILLIS_10).map(this::toPayload).doOnComplete(() -> consumed.set(true));
this.rsocket.setPayloadFluxToReturn(flux);

View File

@ -317,9 +317,9 @@ public class RSocketClientToServerIntegrationTests {
private RSocket delegate;
private final AtomicInteger fireAndForgetCount = new AtomicInteger(0);
private final AtomicInteger fireAndForgetCount = new AtomicInteger();
private final AtomicInteger metadataPushCount = new AtomicInteger(0);
private final AtomicInteger metadataPushCount = new AtomicInteger();
public int getFireAndForgetCount() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -86,8 +86,8 @@ public class ChannelInterceptorTests {
@Test
public void postSendInterceptorMessageWasSent() {
final AtomicBoolean preSendInvoked = new AtomicBoolean(false);
final AtomicBoolean completionInvoked = new AtomicBoolean(false);
final AtomicBoolean preSendInvoked = new AtomicBoolean();
final AtomicBoolean completionInvoked = new AtomicBoolean();
this.channel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
@ -119,8 +119,8 @@ public class ChannelInterceptorTests {
return false;
}
};
final AtomicBoolean preSendInvoked = new AtomicBoolean(false);
final AtomicBoolean completionInvoked = new AtomicBoolean(false);
final AtomicBoolean preSendInvoked = new AtomicBoolean();
final AtomicBoolean completionInvoked = new AtomicBoolean();
testChannel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {

View File

@ -351,7 +351,7 @@ public class OpenEntityManagerInViewTests {
final OpenEntityManagerInViewFilter filter2 = new OpenEntityManagerInViewFilter();
filter2.init(filterConfig2);
final AtomicInteger count = new AtomicInteger(0);
final AtomicInteger count = new AtomicInteger();
final FilterChain filterChain = (servletRequest, servletResponse) -> {
assertThat(TransactionSynchronizationManager.hasResource(factory)).isTrue();
@ -359,7 +359,7 @@ public class OpenEntityManagerInViewTests {
count.incrementAndGet();
};
final AtomicInteger count2 = new AtomicInteger(0);
final AtomicInteger count2 = new AtomicInteger();
final FilterChain filterChain2 = (servletRequest, servletResponse) -> {
assertThat(TransactionSynchronizationManager.hasResource(factory2)).isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -55,7 +55,7 @@ class TransactionContext {
@Nullable
private TransactionStatus transactionStatus;
private final AtomicInteger transactionsStarted = new AtomicInteger(0);
private final AtomicInteger transactionsStarted = new AtomicInteger();
TransactionContext(TestContext testContext, PlatformTransactionManager transactionManager,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -177,7 +177,7 @@ class MockHttpSessionTests {
private static class CountingHttpSessionBindingListener
implements HttpSessionBindingListener {
private final AtomicInteger counter = new AtomicInteger(0);
private final AtomicInteger counter = new AtomicInteger();
@Override
public void valueBound(HttpSessionBindingEvent event) {

View File

@ -52,8 +52,8 @@ import static org.springframework.test.context.cache.ContextCacheTestUtils.reset
*/
class ClassLevelDirtiesContextTestNGTests {
private static final AtomicInteger cacheHits = new AtomicInteger(0);
private static final AtomicInteger cacheMisses = new AtomicInteger(0);
private static final AtomicInteger cacheHits = new AtomicInteger();
private static final AtomicInteger cacheMisses = new AtomicInteger();
@BeforeAll

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,8 +51,8 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.runTests
*/
class ClassLevelDirtiesContextTests {
private static final AtomicInteger cacheHits = new AtomicInteger(0);
private static final AtomicInteger cacheMisses = new AtomicInteger(0);
private static final AtomicInteger cacheHits = new AtomicInteger();
private static final AtomicInteger cacheMisses = new AtomicInteger();
@BeforeAll

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -43,8 +43,8 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.runTests
*/
class DirtiesContextInterfaceTests {
private static final AtomicInteger cacheHits = new AtomicInteger(0);
private static final AtomicInteger cacheMisses = new AtomicInteger(0);
private static final AtomicInteger cacheHits = new AtomicInteger();
private static final AtomicInteger cacheMisses = new AtomicInteger();
@BeforeAll

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -86,7 +86,7 @@ public class HttpOptionsTests {
@Controller
private static class MyController {
private AtomicInteger counter = new AtomicInteger(0);
private AtomicInteger counter = new AtomicInteger();
@RequestMapping(value = "/myUrl", method = RequestMethod.OPTIONS)

View File

@ -431,7 +431,7 @@ public abstract class AbstractReactiveTransactionManager implements ReactiveTran
private Mono<Void> processCommit(TransactionSynchronizationManager synchronizationManager,
GenericReactiveTransaction status) throws TransactionException {
AtomicBoolean beforeCompletionInvoked = new AtomicBoolean(false);
AtomicBoolean beforeCompletionInvoked = new AtomicBoolean();
Mono<Object> commit = prepareForCommit(synchronizationManager, status)
.then(triggerBeforeCommit(synchronizationManager, status))

View File

@ -62,7 +62,7 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
private final NettyDataBufferFactory bufferFactory;
// 0 - not subscribed, 1 - subscribed, 2 - cancelled via connector (before subscribe)
private final AtomicInteger state = new AtomicInteger(0);
private final AtomicInteger state = new AtomicInteger();
private final String logPrefix;

View File

@ -339,7 +339,7 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
private final LimitedPartBodyStreamStorageFactory storageFactory;
private final AtomicInteger terminated = new AtomicInteger(0);
private final AtomicInteger terminated = new AtomicInteger();
FluxSinkAdapterListener(
FluxSink<Part> sink, MultipartContext context, LimitedPartBodyStreamStorageFactory factory) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequ
@Nullable
private AsyncContext asyncContext;
private AtomicBoolean asyncCompleted = new AtomicBoolean(false);
private AtomicBoolean asyncCompleted = new AtomicBoolean();
/**

View File

@ -48,7 +48,7 @@ import org.springframework.util.MultiValueMap;
*/
class ReactorServerHttpRequest extends AbstractServerHttpRequest {
private static final AtomicLong logPrefixIndex = new AtomicLong(0);
private static final AtomicLong logPrefixIndex = new AtomicLong();
private final HttpServerRequest request;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -48,7 +48,7 @@ public class StandardServletAsyncWebRequest extends ServletWebRequest implements
private AsyncContext asyncContext;
private AtomicBoolean asyncCompleted = new AtomicBoolean(false);
private AtomicBoolean asyncCompleted = new AtomicBoolean();
private final List<Runnable> timeoutHandlers = new ArrayList<>();

View File

@ -61,7 +61,7 @@ public class ReactorResourceFactoryTests {
@Test
void globalResourcesWithConsumer() throws Exception {
AtomicBoolean invoked = new AtomicBoolean(false);
AtomicBoolean invoked = new AtomicBoolean();
this.resourceFactory.addGlobalResourcesConsumer(httpResources -> invoked.set(true));
this.resourceFactory.afterPropertiesSet();

View File

@ -75,7 +75,7 @@ public class ClientCodecConfigurerTests {
private final ClientCodecConfigurer configurer = new DefaultClientCodecConfigurer();
private final AtomicInteger index = new AtomicInteger(0);
private final AtomicInteger index = new AtomicInteger();
@Test

View File

@ -73,7 +73,7 @@ class CodecConfigurerTests {
private final CodecConfigurer configurer = new TestCodecConfigurer();
private final AtomicInteger index = new AtomicInteger(0);
private final AtomicInteger index = new AtomicInteger();
@Test
@ -374,7 +374,7 @@ class CodecConfigurerTests {
@SuppressWarnings("deprecation")
@Test
void withDefaultCodecConfig() {
AtomicBoolean callbackCalled = new AtomicBoolean(false);
AtomicBoolean callbackCalled = new AtomicBoolean();
this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
this.configurer.customCodecs().withDefaultCodecConfig(config -> {
assertThat(config.isEnableLoggingRequestDetails()).isTrue();

View File

@ -77,7 +77,7 @@ public class ServerCodecConfigurerTests {
private final ServerCodecConfigurer configurer = new DefaultServerCodecConfigurer();
private final AtomicInteger index = new AtomicInteger(0);
private final AtomicInteger index = new AtomicInteger();
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -121,7 +121,7 @@ public class ContextPathCompositeHandlerTests {
@Test // SPR-17144
public void notFoundWithCommitAction() {
AtomicBoolean commitInvoked = new AtomicBoolean(false);
AtomicBoolean commitInvoked = new AtomicBoolean();
ServerHttpRequest request = MockServerHttpRequest.get("/unknown/path").build();
ServerHttpResponse response = new MockServerHttpResponse();

View File

@ -123,7 +123,7 @@ public class WebHttpHandlerBuilderTests {
BiFunction<ServerHttpRequest, String, ServerHttpRequest> mutator =
(req, value) -> req.mutate().headers(headers -> headers.add("My-Header", value)).build();
AtomicBoolean success = new AtomicBoolean(false);
AtomicBoolean success = new AtomicBoolean();
HttpHandler httpHandler = WebHttpHandlerBuilder
.webHandler(exchange -> {
HttpHeaders headers = exchange.getRequest().getHeaders();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -187,7 +187,7 @@ class DefaultTransportRequest implements TransportRequest {
private final SettableListenableFuture<WebSocketSession> future;
private final AtomicBoolean handled = new AtomicBoolean(false);
private final AtomicBoolean handled = new AtomicBoolean();
public ConnectCallback(WebSocketHandler handler, SettableListenableFuture<WebSocketSession> future) {
this.handler = handler;

View File

@ -145,7 +145,7 @@ public class WebSocketTransport implements Transport, Lifecycle {
private final WebSocketClientSockJsSession sockJsSession;
private final AtomicBoolean connected = new AtomicBoolean(false);
private final AtomicBoolean connected = new AtomicBoolean();
public ClientSockJsWebSocketHandler(WebSocketClientSockJsSession session) {
Assert.notNull(session, "Session must not be null");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -55,7 +55,7 @@ public class SockJsWebSocketHandler extends TextWebSocketHandler implements SubP
private final List<String> subProtocols;
private final AtomicInteger sessionCount = new AtomicInteger(0);
private final AtomicInteger sessionCount = new AtomicInteger();
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler,