Skip to content

Commit

Permalink
Adding 'final' keyword for private fields where possible
Browse files Browse the repository at this point in the history
Motivation

Missing 'final' keyword for fields

Modifications

Add 'final' for fields where possible

Result

More safe and consistent code
  • Loading branch information
fenik17 authored and normanmaurer committed Feb 14, 2017
1 parent 974a251 commit 0cf3f54
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ByteBufInputStream extends InputStream implements DataInput {
* However in future releases ownership should always be transferred and callers of this class should call
* {@link ReferenceCounted#retain()} if necessary.
*/
private boolean releaseOnClose;
private final boolean releaseOnClose;

/**
* Creates a new stream which reads data from the specified {@code buffer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public final class DefaultHttp2GoAwayFrame extends DefaultByteBufHolder implements Http2GoAwayFrame {

private final long errorCode;
private int lastStreamId;
private final int lastStreamId;
private int extraStreamIds;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public final class FixedRedisMessagePool implements RedisMessagePool {
public static final FixedRedisMessagePool INSTANCE = new FixedRedisMessagePool();

// internal caches.
private Map<ByteBuf, SimpleStringRedisMessage> byteBufToSimpleStrings;
private Map<String, SimpleStringRedisMessage> stringToSimpleStrings;
private Map<ByteBuf, ErrorRedisMessage> byteBufToErrors;
private Map<String, ErrorRedisMessage> stringToErrors;
private Map<ByteBuf, IntegerRedisMessage> byteBufToIntegers;
private LongObjectMap<IntegerRedisMessage> longToIntegers;
private LongObjectMap<byte[]> longToByteBufs;
private final Map<ByteBuf, SimpleStringRedisMessage> byteBufToSimpleStrings;
private final Map<String, SimpleStringRedisMessage> stringToSimpleStrings;
private final Map<ByteBuf, ErrorRedisMessage> byteBufToErrors;
private final Map<String, ErrorRedisMessage> stringToErrors;
private final Map<ByteBuf, IntegerRedisMessage> byteBufToIntegers;
private final LongObjectMap<IntegerRedisMessage> longToIntegers;
private final LongObjectMap<byte[]> longToByteBufs;

/**
* Creates a {@link FixedRedisMessagePool} instance.
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/io/netty/util/ConstantPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class ConstantPool<T extends Constant<T>> {

private final ConcurrentMap<String, T> constants = PlatformDependent.newConcurrentHashMap();

private AtomicInteger nextId = new AtomicInteger(1);
private final AtomicInteger nextId = new AtomicInteger(1);

/**
* Shortcut of {@link #valueOf(String) valueOf(firstNameComponent.getName() + "#" + secondNameComponent)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Reads the first {@link Http2Settings} object and notifies a {@link io.netty.channel.ChannelPromise}
*/
public class Http2SettingsHandler extends SimpleChannelInboundHandler<Http2Settings> {
private ChannelPromise promise;
private final ChannelPromise promise;

/**
* Create new instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class HttpResponseHandler extends SimpleChannelInboundHandler<FullHttpResponse> {

private Map<Integer, Entry<ChannelFuture, ChannelPromise>> streamidPromiseMap;
private final Map<Integer, Entry<ChannelFuture, ChannelPromise>> streamidPromiseMap;

public HttpResponseHandler() {
// Use a concurrent map because we add and iterate from the main thread (just for the purposes of the example),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static int defaultProcessId() {
}

private final byte[] data;
private int hashCode;
private final int hashCode;

private transient String shortValue;
private transient String longValue;
Expand Down

0 comments on commit 0cf3f54

Please sign in to comment.