From 911d0b687825351d05b53d42d2f1b8b5e682ac7f Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Fri, 29 Jul 2022 17:21:08 +0300 Subject: [PATCH] Use pattern for the field name when checking the classpath (#2411) In preparation for better GraalVM support --- .../reactor/netty/resources/DefaultLoopEpoll.java | 8 ++++---- .../reactor/netty/resources/DefaultLoopIOUring.java | 8 ++++---- .../reactor/netty/resources/DefaultLoopKQueue.java | 8 ++++---- .../netty/resources/DefaultLoopNativeDetector.java | 8 ++++---- .../netty/http/server/HAProxyMessageReader.java | 12 ++++++------ .../java/reactor/netty/http/server/HttpServer.java | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopEpoll.java b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopEpoll.java index f74c4f0623..bac23d7656 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopEpoll.java +++ b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopEpoll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2011-2022 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,7 @@ public boolean supportGroup(EventLoopGroup group) { static final Logger log = Loggers.getLogger(DefaultLoopEpoll.class); - static final boolean epoll; + static final boolean isEpollAvailable; static { boolean epollCheck = false; @@ -114,9 +114,9 @@ public boolean supportGroup(EventLoopGroup group) { catch (ClassNotFoundException cnfe) { // noop } - epoll = epollCheck; + isEpollAvailable = epollCheck; if (log.isDebugEnabled()) { - log.debug("Default Epoll support : " + epoll); + log.debug("Default Epoll support : " + isEpollAvailable); } } } diff --git a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopIOUring.java b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopIOUring.java index ac3a0423ab..448f0eadbb 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopIOUring.java +++ b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopIOUring.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2020-2022 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ public boolean supportGroup(EventLoopGroup group) { static final Logger log = Loggers.getLogger(DefaultLoopIOUring.class); - static final boolean ioUring; + static final boolean isIoUringAvailable; static { boolean ioUringCheck = false; @@ -98,9 +98,9 @@ public boolean supportGroup(EventLoopGroup group) { catch (ClassNotFoundException cnfe) { // noop } - ioUring = ioUringCheck; + isIoUringAvailable = ioUringCheck; if (log.isDebugEnabled()) { - log.debug("Default io_uring support : " + ioUring); + log.debug("Default io_uring support : " + isIoUringAvailable); } } } diff --git a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopKQueue.java b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopKQueue.java index 8f1d06f357..a445c1a49e 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopKQueue.java +++ b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopKQueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2018-2022 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,7 +102,7 @@ public boolean supportGroup(EventLoopGroup group) { static final Logger log = Loggers.getLogger(DefaultLoopKQueue.class); - static final boolean kqueue; + static final boolean isKqueueAvailable; static { boolean kqueueCheck = false; @@ -113,9 +113,9 @@ public boolean supportGroup(EventLoopGroup group) { catch (ClassNotFoundException cnfe) { // noop } - kqueue = kqueueCheck; + isKqueueAvailable = kqueueCheck; if (log.isDebugEnabled()) { - log.debug("Default KQueue support : " + kqueue); + log.debug("Default KQueue support : " + isKqueueAvailable); } } } diff --git a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopNativeDetector.java b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopNativeDetector.java index ac2e637c3f..cd7a05d90d 100644 --- a/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopNativeDetector.java +++ b/reactor-netty-core/src/main/java/reactor/netty/resources/DefaultLoopNativeDetector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2018-2022 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,13 +29,13 @@ final class DefaultLoopNativeDetector { static { NIO = new DefaultLoopNIO(); - if (DefaultLoopIOUring.ioUring) { + if (DefaultLoopIOUring.isIoUringAvailable) { INSTANCE = new DefaultLoopIOUring(); } - else if (DefaultLoopEpoll.epoll) { + else if (DefaultLoopEpoll.isEpollAvailable) { INSTANCE = new DefaultLoopEpoll(); } - else if (DefaultLoopKQueue.kqueue) { + else if (DefaultLoopKQueue.isKqueueAvailable) { INSTANCE = new DefaultLoopKQueue(); } else { diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/HAProxyMessageReader.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/HAProxyMessageReader.java index 364de0f4e6..102848793d 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/HAProxyMessageReader.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/HAProxyMessageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021 VMware, Inc. or its affiliates, All Rights Reserved. + * Copyright (c) 2019-2022 VMware, Inc. or its affiliates, All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ final class HAProxyMessageReader extends ChannelInboundHandlerAdapter { private static final AttributeKey REMOTE_ADDRESS_FROM_PROXY_PROTOCOL = AttributeKey.valueOf("remoteAddressFromProxyProtocol"); - private static final boolean hasProxyProtocol; + private static final boolean isProxyProtocolAvailable; static { boolean proxyProtocolCheck = true; @@ -47,16 +47,16 @@ final class HAProxyMessageReader extends ChannelInboundHandlerAdapter { catch (ClassNotFoundException cnfe) { proxyProtocolCheck = false; } - hasProxyProtocol = proxyProtocolCheck; + isProxyProtocolAvailable = proxyProtocolCheck; } - static boolean hasProxyProtocol() { - return hasProxyProtocol; + static boolean isProxyProtocolAvailable() { + return isProxyProtocolAvailable; } @Nullable static SocketAddress resolveRemoteAddressFromProxyProtocol(Channel channel) { - if (HAProxyMessageReader.hasProxyProtocol()) { + if (HAProxyMessageReader.isProxyProtocolAvailable()) { return channel.attr(REMOTE_ADDRESS_FROM_PROXY_PROTOCOL).getAndSet(null); } diff --git a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServer.java b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServer.java index 03ed81563f..a75412a8b6 100644 --- a/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServer.java +++ b/reactor-netty-http/src/main/java/reactor/netty/http/server/HttpServer.java @@ -689,7 +689,7 @@ public final HttpServer proxyProtocol(ProxyProtocolSupportType proxyProtocolSupp } if (proxyProtocolSupportType == ProxyProtocolSupportType.ON || proxyProtocolSupportType == ProxyProtocolSupportType.AUTO) { - if (!HAProxyMessageReader.hasProxyProtocol()) { + if (!HAProxyMessageReader.isProxyProtocolAvailable()) { throw new UnsupportedOperationException( "To enable proxyProtocol, you must add the dependency `io.netty:netty-codec-haproxy`" + " to the class path first");