Skip to content

Commit 8a04910

Browse files
stsypanovjhoeller
authored andcommitted
Drop explicit zeroing at instantiation of Atomic* objects
1 parent b7e1553 commit 8a04910

35 files changed

Lines changed: 64 additions & 64 deletions

File tree

integration-tests/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -182,7 +182,7 @@ static MyAspect myAspect() {
182182
@Aspect
183183
public static class MyAspect {
184184

185-
private final AtomicInteger count = new AtomicInteger(0);
185+
private final AtomicInteger count = new AtomicInteger();
186186

187187
@org.aspectj.lang.annotation.Before("execution(* scheduled())")
188188
public void checkTransaction() {
@@ -200,7 +200,7 @@ public interface MyRepository {
200200
@Repository
201201
static class MyRepositoryImpl implements MyRepository {
202202

203-
private final AtomicInteger count = new AtomicInteger(0);
203+
private final AtomicInteger count = new AtomicInteger();
204204

205205
@Transactional
206206
@Scheduled(fixedDelay = 5)
@@ -226,7 +226,7 @@ public interface MyRepositoryWithScheduledMethod {
226226
@Repository
227227
static class MyRepositoryWithScheduledMethodImpl implements MyRepositoryWithScheduledMethod {
228228

229-
private final AtomicInteger count = new AtomicInteger(0);
229+
private final AtomicInteger count = new AtomicInteger();
230230

231231
@Autowired(required = false)
232232
private MyAspect myAspect;

spring-aop/src/main/java/org/springframework/aop/support/ControlFlowPointcut.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public class ControlFlowPointcut implements Pointcut, ClassFilter, MethodMatcher
4545
@Nullable
4646
private final String methodName;
4747

48-
private final AtomicInteger evaluations = new AtomicInteger(0);
48+
private final AtomicInteger evaluations = new AtomicInteger();
4949

5050

5151
/**

spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -286,7 +286,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) {
286286
}
287287
AtomicInteger c = count.get(beanName);
288288
if (c == null) {
289-
c = new AtomicInteger(0);
289+
c = new AtomicInteger();
290290
count.put(beanName, c);
291291
}
292292
c.incrementAndGet();

spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ default String greet(String name) {
113113

114114
static class SimpleGreeter implements Greeter {
115115

116-
private final AtomicBoolean cacheMiss = new AtomicBoolean(false);
116+
private final AtomicBoolean cacheMiss = new AtomicBoolean();
117117

118118
@Override
119119
public boolean isCacheMiss() {

spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ protected final class Segment extends ReentrantLock {
474474
* The total number of references contained in this segment. This includes chained
475475
* references and references that have been garbage collected but not purged.
476476
*/
477-
private final AtomicInteger count = new AtomicInteger(0);
477+
private final AtomicInteger count = new AtomicInteger();
478478

479479
/**
480480
* The threshold when resizing of the references should occur. When {@code count}

spring-core/src/main/java/org/springframework/util/CustomizableThreadCreator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class CustomizableThreadCreator implements Serializable {
4444
@Nullable
4545
private ThreadGroup threadGroup;
4646

47-
private final AtomicInteger threadCount = new AtomicInteger(0);
47+
private final AtomicInteger threadCount = new AtomicInteger();
4848

4949

5050
/**

spring-core/src/main/java/org/springframework/util/SimpleIdGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
public class SimpleIdGenerator implements IdGenerator {
3030

31-
private final AtomicLong leastSigBits = new AtomicLong(0);
31+
private final AtomicLong leastSigBits = new AtomicLong();
3232

3333

3434
@Override

spring-expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public class SpelExpression implements Expression {
7171

7272
// Count of many times as the expression been interpreted - can trigger compilation
7373
// when certain limit reached
74-
private final AtomicInteger interpretedCount = new AtomicInteger(0);
74+
private final AtomicInteger interpretedCount = new AtomicInteger();
7575

7676
// The number of times compilation was attempted and failed - enables us to eventually
7777
// give up trying to compile it when it just doesn't seem to be possible.
78-
private final AtomicInteger failedAttempts = new AtomicInteger(0);
78+
private final AtomicInteger failedAttempts = new AtomicInteger();
7979

8080

8181
/**

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractBrokerMessageHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public abstract class AbstractBrokerMessageHandler
6363
@Nullable
6464
private ApplicationEventPublisher eventPublisher;
6565

66-
private AtomicBoolean brokerAvailable = new AtomicBoolean(false);
66+
private AtomicBoolean brokerAvailable = new AtomicBoolean();
6767

6868
private final BrokerAvailabilityEvent availableEvent = new BrokerAvailabilityEvent(true, this);
6969

spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class OrderedMessageChannelDecorator implements MessageChannel {
5252

5353
private final Queue<Message<?>> messages = new ConcurrentLinkedQueue<>();
5454

55-
private final AtomicBoolean sendInProgress = new AtomicBoolean(false);
55+
private final AtomicBoolean sendInProgress = new AtomicBoolean();
5656

5757

5858
public OrderedMessageChannelDecorator(MessageChannel channel, Log logger) {

0 commit comments

Comments
 (0)