Make variables final (#11548)
Motivation: We should make variables `final` which are not reinstated again in code to match the code style and makes the code look better. Modification: Made couples of variables as `final`. Result: Variables marked as `final`.
This commit is contained in:
parent
a3c4c9ebfd
commit
fe7b18ee83
@ -42,7 +42,7 @@ public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Value might not equal "real" reference count, all access should be via the updater
|
// Value might not equal "real" reference count, all access should be via the updater
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||||
private volatile int refCnt = updater.initialValue();
|
private volatile int refCnt = updater.initialValue();
|
||||||
|
|
||||||
protected AbstractReferenceCountedByteBuf(int maxCapacity) {
|
protected AbstractReferenceCountedByteBuf(int maxCapacity) {
|
||||||
|
@ -667,7 +667,7 @@ public class ByteBufUtilTest {
|
|||||||
ByteBufUtil.utf8Bytes(usAscii, 5, 18));
|
ByteBufUtil.utf8Bytes(usAscii, 5, 18));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[][] INVALID_RANGES = new int[][] {
|
private static final int[][] INVALID_RANGES = new int[][] {
|
||||||
{ -1, 5 }, { 5, 30 }, { 10, 5 }
|
{ -1, 5 }, { 5, 30 }, { 10, 5 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class CorsHandler extends ChannelDuplexHandler {
|
|||||||
|
|
||||||
private HttpRequest request;
|
private HttpRequest request;
|
||||||
private final List<CorsConfig> configList;
|
private final List<CorsConfig> configList;
|
||||||
private boolean isShortCircuit;
|
private final boolean isShortCircuit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance with a single {@link CorsConfig}.
|
* Creates a new instance with a single {@link CorsConfig}.
|
||||||
|
@ -97,7 +97,7 @@ public class HttpPostMultipartRequestDecoder implements InterfaceHttpPostRequest
|
|||||||
/**
|
/**
|
||||||
* If multipart, this is the boundary for the global multipart
|
* If multipart, this is the boundary for the global multipart
|
||||||
*/
|
*/
|
||||||
private String multipartDataBoundary;
|
private final String multipartDataBoundary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If multipart, there could be internal multiparts (mixed) to the global
|
* If multipart, there could be internal multiparts (mixed) to the global
|
||||||
|
@ -27,8 +27,8 @@ import java.nio.charset.Charset;
|
|||||||
* Mixed implementation using both in Memory and in File with a limit of size
|
* Mixed implementation using both in Memory and in File with a limit of size
|
||||||
*/
|
*/
|
||||||
public class MixedAttribute implements Attribute {
|
public class MixedAttribute implements Attribute {
|
||||||
private String baseDir;
|
private final String baseDir;
|
||||||
private boolean deleteOnExit;
|
private final boolean deleteOnExit;
|
||||||
private Attribute attribute;
|
private Attribute attribute;
|
||||||
|
|
||||||
private final long limitSize;
|
private final long limitSize;
|
||||||
|
@ -24,7 +24,7 @@ import org.mockito.stubbing.Answer;
|
|||||||
abstract class AbstractWeightedFairQueueByteDistributorDependencyTest {
|
abstract class AbstractWeightedFairQueueByteDistributorDependencyTest {
|
||||||
Http2Connection connection;
|
Http2Connection connection;
|
||||||
WeightedFairQueueByteDistributor distributor;
|
WeightedFairQueueByteDistributor distributor;
|
||||||
private IntObjectMap<TestStreamByteDistributorStreamState> stateMap =
|
private final IntObjectMap<TestStreamByteDistributorStreamState> stateMap =
|
||||||
new IntObjectHashMap<TestStreamByteDistributorStreamState>();
|
new IntObjectHashMap<TestStreamByteDistributorStreamState>();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -242,6 +242,7 @@ final class HpackTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class HeaderBlock {
|
static class HeaderBlock {
|
||||||
|
@SuppressWarnings("FieldMayBeFinal")
|
||||||
private int maxHeaderTableSize = -1;
|
private int maxHeaderTableSize = -1;
|
||||||
private byte[] encodedBytes;
|
private byte[] encodedBytes;
|
||||||
private List<String> encoded;
|
private List<String> encoded;
|
||||||
|
@ -74,7 +74,7 @@ public class Http2ControlFrameLimitEncoderTest {
|
|||||||
|
|
||||||
private int numWrites;
|
private int numWrites;
|
||||||
|
|
||||||
private Queue<ChannelPromise> goAwayPromises = new ArrayDeque<ChannelPromise>();
|
private final Queue<ChannelPromise> goAwayPromises = new ArrayDeque<ChannelPromise>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init fields and do mocking.
|
* Init fields and do mocking.
|
||||||
|
@ -356,7 +356,7 @@ public final class MqttMessageBuilders {
|
|||||||
private Long maximumPacketSize;
|
private Long maximumPacketSize;
|
||||||
private int topicAliasMaximum;
|
private int topicAliasMaximum;
|
||||||
private String reasonString;
|
private String reasonString;
|
||||||
private MqttProperties.UserProperties userProperties = new MqttProperties.UserProperties();
|
private final MqttProperties.UserProperties userProperties = new MqttProperties.UserProperties();
|
||||||
private Boolean wildcardSubscriptionAvailable;
|
private Boolean wildcardSubscriptionAvailable;
|
||||||
private Boolean subscriptionIdentifiersAvailable;
|
private Boolean subscriptionIdentifiersAvailable;
|
||||||
private Boolean sharedSubscriptionAvailable;
|
private Boolean sharedSubscriptionAvailable;
|
||||||
|
@ -56,7 +56,7 @@ public final class FixedRedisMessagePool implements RedisMessagePool {
|
|||||||
WRONGTYPE("WRONGTYPE Operation against a key holding the wrong kind of value"),
|
WRONGTYPE("WRONGTYPE Operation against a key holding the wrong kind of value"),
|
||||||
NOT_AUTH("NOAUTH Authentication required.");
|
NOT_AUTH("NOAUTH Authentication required.");
|
||||||
|
|
||||||
private String msg;
|
private final String msg;
|
||||||
|
|
||||||
RedisErrorKey(String msg) {
|
RedisErrorKey(String msg) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
|
@ -404,7 +404,7 @@ public abstract class ZlibTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final class TestByteBufAllocator extends AbstractByteBufAllocator {
|
private static final class TestByteBufAllocator extends AbstractByteBufAllocator {
|
||||||
private ByteBufAllocator wrapped;
|
private final ByteBufAllocator wrapped;
|
||||||
private int maxAllocation;
|
private int maxAllocation;
|
||||||
|
|
||||||
TestByteBufAllocator(ByteBufAllocator wrapped) {
|
TestByteBufAllocator(ByteBufAllocator wrapped) {
|
||||||
|
@ -41,7 +41,7 @@ public abstract class AbstractReferenceCounted implements ReferenceCounted {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Value might not equal "real" reference count, all access should be via the updater
|
// Value might not equal "real" reference count, all access should be via the updater
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||||
private volatile int refCnt = updater.initialValue();
|
private volatile int refCnt = updater.initialValue();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class AsciiStringMemoryTest {
|
|||||||
private int length = 100;
|
private int length = 100;
|
||||||
private AsciiString aAsciiString;
|
private AsciiString aAsciiString;
|
||||||
private AsciiString bAsciiString;
|
private AsciiString bAsciiString;
|
||||||
private Random r = new Random();
|
private final Random r = new Random();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
@ -37,7 +37,7 @@ public class ResourceLeakDetectorTest {
|
|||||||
final CyclicBarrier barrier = new CyclicBarrier(threads.length);
|
final CyclicBarrier barrier = new CyclicBarrier(threads.length);
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
Queue<LeakAwareResource> resources = new ArrayDeque<LeakAwareResource>(100);
|
final Queue<LeakAwareResource> resources = new ArrayDeque<LeakAwareResource>(100);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -147,7 +147,7 @@ public class FileRegionThrottleTest {
|
|||||||
|
|
||||||
private static final class ReadHandler extends ChannelInboundHandlerAdapter {
|
private static final class ReadHandler extends ChannelInboundHandlerAdapter {
|
||||||
private long bytesTransferred;
|
private long bytesTransferred;
|
||||||
private CountDownLatch latch;
|
private final CountDownLatch latch;
|
||||||
|
|
||||||
ReadHandler(CountDownLatch latch) {
|
ReadHandler(CountDownLatch latch) {
|
||||||
this.latch = latch;
|
this.latch = latch;
|
||||||
|
@ -34,9 +34,9 @@ import static io.netty.handler.codec.http.HttpConstants.*;
|
|||||||
@Measurement(iterations = 20)
|
@Measurement(iterations = 20)
|
||||||
public class HttpRequestEncoderInsertBenchmark extends AbstractMicrobenchmark {
|
public class HttpRequestEncoderInsertBenchmark extends AbstractMicrobenchmark {
|
||||||
|
|
||||||
private String uri = "http://localhost?eventType=CRITICAL&from=0&to=1497437160327&limit=10&offset=0";
|
private final String uri = "http://localhost?eventType=CRITICAL&from=0&to=1497437160327&limit=10&offset=0";
|
||||||
private OldHttpRequestEncoder encoderOld = new OldHttpRequestEncoder();
|
private final OldHttpRequestEncoder encoderOld = new OldHttpRequestEncoder();
|
||||||
private HttpRequestEncoder encoderNew = new HttpRequestEncoder();
|
private final HttpRequestEncoder encoderNew = new HttpRequestEncoder();
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public ByteBuf oldEncoder() throws Exception {
|
public ByteBuf oldEncoder() throws Exception {
|
||||||
|
@ -115,7 +115,7 @@ public class Http2FrameWriterDataBenchmark extends AbstractMicrobenchmark {
|
|||||||
private static final class OldDefaultHttp2FrameWriter implements Http2DataWriter {
|
private static final class OldDefaultHttp2FrameWriter implements Http2DataWriter {
|
||||||
private static final ByteBuf ZERO_BUFFER =
|
private static final ByteBuf ZERO_BUFFER =
|
||||||
unreleasableBuffer(directBuffer(MAX_UNSIGNED_BYTE).writeZero(MAX_UNSIGNED_BYTE)).asReadOnly();
|
unreleasableBuffer(directBuffer(MAX_UNSIGNED_BYTE).writeZero(MAX_UNSIGNED_BYTE)).asReadOnly();
|
||||||
private int maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
|
private final int maxFrameSize = DEFAULT_MAX_FRAME_SIZE;
|
||||||
@Override
|
@Override
|
||||||
public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
public ChannelFuture writeData(ChannelHandlerContext ctx, int streamId, ByteBuf data,
|
||||||
int padding, boolean endStream, ChannelPromise promise) {
|
int padding, boolean endStream, ChannelPromise promise) {
|
||||||
|
@ -25,7 +25,7 @@ import io.netty.util.internal.ObjectUtil;
|
|||||||
|
|
||||||
public abstract class EmbeddedChannelWriteAccumulatingHandlerContext extends EmbeddedChannelHandlerContext {
|
public abstract class EmbeddedChannelWriteAccumulatingHandlerContext extends EmbeddedChannelHandlerContext {
|
||||||
private ByteBuf cumulation;
|
private ByteBuf cumulation;
|
||||||
private ByteToMessageDecoder.Cumulator cumulator;
|
private final ByteToMessageDecoder.Cumulator cumulator;
|
||||||
|
|
||||||
protected EmbeddedChannelWriteAccumulatingHandlerContext(ByteBufAllocator alloc, ChannelHandler handler,
|
protected EmbeddedChannelWriteAccumulatingHandlerContext(ByteBufAllocator alloc, ChannelHandler handler,
|
||||||
ByteToMessageDecoder.Cumulator writeCumulator) {
|
ByteToMessageDecoder.Cumulator writeCumulator) {
|
||||||
|
@ -98,7 +98,7 @@ public class NoPriorityByteDistributionBenchmark extends AbstractMicrobenchmark
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Http2StreamVisitor invocationVisitor = new Http2StreamVisitor() {
|
private final Http2StreamVisitor invocationVisitor = new Http2StreamVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public boolean visit(Http2Stream stream) throws Http2Exception {
|
public boolean visit(Http2Stream stream) throws Http2Exception {
|
||||||
// Restore the connection window.
|
// Restore the connection window.
|
||||||
|
@ -64,7 +64,7 @@ public class AbstractSharedExecutorMicrobenchmark extends AbstractMicrobenchmark
|
|||||||
*/
|
*/
|
||||||
public static final class DelegateHarnessExecutor extends AbstractEventExecutor {
|
public static final class DelegateHarnessExecutor extends AbstractEventExecutor {
|
||||||
private static EventLoop executor;
|
private static EventLoop executor;
|
||||||
private InternalLogger logger = InternalLoggerFactory.getInstance(DelegateHarnessExecutor.class);
|
private final InternalLogger logger = InternalLoggerFactory.getInstance(DelegateHarnessExecutor.class);
|
||||||
|
|
||||||
public DelegateHarnessExecutor(int maxThreads, String prefix) {
|
public DelegateHarnessExecutor(int maxThreads, String prefix) {
|
||||||
logger.debug("Using DelegateHarnessExecutor executor {}", this);
|
logger.debug("Using DelegateHarnessExecutor executor {}", this);
|
||||||
|
@ -191,7 +191,7 @@ class TestDnsServer extends DnsServer {
|
|||||||
@Override
|
@Override
|
||||||
public ProtocolDecoder getDecoder(IoSession session) {
|
public ProtocolDecoder getDecoder(IoSession session) {
|
||||||
return new ProtocolDecoderAdapter() {
|
return new ProtocolDecoderAdapter() {
|
||||||
private DnsMessageDecoder decoder = new DnsMessageDecoder();
|
private final DnsMessageDecoder decoder = new DnsMessageDecoder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws IOException {
|
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws IOException {
|
||||||
|
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
|
|||||||
public class AdaptiveRecvByteBufAllocatorTest {
|
public class AdaptiveRecvByteBufAllocatorTest {
|
||||||
@Mock
|
@Mock
|
||||||
private ChannelConfig config;
|
private ChannelConfig config;
|
||||||
private ByteBufAllocator alloc = UnpooledByteBufAllocator.DEFAULT;
|
private final ByteBufAllocator alloc = UnpooledByteBufAllocator.DEFAULT;
|
||||||
private RecvByteBufAllocator.ExtendedHandle handle;
|
private RecvByteBufAllocator.ExtendedHandle handle;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
|
@ -22,7 +22,7 @@ public class CustomChannelId implements ChannelId {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
private final int id;
|
||||||
|
|
||||||
CustomChannelId(int id) {
|
CustomChannelId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
Loading…
Reference in New Issue
Block a user