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-6882] Avoiding potential NPE
Date Tue, 06 Dec 2016 11:10:53 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 08e8316aa -> 7d344ae7e


[CXF-6882] Avoiding potential NPE


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

Branch: refs/heads/master
Commit: 7d344ae7ed882a4347d0f8775744646e0013aca5
Parents: 08e8316
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Dec 6 11:10:37 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Dec 6 11:10:37 2016 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java    | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7d344ae7/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
index d4ab508..ac9f8ba 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/nio/NioMessageBodyWriter.java
@@ -43,14 +43,14 @@ public class NioMessageBodyWriter implements MessageBodyWriter<NioWriteEntity>
{
 
     @Override
     public boolean isWriteable(Class<?> cls, Type type, Annotation[] anns, MediaType
mt) {
-        return NioWriteEntity.class.isAssignableFrom(cls);
+        return NioWriteEntity.class.isAssignableFrom(cls) && getContinuationProvider()
!= null;
     }
     
     @Override
     public void writeTo(NioWriteEntity entity, Class<?> cls, Type t, Annotation[] anns,
             MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)

                 throws IOException, WebApplicationException {
-        Continuation cont = getContinuation();
+        Continuation cont = getContinuationProvider().getContinuation();
         NioWriteListenerImpl listener = new NioWriteListenerImpl(cont, entity, os);
         Message m = JAXRSUtils.getCurrentMessage();
         m.put(WriteListener.class, listener);
@@ -65,10 +65,8 @@ public class NioMessageBodyWriter implements MessageBodyWriter<NioWriteEntity>
{
             MediaType mediaType) {
         return -1;
     }
-    private Continuation getContinuation() {
-        ContinuationProvider provider = 
-            (ContinuationProvider)JAXRSUtils.getCurrentMessage().getExchange()
+    private ContinuationProvider getContinuationProvider() {
+        return (ContinuationProvider)JAXRSUtils.getCurrentMessage().getExchange()
             .getInMessage().get(ContinuationProvider.class.getName());
-        return provider.getContinuation();
     }
 }


Mime
View raw message