On Mon, Jan 23, 2012 at 10:48 AM, Selvaratnam Uthaiyashankar <
[email protected]> wrote:

> 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.
>
> AFAIK, it should not be null.. If it is NULL, the error log should be
> ERROR, not WARNING.
>

+1

>
> Regards,
> Shankar
>
> >
> > 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
> >
>
>
>
> --
> S.Uthaiyashankar
> Senior Architect & Senior Manager
> WSO2 Inc.
> http://wso2.com/ - "lean . enterprise . middleware"
>
> Phone: +94 714897591
> _______________________________________________
> 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

Reply via email to