Skip to content

Commit 04070c1

Browse files
stepanchegslandelle
authored andcommitted
Unnecessary AtomicBoolean in inactive token attribute (AsyncHttpClient#1378)
1 parent 45fe7a6 commit 04070c1

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
@@ -17,8 +17,6 @@
1717
import io.netty.util.Attribute;
1818
import io.netty.util.AttributeKey;
1919

20-
import java.util.concurrent.atomic.AtomicBoolean;
21-
2220
import org.asynchttpclient.netty.DiscardEvent;
2321
import org.slf4j.Logger;
2422
import org.slf4j.LoggerFactory;
@@ -28,7 +26,9 @@ public class Channels {
2826
private static final Logger LOGGER = LoggerFactory.getLogger(Channels.class);
2927

3028
private static final AttributeKey<Object> DEFAULT_ATTRIBUTE = AttributeKey.valueOf("default");
31-
private static final AttributeKey<AtomicBoolean> INACTIVE_TOKEN_ATTRIBUTE = AttributeKey.valueOf("inactiveToken");
29+
private static final AttributeKey<Inactive> INACTIVE_TOKEN_ATTRIBUTE = AttributeKey.valueOf("inactiveToken");
30+
31+
private enum Inactive { INSTANCE }
3232

3333
public static Object getAttribute(Channel channel) {
3434
Attribute<Object> attr = channel.attr(DEFAULT_ATTRIBUTE);
@@ -48,11 +48,11 @@ public static boolean isChannelValid(Channel channel) {
4848
}
4949

5050
public static void setInactiveToken(Channel channel) {
51-
channel.attr(INACTIVE_TOKEN_ATTRIBUTE).set(new AtomicBoolean(true));
51+
channel.attr(INACTIVE_TOKEN_ATTRIBUTE).set(Inactive.INSTANCE);
5252
}
5353

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

5858
public static void silentlyCloseChannel(Channel channel) {

0 commit comments

Comments
 (0)