cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Avoiding NPEs in the logging feature given that headers can be non Strings on the out flow especially for JAXRS
Date Fri, 03 Mar 2017 14:53:35 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 86ce80a0c -> 9c53709b3


Avoiding NPEs in the logging feature given that headers can be non Strings on the out flow
especially for JAXRS


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9c53709b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9c53709b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9c53709b

Branch: refs/heads/3.1.x-fixes
Commit: 9c53709b39163bb2962990e88b50ba8961d8dc85
Parents: 86ce80a
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Mar 3 14:51:56 2017 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Mar 3 14:53:17 2017 +0000

----------------------------------------------------------------------
 .../cxf/ext/logging/event/DefaultLogEventMapper.java   | 13 ++++++++-----
 .../cxf/systest/jaxrs/JAXRSClientServerBookTest.java   |  4 +++-
 2 files changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9c53709b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
----------------------------------------------------------------------
diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
index abf3a06..78bbc7b 100644
--- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
+++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/event/DefaultLogEventMapper.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.ext.logging.event;
 
 import java.security.AccessController;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -126,17 +127,19 @@ public class DefaultLogEventMapper implements LogEventMapper {
     }
 
     private Map<String, String> getHeaders(Message message) {
-        Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+        Map<String, List<Object>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
         Map<String, String> result = new HashMap<>();
         if (headers == null) {
             return result;
         }
-        for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
+        for (Map.Entry<String, List<Object>> entry : headers.entrySet()) {
             if (entry.getValue().size() == 1) {
-                result.put(entry.getKey(), entry.getValue().get(0));
+                Object value = entry.getValue().get(0);
+                if (value != null) {
+                    result.put(entry.getKey(), value.toString());
+                }
             } else {
-                String[] valueAr = entry.getValue().toArray(new String[] {});
-                result.put(entry.getKey(), valueAr.toString());
+                result.put(entry.getKey(), Arrays.deepToString(entry.getValue().toArray()));
             }
         }
         return result;

http://git-wip-us.apache.org/repos/asf/cxf/blob/9c53709b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
index b19dc6b..f7e78b7 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
@@ -1078,8 +1078,10 @@ public class JAXRSClientServerBookTest extends AbstractBusClientServerTestBase
{
     
     @Test 
     public void testAddBookProxyResponse() {
-        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
         Book b = new Book("CXF rocks", 123L);
+        
+        System.out.println(Arrays.deepToString(Arrays.asList(b, b).toArray()));
+        BookStore store = JAXRSClientFactory.create("http://localhost:" + PORT, BookStore.class);
         Response r = store.addBook(b);
         assertNotNull(r);
         InputStream is = (InputStream)r.getEntity();


Mime
View raw message