File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
client/src/main/java/org/asynchttpclient/netty/channel Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 17
17
import io .netty .util .Attribute ;
18
18
import io .netty .util .AttributeKey ;
19
19
20
- import java .util .concurrent .atomic .AtomicBoolean ;
21
-
22
20
import org .asynchttpclient .netty .DiscardEvent ;
23
21
import org .slf4j .Logger ;
24
22
import org .slf4j .LoggerFactory ;
@@ -28,7 +26,9 @@ public class Channels {
28
26
private static final Logger LOGGER = LoggerFactory .getLogger (Channels .class );
29
27
30
28
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 }
32
32
33
33
public static Object getAttribute (Channel channel ) {
34
34
Attribute <Object > attr = channel .attr (DEFAULT_ATTRIBUTE );
@@ -48,11 +48,11 @@ public static boolean isChannelValid(Channel channel) {
48
48
}
49
49
50
50
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 );
52
52
}
53
53
54
54
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 ;
56
56
}
57
57
58
58
public static void silentlyCloseChannel (Channel channel ) {
You can’t perform that action at this time.
0 commit comments