You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2020/05/22 09:37:38 UTC

[cxf] branch master updated (5633467 -> 0a961b1)

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

buhhunyx pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 5633467  Updating Netty to 4.1.50
     new 83dfaba  cxf-rt-transports-http-netty-client: speedup test
     new 0a961b1  cxf-rt-rs-client: fix warn and minor improvements

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/cxf/jaxrs/client/AbstractClient.java    | 35 +++++++---------------
 .../org/apache/cxf/jaxrs/client/WebClientTest.java |  7 +++++
 .../http/netty/client/NettyHttpConduitTest.java    |  3 +-
 3 files changed, 18 insertions(+), 27 deletions(-)


[cxf] 01/02: cxf-rt-transports-http-netty-client: speedup test

Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 83dfabaf8773a355a867e3aa93e30989a1bbb7ba
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Fri May 22 12:35:20 2020 +0300

    cxf-rt-transports-http-netty-client: speedup test
---
 .../apache/cxf/transport/http/netty/client/NettyHttpConduitTest.java   | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitTest.java b/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitTest.java
index 70ea35b..7077842 100644
--- a/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitTest.java
+++ b/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitTest.java
@@ -261,7 +261,7 @@ public class NettyHttpConduitTest extends AbstractBusClientServerTestBase {
 
     @Test
     public void testCallAsyncCallbackInvokedOnlyOnce() throws Exception {
-        updateAddressPort(g, PORT_INV);
+        updateAddressPort(g, PORT);
         int repeat = 20;
         final AtomicInteger count = new AtomicInteger(0);
         for (int i = 0; i < repeat; i++) {
@@ -274,7 +274,6 @@ public class NettyHttpConduitTest extends AbstractBusClientServerTestBase {
             } catch (Exception e) {
             }
         }
-        Thread.sleep(1000);
         assertEquals("Callback should be invoked only once per request", repeat, count.intValue());
     }
 }


[cxf] 02/02: cxf-rt-rs-client: fix warn and minor improvements

Posted by bu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 0a961b125c0f81fc8d130ad99cc2c986e0dcdfb0
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Fri May 22 12:36:54 2020 +0300

    cxf-rt-rs-client: fix warn and minor improvements
---
 .../apache/cxf/jaxrs/client/AbstractClient.java    | 35 +++++++---------------
 .../org/apache/cxf/jaxrs/client/WebClientTest.java |  7 +++++
 2 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index 511dba4..d398cbb 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -26,7 +26,6 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
-import java.net.HttpURLConnection;
 import java.net.URI;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -456,8 +455,8 @@ public abstract class AbstractClient implements Client {
                 entry.getValue().forEach(valObject -> {
                     if (splitHeaders && valObject instanceof String) {
                         String val = (String) valObject;
-                        String[] values;
-                        if (val.length() == 0) {
+                        final String[] values;
+                        if (val.isEmpty()) {
                             values = new String[]{""};
                         } else if (val.charAt(0) == '"' && val.charAt(val.length() - 1) == '"') {
                             // if the value starts with a quote and ends with a quote, we do a best
@@ -470,7 +469,7 @@ public abstract class AbstractClient implements Client {
                         }
                         for (String s : values) {
                             String theValue = s.trim();
-                            if (theValue.length() > 0) {
+                            if (!theValue.isEmpty()) {
                                 currentResponseBuilder.header(entry.getKey(), theValue);
                             }
                         }
@@ -766,7 +765,7 @@ public abstract class AbstractClient implements Client {
             } else {
                 addMatrixOrQueryToBuilder(ub, paramName, pt, pValues);
             }
-        } else {
+        } else if (pValues != null && pValues.length > 0) {
             Object pValue = pValues[0];
             MultivaluedMap<String, Object> values = InjectionUtils.extractValuesFromBean(pValue, "");
             values.forEach((key, value) -> {
@@ -847,19 +846,6 @@ public abstract class AbstractClient implements Client {
         throw new ProcessingException(errorMessage, actualEx);
     }
 
-    protected static void setAllHeaders(MultivaluedMap<String, String> headers, HttpURLConnection conn) {
-        headers.forEach((key, value) -> {
-            StringBuilder b = new StringBuilder();
-            for (int i = 0; i < value.size(); i++) {
-                b.append(value.get(i));
-                if (i + 1 < value.size()) {
-                    b.append(',');
-                }
-            }
-            conn.setRequestProperty(key, b.toString());
-        });
-    }
-
     protected String[] parseQuotedHeaderValue(String originalValue) {
         // this algorithm isn't perfect; see CXF-3518 for further discussion.
         List<String> results = new ArrayList<>();
@@ -868,10 +854,10 @@ public abstract class AbstractClient implements Client {
         int lastIndex = chars.length - 1;
 
         boolean quote = false;
-        StringBuilder sb = new StringBuilder();
+        final StringBuilder sb = new StringBuilder();
 
         for (int pos = 0; pos <= lastIndex; pos++) {
-            char c = chars[pos];
+            final char c = chars[pos];
             if (pos == lastIndex) {
                 sb.append(c);
                 results.add(sb.toString());
@@ -885,8 +871,7 @@ public abstract class AbstractClient implements Client {
                     if (quote) {
                         pos++;
                         if (pos <= lastIndex) {
-                            c = chars[pos];
-                            sb.append(c);
+                            sb.append(chars[pos]);
                         }
                         if (pos == lastIndex) {
                             results.add(sb.toString());
@@ -900,7 +885,7 @@ public abstract class AbstractClient implements Client {
                         sb.append(c);
                     } else {
                         results.add(sb.toString());
-                        sb = new StringBuilder();
+                        sb.setLength(0);
                     }
                     break;
                 default:
@@ -1071,7 +1056,7 @@ public abstract class AbstractClient implements Client {
     protected Object checkIfBodyEmpty(Object body, String contentType) {
         //CHECKSTYLE:OFF
         if (body != null
-            && (body.getClass() == String.class && ((String)body).length() == 0
+            && (body.getClass() == String.class && ((String)body).isEmpty()
             || body.getClass() == Form.class && ((Form)body).asMap().isEmpty()
             || Map.class.isAssignableFrom(body.getClass()) && ((Map<?, ?>)body).isEmpty()
                 && !MediaType.APPLICATION_JSON.equals(contentType)
@@ -1210,7 +1195,7 @@ public abstract class AbstractClient implements Client {
         }
     }
 
-    protected abstract class AbstractBodyWriter extends AbstractOutDatabindingInterceptor {
+    protected abstract static class AbstractBodyWriter extends AbstractOutDatabindingInterceptor {
 
         public AbstractBodyWriter() {
             super(Phase.WRITE);
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
index 150e696..10830d3 100644
--- a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
@@ -141,6 +141,13 @@ public class WebClientTest {
     }
 
     @Test
+    public void testEmptyQueryKey() {
+        WebClient wc = WebClient.create("http://foo");
+        wc.query("");
+        assertEquals("http://foo", wc.getCurrentURI().toString());
+    }
+
+    @Test
     public void testForward() {
         WebClient wc = WebClient.create("http://foo");
         wc.to("http://foo/bar", true);