This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit fd6ddb6fc196ebb58432bca4b9ea63c143a1d41b
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Nov 24 16:45:56 2023 +0000

    Fix IDE warnings
    
    The volume of warnings is masking genuine issues elsewhere in the code
    base
---
 .../util/net/openssl/panama/OpenSSLContext.java    | 26 ++++++++++++++--------
 .../util/net/openssl/panama/OpenSSLEngine.java     |  2 +-
 .../util/net/openssl/panama/OpenSSLLibrary.java    |  3 +++
 .../net/openssl/panama/OpenSSLSessionContext.java  |  3 ++-
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java 
b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
index 1a70d72c63..74e60e9bba 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLContext.java
@@ -333,13 +333,15 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
                     openSSLCallbackPasswordFunctionDescriptor, contextArena);
             SSL_CTX_set_default_passwd_cb(sslCtx, openSSLCallbackPassword);
 
-            alpn = (negotiableProtocols != null && negotiableProtocols.size() 
> 0);
-            if (alpn) {
+            if (negotiableProtocols != null && negotiableProtocols.size() > 0) 
{
+                alpn = true;
                 negotiableProtocolsBytes = new 
ArrayList<>(negotiableProtocols.size() + 1);
                 for (String negotiableProtocol : negotiableProtocols) {
                     
negotiableProtocolsBytes.add(negotiableProtocol.getBytes(StandardCharsets.ISO_8859_1));
                 }
                 negotiableProtocolsBytes.add(HTTP_11_PROTOCOL);
+            } else {
+                alpn = false;
             }
 
             success = true;
@@ -737,7 +739,7 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
             // this is set so always set it in case an app is configured to
             // require it
             sessionContext.setSessionIdContext(DEFAULT_SESSION_ID_CONTEXT);
-            sslHostConfig.setOpenSslContext(state.sslCtx.address());
+            
sslHostConfig.setOpenSslContext(Long.valueOf(state.sslCtx.address()));
             initialized = true;
         } catch (Exception e) {
             log.warn(sm.getString("openssl.errorSSLCtxInit"), e);
@@ -754,7 +756,9 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
     }
 
     // DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)
-    public static MemorySegment openSSLCallbackTmpDH(MemorySegment ssl, int 
isExport, int keylength) {
+    @SuppressWarnings("deprecation")
+    public static MemorySegment openSSLCallbackTmpDH(MemorySegment ssl, 
@SuppressWarnings("unused") int isExport,
+            @SuppressWarnings("unused") int keylength) {
         var pkey = SSL_get_privatekey(ssl);
         int type = (MemorySegment.NULL.equals(pkey)) ? EVP_PKEY_NONE() : 
EVP_PKEY_base_id(pkey);
         /*
@@ -783,8 +787,8 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
 
     // int SSL_callback_alpn_select_proto(SSL* ssl, const unsigned char **out, 
unsigned char *outlen,
     //        const unsigned char *in, unsigned int inlen, void *arg)
-    public static int openSSLCallbackAlpnSelectProto(MemorySegment ssl, 
MemorySegment out, MemorySegment outlen,
-            MemorySegment in, int inlen, MemorySegment arg) {
+    public static int 
openSSLCallbackAlpnSelectProto(@SuppressWarnings("unused") MemorySegment ssl, 
MemorySegment out,
+            MemorySegment outlen, MemorySegment in, int inlen, MemorySegment 
arg) {
         ContextState state = getState(arg);
         if (state == null) {
             log.warn(sm.getString("context.noSSL", 
Long.valueOf(arg.address())));
@@ -950,7 +954,8 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
 
     private static ThreadLocal<String> callbackPasswordTheadLocal = new 
ThreadLocal<>();
 
-    public static int openSSLCallbackPassword(MemorySegment /*char **/ buf, 
int bufsiz, int verify, MemorySegment /*void **/ cb) {
+    public static int openSSLCallbackPassword(MemorySegment /*char **/ buf, 
int bufsiz,
+            @SuppressWarnings("unused") int verify, 
@SuppressWarnings("unused") MemorySegment /*void **/ cb) {
         if (log.isDebugEnabled()) {
             log.debug("Return password for certificate");
         }
@@ -972,6 +977,7 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
     }
 
 
+    @SuppressWarnings("deprecation")
     private boolean addCertificate(SSLHostConfigCertificate certificate, Arena 
localArena) throws Exception {
         int index = getCertificateIndex(certificate);
         // Load Server key and certificate
@@ -1185,7 +1191,8 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
                             curveNid = 0;
                         }
                         if (log.isDebugEnabled()) {
-                            log.debug(sm.getString("openssl.setECDHCurve", 
curveNid, certificate.getCertificateFile()));
+                            log.debug(sm.getString("openssl.setECDHCurve", 
Integer.valueOf(curveNid),
+                                    certificate.getCertificateFile()));
                         }
                         EC_GROUP_free(ecparams);
                     }
@@ -1314,7 +1321,8 @@ public class OpenSSLContext implements 
org.apache.tomcat.util.net.SSLContext {
                         if (SSL_CTX_set0_tmp_dh_pkey(state.sslCtx, pkey) <= 0) 
{
                             EVP_PKEY_free(pkey);
                         } else {
-                            
log.debug(sm.getString("openssl.setCustomDHParameters", numBits, 
certificate.getCertificateFile()));
+                            
log.debug(sm.getString("openssl.setCustomDHParameters", 
Integer.valueOf(numBits),
+                                    certificate.getCertificateFile()));
                         }
                     } else {
                         SSL_CTX_ctrl(state.sslCtx, SSL_CTRL_SET_DH_AUTO(), 1, 
MemorySegment.NULL);
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java 
b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
index bd23503956..2f20bd80cf 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLEngine.java
@@ -1172,7 +1172,7 @@ public final class OpenSSLEngine extends SSLEngine 
implements SSLUtil.ProtocolIn
         }
     }
 
-    public static void openSSLCallbackInfo(MemorySegment ssl, int where, int 
ret) {
+    public static void openSSLCallbackInfo(MemorySegment ssl, int where, 
@SuppressWarnings("unused") int ret) {
         EngineState state = getState(ssl);
         if (state == null) {
             log.warn(sm.getString("engine.noSSL", 
Long.valueOf(ssl.address())));
diff --git a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java 
b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
index 7d6fcc1808..418af902ff 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLLibrary.java
@@ -81,6 +81,7 @@ public class OpenSSLLibrary {
             if (OpenSSLStatus.isLibraryInitialized()) {
                 return;
             }
+            @SuppressWarnings("deprecation")
             long initParam = (OpenSSL_version_num() >= 0x3000000fL) ? 0 : 
OPENSSL_INIT_ENGINE_ALL_BUILTIN();
             OPENSSL_init_ssl(initParam, MemorySegment.NULL);
             OpenSSLStatus.setLibraryInitialized(true);
@@ -159,6 +160,7 @@ public class OpenSSLLibrary {
         }
     }
 
+    @SuppressWarnings("deprecation")
     public static void init() {
         synchronized (lock) {
 
@@ -327,6 +329,7 @@ public class OpenSSLLibrary {
         }
     }
 
+    @SuppressWarnings("deprecation")
     public static void destroy() {
         synchronized (lock) {
             if (!OpenSSLStatus.isInitialized()) {
diff --git 
a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java 
b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
index b14eb60d44..82ece562b0 100644
--- a/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
+++ b/java/org/apache/tomcat/util/net/openssl/panama/OpenSSLSessionContext.java
@@ -65,7 +65,8 @@ public class OpenSSLSessionContext implements 
SSLSessionContext {
             throw new 
IllegalArgumentException(sm.getString("sessionContext.nullTicketKeys"));
         }
         if (keys.length != TICKET_KEYS_SIZE) {
-            throw new 
IllegalArgumentException(sm.getString("sessionContext.invalidTicketKeysLength", 
keys.length));
+            throw new 
IllegalArgumentException(sm.getString("sessionContext.invalidTicketKeysLength",
+                    Integer.valueOf(keys.length)));
         }
         try (var memorySession = Arena.ofConfined()) {
             var array = memorySession.allocateFrom(ValueLayout.JAVA_BYTE, 
keys);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to