killbill-uncached

Fix NPE when recreating a plan

12/3/2012 12:51:51 AM

Details

diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/api/user/DefaultEntitlementUserApi.java b/entitlement/src/main/java/com/ning/billing/entitlement/api/user/DefaultEntitlementUserApi.java
index d3d128c..bd14a1b 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/api/user/DefaultEntitlementUserApi.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/api/user/DefaultEntitlementUserApi.java
@@ -165,8 +165,9 @@ public class DefaultEntitlementUserApi extends EntitlementApiBase implements Ent
                             throw new EntitlementUserApiException(ErrorCode.ENT_CREATE_BP_EXISTS, bundleId);
                         } else {
                             // If we do create on an existing CANCELLED BP, this is equivalent to call recreate on that Subscription.
-                            baseSubscription.recreate(spec, requestedDate, context);
-                            return baseSubscription;
+                            final Subscription recreatedSubscriptionForApiUse = createSubscriptionForApiUse(baseSubscription);
+                            recreatedSubscriptionForApiUse.recreate(spec, requestedDate, context);
+                            return recreatedSubscriptionForApiUse;
                         }
                     }
                     bundleStartDate = requestedDate;