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:
dreis2211
2020-10-02 12:46:27 +02:00
committed by Stephane Nicoll
parent 48c2f4d9cc
commit ecee9c0f9b
13 changed files with 21 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-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.
@@ -28,7 +28,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
private static final AtomicInteger snakeIds = new AtomicInteger(0);
private static final AtomicInteger snakeIds = new AtomicInteger();
private static final Random random = new Random();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-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.
@@ -28,7 +28,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
private static final AtomicInteger snakeIds = new AtomicInteger(0);
private static final AtomicInteger snakeIds = new AtomicInteger();
private static final Random random = new Random();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-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.
@@ -28,7 +28,7 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler {
private static final AtomicInteger snakeIds = new AtomicInteger(0);
private static final AtomicInteger snakeIds = new AtomicInteger();
private static final Random random = new Random();