Skip to content

Commit a80a011

Browse files
stepanchegslandelle
authored andcommitted
Unnecessary AtomicBoolean in inactive token attribute (AsyncHttpClient#1378)
1 parent d735d7b commit a80a011

File tree

1 file changed

+5
-5
lines changed
  • client/src/main/java/org/asynchttpclient/netty/channel

1 file changed

+5
-5
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/Channels.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
package org.asynchttpclient.netty.channel;
1515

16-
import java.util.concurrent.atomic.AtomicBoolean;
17-
1816
import io.netty.channel.Channel;
1917
import io.netty.channel.ChannelId;
2018
import io.netty.channel.DefaultChannelId;
@@ -31,7 +29,9 @@ public class Channels {
3129

3230
private static final AttributeKey<Object> DEFAULT_ATTRIBUTE = AttributeKey.valueOf("default");
3331
private static final AttributeKey<ChannelId> CHANNEL_ID_ATTRIBUTE = AttributeKey.valueOf("channelId");
34-
private static final AttributeKey<AtomicBoolean> INACTIVE_TOKEN_ATTRIBUTE = AttributeKey.valueOf("inactiveToken");
32+
private static final AttributeKey<Inactive> INACTIVE_TOKEN_ATTRIBUTE = AttributeKey.valueOf("inactiveToken");
33+
34+
private enum Inactive { INSTANCE }
3535

3636
public static Object getAttribute(Channel channel) {
3737
Attribute<Object> attr = channel.attr(DEFAULT_ATTRIBUTE);
@@ -51,11 +51,11 @@ public static boolean isChannelValid(Channel channel) {
5151
}
5252

5353
public static void setInactiveToken(Channel channel) {
54-
channel.attr(INACTIVE_TOKEN_ATTRIBUTE).set(new AtomicBoolean(true));
54+
channel.attr(INACTIVE_TOKEN_ATTRIBUTE).set(Inactive.INSTANCE);
5555
}
5656

5757
public static boolean getInactiveToken(Channel channel) {
58-
return channel != null && channel.attr(INACTIVE_TOKEN_ATTRIBUTE).get().getAndSet(false);
58+
return channel != null && channel.attr(INACTIVE_TOKEN_ATTRIBUTE).getAndSet(null) != null;
5959
}
6060

6161
public static ChannelId getChannelId(Channel channel) {

0 commit comments

Comments
 (0)