killbill-aplcache

Fix null Plan or null Phase issue

5/2/2012 5:47:06 PM

Details

diff --git a/analytics/src/main/java/com/ning/billing/analytics/BusinessSubscription.java b/analytics/src/main/java/com/ning/billing/analytics/BusinessSubscription.java
index 59c36ee..441b064 100644
--- a/analytics/src/main/java/com/ning/billing/analytics/BusinessSubscription.java
+++ b/analytics/src/main/java/com/ning/billing/analytics/BusinessSubscription.java
@@ -99,8 +99,8 @@ public class BusinessSubscription
         Plan thePlan = null;
         PlanPhase thePhase = null;
         try {
-            thePlan = catalog.findPlan(currentPlan, new DateTime(), startDate);
-            thePhase = catalog.findPhase(currentPhase, new DateTime(), startDate);
+            thePlan = (currentPlan != null) ? catalog.findPlan(currentPlan, new DateTime(), startDate) : null;
+            thePhase = (currentPhase != null) ? catalog.findPhase(currentPhase, new DateTime(), startDate) : null;
         } catch (CatalogApiException e) {
             log.error(String.format("Failed to retrieve Plan from catalog for plan %s, phase ", currentPlan, currentPhase));
         }