On Sat, Jan 21, 2012 at 6:53 PM, Amila Maha Arachchi <[email protected]>wrote:
> Hi Nirmal, > > It seems the source in the trunk is missing some changes done in the > branch. In the branch we have the following code segment. > > BillingEngine billingEngine = > billingManager.getBillingEngine(StratosConstants.* > MULTITENANCY_VIEWING_TASK_ID*); > > Yet I agree that there should be a null check for billingEngine. > > This NPE occurs because one of the two billing engine configurations is > commented in the billing-config.xml when setting up stratos via the script. > Try uncommenting it and you will be able get rid of this. > > I'll copy the code from branch to trunk and then fix this. > +1 Thanks. > > Thanks, > AmilaM. > > On Sat, Jan 21, 2012 at 4:50 PM, Nirmal Fernando <[email protected]> wrote: > >> Hi, >> >> Following highlighted code segment [1] throws a NPE as it doesn't handle >> the case of BillingEngine being null. >> >> Would it be okay to log a 'warning' when it is null? >> >> Thanks. >> >> [1] >> >> Class: org.wso2.carbon.throttling.manager.utils.Util.java >> >> /** >> * get current billing customer. >> * >> * @param tenantId, tenant id. >> * @return Customer >> * @throws RegistryException, if getting the current billing customer >> failed. >> */ >> public static Customer getCurrentBillingCustomer(int tenantId) throws >> RegistryException { >> // get the host name of the current domain >> if (tenantId == MultitenantConstants.SUPER_TENANT_ID) { >> return null; >> } >> Tenant tenant; >> try { >> tenant = (Tenant) >> realmService.getTenantManager().getTenant(tenantId); >> } catch (org.wso2.carbon.user.api.UserStoreException e) { >> String msg = "Error in getting the realm Information."; >> log.error(msg, e); >> throw new RegistryException(msg, e); >> } >> if (tenant == null) { >> return null; >> } >> String customerName = tenant.getDomain(); >> >> BillingEngine billingEngine = >> >> >> billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID); >> Customer customer; >> >> try { >> List<Customer> customers = >> billingEngine.getCustomersWithName(customerName); >> if (customers == null || customers.size() == 0) { >> customer = null; >> } else { >> customer = customers.get(0); >> } >> } catch (BillingException e) { >> String msg = "Error in getting the current customer"; >> log.error(msg, e); >> throw new RegistryException(msg, e); >> } >> >> return customer; >> } >> >> >> >> -- >> >> regards, >> Nirmal >> >> Software Engineer, WSO2 Inc. >> mobile: +94715779733 >> >> >> _______________________________________________ >> Carbon-dev mailing list >> [email protected] >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >> >> > > > -- > *Amila Maharachchi* > Senior Software Engineer; WSO2, Inc.; http://wso2.com > > Blog: http://maharachchi.blogspot.com > Mobile: +94719371446 > > > > _______________________________________________ > Carbon-dev mailing list > [email protected] > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev > > -- regards, Nirmal Software Engineer, WSO2 Inc. mobile: +94715779733
_______________________________________________ Carbon-dev mailing list [email protected] http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
