History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SAK-13031
Type: Sub-task Sub-task
Status: Open Open
Priority: Minor Minor
Assignee: SOO IL KIM
Reporter: Alan Berg
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sakai
SAK-13007

Mailtool - NPE

Created: 20-Feb-2008 03:33   Updated: 23-Oct-2008 05:50
Component/s: Mailtool
Affects Version/s: trunk [DO NOT USE]
Fix Version/s: None

Time Tracking:
Not Specified

2.4.x Status: None
2.5.x Status: None
2.6.x Status: None


 Description  « Hide
http://qa1-nl.sakaiproject.org/codereview/bug_dashboard/findbugs_generic_null.html

mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 1809 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 1852 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 1906 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 1981 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 2032 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 2089 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.Mailtool 2144 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.Mailtool.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 523 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 567 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 616 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroups() on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 674 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 715 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 764 Possible null pointer dereference of currentSite in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroupsByType(String) on exception path
mailtool NP_NULL_ON_SOME_PATH_EXCEPTION org.sakaiproject.tool.mailtool.OptionsBean 809 Possible null pointer dereference of therealm in org.sakaiproject.tool.mailtool.OptionsBean.getEmailGroupsByType(String) on exception path

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alan Berg - 08-Oct-2008 03:26

A partially reviewed the issue to confirm reality.
See: http://qa1-nl.sakaiproject.org/codereview/bug_dashboard/findbugs_generic_null.html


http://qa1-nl.sakaiproject.org/codereview/trunk/api/org/sakaiproject/tool/mailtool/EmailUser.java.html#61


Equals should return false on user=null not nullpointer exception

59 public boolean equals(EmailUser user)
60 {
61 if (user.getUserid().equals(m_userid) &&
62 user.getEmail().equals(m_email))
63 {
64 return true;
65 }
66 else
67 return false;
68
69 }


If you override equals you should generate your own hashcode or strange things happens with collection sorting.

org.sakaiproject.tool.mailtool.Mailtool

If exception then NPE on line 1906

1845 Site currentSite = null;
1846 try {
1847 currentSite = siteService.getSite(sid);
1848 } catch (Exception e) {
1849 log.debug("Exception: Mailtool.getEmailGroups() #3, "
1850 + e.getMessage());
1851 }
1852 Collection groups = currentSite.getGroups();
1899 Site currentSite = null;
1900 try {
1901 currentSite = siteService.getSite(sid);
1902 } catch (Exception e) {
1903 log.debug("Exception: Mailtool.getEmailGroups() #4, "
1904 + e.getMessage());
1905 }
1906 Collection groups = currentSite.getGroups();

If exception then NPE on line 1809

1802 AuthzGroup therealm = null;
1803 try {
1804 therealm = m_realmService.getAuthzGroup(realmid);
1805 } catch (Exception e) {
1806 log.debug("Exception: Mailtool.getEmailGroups() #1, "
1807 + e.getMessage());
1808 }
1809 Set users = therealm.getUsersHasRole(emailrole.getRoleid());

if exception then NPE on 2032
2025 Site currentSite = null;
2026 try {
2027 currentSite = siteService.getSite(sid);
2028 } catch (Exception e) {
2029 log.debug("Exception: Mailtool.getEmailGroups() #3, "
2030 + e.getMessage());
2031 }
2032 Collection groups = currentSite.getGroups();

if exception then NPE on 1981

1973 AuthzGroup therealm = null;
1974 try {
1975 // therealm = m_realmService.getRealm(realmid);
1976 therealm = m_realmService.getAuthzGroup(realmid);
1977 } catch (Exception e) {
1978 log.debug("Exception: Mailtool.getEmailGroups() #1, "
1979 + e.getMessage());
1980 }
1981 Set users = therealm.getUsersHasRole(emailrole.getRoleid());

if exception then NPE on 2144
2137 AuthzGroup therealm = null;
2138 try {
2139 therealm = m_realmService.getAuthzGroup(realmid);
2140 } catch (Exception e) {
2141 log.debug("Exception: Mailtool.getEmailGroups() #5, "
2142 + e.getMessage());
2143 }
2144 Set users = therealm.getUsersHasRole(emailrole.getRoleid());

Check type is null first or NPE if null
697 if (type.equals("") || type == null)

Please review the generic jira and cleanup

ETC