On Tue, Sep 23, 2014 at 4:52 PM, Afkham Azeez <[email protected]> wrote:
> > > On Tue, Sep 23, 2014 at 4:48 PM, Pubudu Dissanayake <[email protected]> > wrote: > >> Hi folks, >> >> I'm in a process of implementing a fix for the CarbonContext.java >> <https://github.com/wso2-dev/carbon4-kernel/blob/master/core/org.wso2.carbon.utils/src/main/java/org/wso2/carbon/context/CarbonContext.java> >> [1] >> and I found several concerns. Observations as follows, >> >> - Empty Catch blocks >> >> if (tenantId != MultitenantConstants.INVALID_TENANT_ID) { >> >> try { >> registry = >> dataHolder.getRegistryService().getConfigUserRegistry(getUsername(), >> tenantId); >> return registry; >> } catch (Exception e) { >> // If we can't obtain an instance of the >> registry, we'll simply return null. The >> // errors that lead to this situation will be >> logged by the Registry Kernel. >> } >> return null; >> } >> > > Throw a relevant exception > If we throw an Exception there will be an API change for getRegistry method.. Right?.. > >> - Ignoring of documenting of potential exceptions thrown by methods >> >> try { >> >> return >> CarbonContextDataHolder.getDiscoveryServiceProvider().probe(null, scopes, >> null, >> getCarbonContextDataHolder().getTenantId()); >> } catch (Exception ignored) { >> // If an exception occurs, simply return no endpoints. The >> discovery component will >> // be responsible of reporting any errors. >> return new String[0]; >> } >> > > We don't use WS-Discovery anymore, right? If so, we can get rid of this > method. > >> >> What we normally tend to do is, either log, or throw. Catching the >> exception just to log it doesn't make much sense. If we can gather some >> additional context, create a new exception with new info and wrap the >> cause, and throw it. Also, if we log, and throw, and then the client >> catches it, logs, rethrows, and so on,what will happen is we will get the >> stack trace with the same exception multiple times. >> >> Please advice as to how I should go about handling this. >> >> Thanks >> - Pubudu >> >> [1] >> https://github.com/wso2-dev/carbon4-kernel/blob/master/core/org.wso2.carbon.utils/src/main/java/org/wso2/carbon/context/CarbonContext.java >> >> -- >> *Pubudu Dissanayake* >> Software Engineer >> >> WSO2 Inc.; http://wso2.com >> lean.enterprise.middleware >> Mob: + 94 775 503 304 >> >> Blog: http://geekdetected.wordpress.com/ >> Linkedin: *http://lk.linkedin.com/in/pubududissanayake* >> <http://lk.linkedin.com/in/pubududissanayake> >> Flickr : https://www.flickr.com/photos/pubudufx/ >> Twitter: https://twitter.com/GeekInAction >> >> > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>* > *email: **[email protected]* <[email protected]> > * cell: +94 77 3320919 <%2B94%2077%203320919>blog: * > *http://blog.afkham.org* <http://blog.afkham.org> > *twitter: **http://twitter.com/afkham_azeez* > <http://twitter.com/afkham_azeez> > *linked-in: **http://lk.linkedin.com/in/afkhamazeez > <http://lk.linkedin.com/in/afkhamazeez>* > > *Lean . Enterprise . Middleware* > -- *Aruna Sujith Karunarathna* | Software Engineer WSO2, Inc | lean. enterprise. middleware. #20, Palm Grove, Colombo 03, Sri Lanka Mobile: +94 71 9040362 | Work: +94 112145345 Email: [email protected] | Web: www.wso2.com
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
