cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [3/3] cxf git commit: [CXF-6845] More non-null checks
Date Tue, 29 Mar 2016 10:35:47 GMT
[CXF-6845] More non-null checks


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

Branch: refs/heads/master
Commit: b34ec6ea11bda11a6072574d30df36b4c72eb581
Parents: 19c1279
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Tue Mar 29 12:35:37 2016 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Tue Mar 29 12:35:37 2016 +0200

----------------------------------------------------------------------
 .../org/apache/cxf/message/MessageUtils.java    | 29 ++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b34ec6ea/core/src/main/java/org/apache/cxf/message/MessageUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index d964070..b7f8137 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -42,9 +42,10 @@ public final class MessageUtils {
      * @return true if the message direction is outbound
      */
     public static boolean isOutbound(Message message) {
-        Exchange exchange = message.getExchange();
-        return exchange != null
-               && (message == exchange.getOutMessage() || message == exchange.getOutFaultMessage());
+        return message != null 
+               && message.getExchange() != null
+               && (message == message.getExchange().getOutMessage() 
+                || message == message.getExchange().getOutFaultMessage());
     }
 
     /**
@@ -88,8 +89,11 @@ public final class MessageUtils {
      * @return true if the current messaging role is that of requestor
      */
     public static boolean isRequestor(Message message) {
-        Boolean requestor = (Boolean)message.get(Message.REQUESTOR_ROLE);
-        return requestor != null && requestor.booleanValue();
+        if (message != null) {
+            Boolean requestor = (Boolean) message.get(Message.REQUESTOR_ROLE);
+            return requestor != null && requestor;
+        }
+        return false;
     }
     
     /**
@@ -99,7 +103,7 @@ public final class MessageUtils {
      * @return true if the current messags is a partial response
      */
     public static boolean isPartialResponse(Message message) {
-        return Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE));
+        return message != null && Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE));
     }
     
     /**
@@ -110,7 +114,7 @@ public final class MessageUtils {
      * @return true if the current messags is a partial empty response
      */
     public static boolean isEmptyPartialResponse(Message message) {
-        return Boolean.TRUE.equals(message.get(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE));
+        return message != null && Boolean.TRUE.equals(message.get(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE));
     }
 
     /**
@@ -134,9 +138,12 @@ public final class MessageUtils {
     }
     
     public static Object getContextualProperty(Message m, String propPreferred, String propDefault)
{
-        Object prop = m.getContextualProperty(propPreferred);
-        if (prop == null && propDefault != null) {
-            prop = m.getContextualProperty(propDefault);
+        Object prop = null;
+        if (m != null) {
+            prop = m.getContextualProperty(propPreferred);
+            if (prop == null && propDefault != null) {
+                prop = m.getContextualProperty(propDefault);
+            }
         }
         return prop;
     }
@@ -145,7 +152,7 @@ public final class MessageUtils {
      * Returns true if the underlying content format is a W3C DOM or a SAAJ message.
      */
     public static boolean isDOMPresent(Message m) {
-        return m.getContent(Node.class) != null;
+        return m != null && m.getContent(Node.class) != null;
         /*
         for (Class c : m.getContentFormats()) {
             if (c.equals(Node.class) || c.getName().equals("javax.xml.soap.SOAPMessage"))
{


Mime
View raw message