cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/3] cxf git commit: [CXF-6845] More non-null checks
Date Tue, 29 Mar 2016 10:35:45 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes c633fbccb -> ca618c41b
  refs/heads/3.1.x-fixes 6c9b9b922 -> 87bbc7f81
  refs/heads/master 19c1279dc -> b34ec6ea1


[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/ca618c41
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ca618c41
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ca618c41

Branch: refs/heads/3.0.x-fixes
Commit: ca618c41b9c734e8ea6edb13fd171d66ddeeb7fc
Parents: c633fbc
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Tue Mar 29 12:31:23 2016 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Tue Mar 29 12:31:23 2016 +0200

----------------------------------------------------------------------
 .../org/apache/cxf/message/MessageUtils.java    | 37 ++++++++++++--------
 1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ca618c41/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 d8bbf0c..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));
     }
 
     /**
@@ -124,17 +128,22 @@ public final class MessageUtils {
     }
     
     public static boolean getContextualBoolean(Message m, String key, boolean defaultValue)
{
-        Object o = m.getContextualProperty(key);
-        if (o != null) {
-            return PropertyUtils.isTrue(o);
+        if (m != null) {
+            Object o = m.getContextualProperty(key);
+            if (o != null) {
+                return PropertyUtils.isTrue(o);
+            }
         }
         return defaultValue;
     }
     
     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;
     }
@@ -143,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