cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7429] Preventing NPE
Date Mon, 26 Jun 2017 11:31:42 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 4ae1b339d -> 5585ad569


[CXF-7429] Preventing NPE


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

Branch: refs/heads/3.1.x-fixes
Commit: 5585ad5691fbbe8cb0f74f3ebf670edd4a2eecc8
Parents: 4ae1b33
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon Jun 26 12:06:55 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Jun 26 12:31:21 2017 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/WriterInterceptorMBW.java    | 32 ++++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5585ad56/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java
index 053ac69..dfa02a6 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorMBW.java
@@ -57,11 +57,6 @@ public class WriterInterceptorMBW implements WriterInterceptor {
     @SuppressWarnings("unchecked")
     @Override
     public void aroundWriteTo(WriterInterceptorContext c) throws IOException, WebApplicationException
{
-        
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
-        }
-        
         MultivaluedMap<String, Object> headers = c.getHeaders();
         Object mtObject = headers.getFirst(HttpHeaders.CONTENT_TYPE);
         MediaType entityMt = mtObject == null ? c.getMediaType() : JAXRSUtils.toMediaType(mtObject.toString());
@@ -77,21 +72,26 @@ public class WriterInterceptorMBW implements WriterInterceptor {
             
             writer = (MessageBodyWriter<Object>)ProviderFactory.getInstance(m)
                 .createMessageBodyWriter(entityCls, entityType, entityAnns, entityMt, m);
-            if (writer == null) {
-                String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_WRITER",
entityCls, entityMt);
-                throw new ProcessingException(errorMessage);
-            }
+        }
+
+        if (writer == null) {
+            String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_WRITER", entityCls,
entityMt);
+            throw new ProcessingException(errorMessage);
         }
         
         HttpUtils.convertHeaderValuesToString(headers, true);
+
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
+        }
         
-        writer.writeTo(c.getEntity(), 
-                       c.getType(), 
-                       c.getGenericType(), 
-                       c.getAnnotations(), 
-                       entityMt, 
-                       headers, 
-                       c.getOutputStream());
+        writer.writeTo(c.getEntity(),
+                       c.getType(),
+                       c.getGenericType(),
+                       c.getAnnotations(),
+                       entityMt,
+                       headers,
+                       c.getOutputStream()); 
     }
     
     


Mime
View raw message