svn commit: r1309715 - /ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1309715 - /ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java

jleroux@apache.org
Author: jleroux
Date: Thu Apr  5 09:27:24 2012
New Revision: 1309715

URL: http://svn.apache.org/viewvc?rev=1309715&view=rev
Log:
A patch from Paul Foxworthy https://issues.apache.org/jira/browse/OFBIZ-4784 "storeIncomingEmail assumes variable is not null when it might be"

In storeIncomingEmail in CommunicationEventServices.java, the code to assemble the aboutThisEmail debugging message assumes addressesFrom and addressesTo are not null. But the methods that return values for those variables might return null if they encounter an exception.

Removes also uses of UtilValidate.isEmpty, which should only be used for collections and sequences (see OFBIZ-4427).

Modified:
    ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java

Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=1309715&r1=1309714&r2=1309715&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Thu Apr  5 09:27:24 2012
@@ -711,8 +711,9 @@ public class CommunicationEventServices
             String messageId = wrapper.getMessageId().replaceAll("[<>]", "");
 
             String aboutThisEmail = "message [" + messageId + "] from [" +
-                (addressesFrom[0] == null? "not found" : addressesFrom[0].toString()) + "] to [" +
-                (addressesTo[0] == null? "not found" : addressesTo[0].toString()) + "]";
+                    ((addressesFrom == null || addressesFrom[0] == null) ? "not found" : addressesFrom[0].toString()) + "] to [" +
+                    ((addressesTo == null || addressesTo[0] == null) ? "not found" : addressesTo[0].toString()) + "]";
+
             if (Debug.verboseOn()) Debug.logVerbose("Processing Incoming Email " + aboutThisEmail, module);
 
             // ignore the message when the spam status = yes
@@ -1079,7 +1080,7 @@ public class CommunicationEventServices
             }
         }
 
-        if (!UtilValidate.isEmpty(emailAddress)) {
+        if (emailAddress != null) {
             map = FastMap.newInstance();
             map.put("address", emailAddress.getAddress());
             map.put("userLogin", userLogin);
@@ -1102,7 +1103,7 @@ public class CommunicationEventServices
                 if (addr instanceof InternetAddress) {
                     emailAddress = (InternetAddress)addr;
 
-                    if (!UtilValidate.isEmpty(emailAddress)) {
+                    if (emailAddress != null) {
                         result = dispatcher.runSync("findPartyFromEmailAddress",
                                 UtilMisc.toMap("address", emailAddress.getAddress(), "userLogin", userLogin));
                         if (result.get("partyId") != null) {
@@ -1129,7 +1130,7 @@ public class CommunicationEventServices
                 if (addr instanceof InternetAddress) {
                     emailAddress = (InternetAddress)addr;
 
-                    if (!UtilValidate.isEmpty(emailAddress)) {
+                    if (emailAddress != null) {
                         Map<String, String> inputFields = FastMap.newInstance();
                         inputFields.put("infoString", emailAddress.getAddress());
                         inputFields.put("infoString_ic", caseInsensitiveEmail);