Bugs/concerns from quick code review on shindig extender filter
---------------------------------------------------------------
Key: AMDATU-291
URL: http://jira.amdatu.org/jira/browse/AMDATU-291
Project: Amdatu
Issue Type: Task
Components: Amdatu OpenSocial
Reporter: Bram de Kruijff
I have some concerns with regard to
org.amdatu.opensocial.shindig.service.TenantHostnameDispatchExtenderFilter
besides the fact that it introduces redundant resolving as described in
AMDATU-288. Specifically the use of a static method to grant access to the
mostly unrelated class CassandraAppDataServiceStore is obviosly a quick hack en
smells.... Besides the potential exceptions indicated below some fundamental
questions:
1) The static method access couples the availibility to the classloader
lifecycle while the availibility of bundlecontext (etc) is coupled to service
lifecycle
2) The useradmin lookup code (should it be here anyway?) uses
getAllServiceReferences which does not check compatibility restrictions
Annotated code:
private static ThreadLocal<Tenant> m_properties = null;
public static Tenant getTenant() {
return m_properties.get();
<====== potential NullPointerException
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws
IOException, ServletException {
....
}
public static UserAdmin getUserAdmin() throws InvalidSyntaxException {
Tenant tenant = getTenant();
ServiceReference[] refs =
m_bundleContext.getAllServiceReferences(UserAdmin.class.getName(), null);
<====== potential NullPointerException
for (ServiceReference ref : refs) {
<====== potential NullPointerException
if
(tenant.getId().equals(ref.getProperty(Tenant.TENANT_ID_SERVICEPROPERTY))) {
<====== potential NullPointerException
return (UserAdmin)
m_bundleContext.getService(ref);
<====== potential ClassCastException
}
}
return null;
}
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira