You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2022/09/14 15:54:38 UTC

[httpcomponents-core] 01/01: Fixed deprecation and varargs warnings

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

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 7624596b5425623a5f746c7f05044b62f42aedbd
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Wed Sep 14 16:05:41 2022 +0200

    Fixed deprecation and varargs warnings
---
 .../http2/ssl/ConscryptServerTlsStrategy.java      | 15 ++++++-------
 .../hc/core5/http2/ssl/H2ServerTlsStrategy.java    | 15 ++++++-------
 .../hc/core5/testing/nio/TLSIntegrationTest.java   |  4 ++++
 .../java/org/apache/hc/core5/http/ssl/TLSTest.java |  2 +-
 .../apache/hc/core5/http/ssl/TestTlsCiphers.java   |  2 +-
 .../org/apache/hc/core5/util/TestLangUtils.java    | 25 ----------------------
 6 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/ConscryptServerTlsStrategy.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/ConscryptServerTlsStrategy.java
index abacfeb83..d5557580b 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/ConscryptServerTlsStrategy.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/ConscryptServerTlsStrategy.java
@@ -33,8 +33,6 @@ import javax.net.ssl.SSLContext;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.nio.ssl.FixedPortStrategy;
-import org.apache.hc.core5.http.nio.ssl.SecurePortStrategy;
 import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
 import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
@@ -55,7 +53,7 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
 
     private final SSLContext sslContext;
     @SuppressWarnings("deprecation")
-    private final SecurePortStrategy securePortStrategy;
+    private final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy;
     private final SSLBufferMode sslBufferMode;
     private final SSLSessionInitializer initializer;
     private final SSLSessionVerifier verifier;
@@ -66,7 +64,7 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public ConscryptServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLBufferMode sslBufferMode,
             final SSLSessionInitializer initializer,
             final SSLSessionVerifier verifier) {
@@ -83,7 +81,7 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public ConscryptServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLSessionInitializer initializer,
             final SSLSessionVerifier verifier) {
         this(sslContext, securePortStrategy, null, initializer, verifier);
@@ -95,7 +93,7 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public ConscryptServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLSessionVerifier verifier) {
         this(sslContext, securePortStrategy, null, null, verifier);
     }
@@ -104,7 +102,8 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
      * @deprecated Use {@link ConscryptServerTlsStrategy#ConscryptServerTlsStrategy(SSLContext)}
      */
     @Deprecated
-    public ConscryptServerTlsStrategy(final SSLContext sslContext, final SecurePortStrategy securePortStrategy) {
+    public ConscryptServerTlsStrategy(final SSLContext sslContext,
+                                      final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy) {
         this(sslContext, securePortStrategy, null, null, null);
     }
 
@@ -113,7 +112,7 @@ public class ConscryptServerTlsStrategy implements TlsStrategy {
      */
     @Deprecated
     public ConscryptServerTlsStrategy(final SSLContext sslContext, final int... securePorts) {
-        this(sslContext, new FixedPortStrategy(securePorts));
+        this(sslContext, new org.apache.hc.core5.http.nio.ssl.FixedPortStrategy(securePorts));
     }
 
     public ConscryptServerTlsStrategy(
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java
index e850eddd5..9b9a13caf 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/ssl/H2ServerTlsStrategy.java
@@ -33,8 +33,6 @@ import javax.net.ssl.SSLContext;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.nio.ssl.FixedPortStrategy;
-import org.apache.hc.core5.http.nio.ssl.SecurePortStrategy;
 import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
 import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
@@ -55,7 +53,7 @@ public class H2ServerTlsStrategy implements TlsStrategy {
 
     private final SSLContext sslContext;
     @SuppressWarnings("deprecation")
-    private final SecurePortStrategy securePortStrategy;
+    private final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy;
     private final SSLBufferMode sslBufferMode;
     private final SSLSessionInitializer initializer;
     private final SSLSessionVerifier verifier;
@@ -66,7 +64,7 @@ public class H2ServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public H2ServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLBufferMode sslBufferMode,
             final SSLSessionInitializer initializer,
             final SSLSessionVerifier verifier) {
@@ -83,7 +81,7 @@ public class H2ServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public H2ServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLSessionInitializer initializer,
             final SSLSessionVerifier verifier) {
         this(sslContext, securePortStrategy, null, initializer, verifier);
@@ -95,7 +93,7 @@ public class H2ServerTlsStrategy implements TlsStrategy {
     @Deprecated
     public H2ServerTlsStrategy(
             final SSLContext sslContext,
-            final SecurePortStrategy securePortStrategy,
+            final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy,
             final SSLSessionVerifier verifier) {
         this(sslContext, securePortStrategy, null, null, verifier);
     }
@@ -104,7 +102,8 @@ public class H2ServerTlsStrategy implements TlsStrategy {
      * @deprecated Use {@link H2ServerTlsStrategy#H2ServerTlsStrategy(SSLContext)}
      */
     @Deprecated
-    public H2ServerTlsStrategy(final SSLContext sslContext, final SecurePortStrategy securePortStrategy) {
+    public H2ServerTlsStrategy(final SSLContext sslContext,
+                               final org.apache.hc.core5.http.nio.ssl.SecurePortStrategy securePortStrategy) {
         this(sslContext, securePortStrategy, null, null, null);
     }
 
@@ -113,7 +112,7 @@ public class H2ServerTlsStrategy implements TlsStrategy {
      */
     @Deprecated
     public H2ServerTlsStrategy(final int... securePorts) {
-        this(SSLContexts.createSystemDefault(), new FixedPortStrategy(securePorts));
+        this(SSLContexts.createSystemDefault(), new org.apache.hc.core5.http.nio.ssl.FixedPortStrategy(securePorts));
     }
 
     public H2ServerTlsStrategy(
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
index 247f2c12f..09c401cae 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TLSIntegrationTest.java
@@ -401,6 +401,10 @@ public class TLSIntegrationTest {
                     TlsSupport.enforceStrongSecurity(initializer), verifier, handshakeTimeout, callback);
         }
 
+        /**
+         * @deprecated do not use.
+         */
+        @Deprecated
         @Override
         public boolean upgrade(
                 final TransportSecurityLayer tlsSession,
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TLSTest.java b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TLSTest.java
index 72ebb829d..e9a2730a4 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TLSTest.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TLSTest.java
@@ -69,7 +69,7 @@ class TLSTest {
 
     @Test
     void excludeWeakNull() {
-        assertNull((TLS.excludeWeak(null)));
+        assertNull((TLS.excludeWeak((String[]) null)));
     }
 
     @Test
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsCiphers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsCiphers.java
index eeec5d7ec..8313b9e39 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsCiphers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/ssl/TestTlsCiphers.java
@@ -125,7 +125,7 @@ public class TestTlsCiphers {
 
     @Test
     void excludeWeakNull(){
-        Assertions.assertNull(TlsCiphers.excludeWeak(null));
+        Assertions.assertNull(TlsCiphers.excludeWeak((String[]) null));
     }
 
 }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java
index 5a0f2072e..c302b56bd 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java
@@ -27,8 +27,6 @@
 
 package org.apache.hc.core5.util;
 
-import java.util.Objects;
-
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -64,27 +62,4 @@ public class TestLangUtils {
         Assertions.assertEquals(h2, h4);
     }
 
-    @Test
-    public void testBasicEquality() {
-        Assertions.assertTrue(LangUtils.equals(null, null));
-        Assertions.assertFalse(Objects.equals(null, "abc"));
-        Assertions.assertFalse(Objects.equals("abc", null));
-        Assertions.assertTrue(Objects.equals("abc", "abc"));
-    }
-
-    @Test
-    public void testArrayEquals() {
-        Assertions.assertFalse(LangUtils.equals(null, new Object[] {}));
-        Assertions.assertFalse(LangUtils.equals(new Object[] {}, null));
-        Assertions.assertTrue(LangUtils.equals(new Object[] {}, new Object[] {}));
-        Assertions.assertFalse(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1)}));
-        Assertions.assertFalse(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1), Integer.valueOf(3)}));
-        Assertions.assertTrue(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)}));
-    }
 }