java.lang.NullPointerException

Atlassian JIRA | Joe Clark [Atlassian] | 3 years ago
  1. 0

    Since time immemorial, the standard behaviour of Atlassian's user management subsystems has been to use {{null}} to represent an anonymous user context. This has been codified in the SAL interface javadoc for the {{com.atlassian.sal.api.user.UserManager}} interface. For example, the textual contract for the #getRemoteUser() method states: {code:lang=java} /** * Returns the profile of the currently logged in user or null if no user can be found. * <p/> * Getting the full {@link UserProfile} may have performance implications in some applications. Consider using {@link #getRemoteUserKey()} if you don't need the full object. * * @return the {@link UserProfile} of the logged in user or null * @see #getRemoteUserKey() * @since 2.10 */ @Nullable UserProfile getRemoteUser(); {code} The SAL UserManager API and the underlying JIRA implementation of UserManager were changed in JIRA 6.0 to support renaming users. This change has *broken* the textual contract of the #getRemoteUser() method in JIRA, which *no longer returns {{null}} for anonymous users*. This appears to simply be an oversight in the JIRA implementation: {code:lang=java} @Override public UserProfile getRemoteUser() { return new JiraUserProfile(jiraAuthenticationContext.getUser()); } {code} This method should return {{null}} if the value returned from {{jiraAuthenticationContext.getUser()}} also returns {{null}}. This subtle change in behaviour can end up with add-on developers getting a stack-trace like this: {noformat} java.lang.NullPointerException at com.atlassian.sal.jira.user.DefaultUserManager$JiraUserProfile.getUsername(DefaultUserManager.java:253) at com.atlassian.jira.examples.ExampleServlet.doGet(ExampleServlet.java:78) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at com.atlassian.plugin.servlet.DelegatingPluginServlet.service(DelegatingPluginServlet.java:42) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) ... {noformat} This change may cause unexpected side effects in Atlassian-authored and third-party JIRA add-ons and should be corrected ASAP. This bug would only be detected through explicit testing, since this change is not mentioned in the [Preparing for JIRA 6.0|https://developer.atlassian.com/display/JIRADEV/Preparing+for+JIRA+6.0] guide or the [Renamable Users in JIRA 6.0|https://developer.atlassian.com/display/JIRADEV/Renamable+Users+in+JIRA+6.0] guide.

    Atlassian JIRA | 3 years ago | Joe Clark [Atlassian]
    java.lang.NullPointerException
  2. 0

    Since time immemorial, the standard behaviour of Atlassian's user management subsystems has been to use {{null}} to represent an anonymous user context. This has been codified in the SAL interface javadoc for the {{com.atlassian.sal.api.user.UserManager}} interface. For example, the textual contract for the #getRemoteUser() method states: {code:lang=java} /** * Returns the profile of the currently logged in user or null if no user can be found. * <p/> * Getting the full {@link UserProfile} may have performance implications in some applications. Consider using {@link #getRemoteUserKey()} if you don't need the full object. * * @return the {@link UserProfile} of the logged in user or null * @see #getRemoteUserKey() * @since 2.10 */ @Nullable UserProfile getRemoteUser(); {code} The SAL UserManager API and the underlying JIRA implementation of UserManager were changed in JIRA 6.0 to support renaming users. This change has *broken* the textual contract of the #getRemoteUser() method in JIRA, which *no longer returns {{null}} for anonymous users*. This appears to simply be an oversight in the JIRA implementation: {code:lang=java} @Override public UserProfile getRemoteUser() { return new JiraUserProfile(jiraAuthenticationContext.getUser()); } {code} This method should return {{null}} if the value returned from {{jiraAuthenticationContext.getUser()}} also returns {{null}}. This subtle change in behaviour can end up with add-on developers getting a stack-trace like this: {noformat} java.lang.NullPointerException at com.atlassian.sal.jira.user.DefaultUserManager$JiraUserProfile.getUsername(DefaultUserManager.java:253) at com.atlassian.jira.examples.ExampleServlet.doGet(ExampleServlet.java:78) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at com.atlassian.plugin.servlet.DelegatingPluginServlet.service(DelegatingPluginServlet.java:42) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) ... {noformat} This change may cause unexpected side effects in Atlassian-authored and third-party JIRA add-ons and should be corrected ASAP. This bug would only be detected through explicit testing, since this change is not mentioned in the [Preparing for JIRA 6.0|https://developer.atlassian.com/display/JIRADEV/Preparing+for+JIRA+6.0] guide or the [Renamable Users in JIRA 6.0|https://developer.atlassian.com/display/JIRADEV/Renamable+Users+in+JIRA+6.0] guide.

    Atlassian JIRA | 3 years ago | Joe Clark [Atlassian]
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.atlassian.sal.jira.user.DefaultUserManager$JiraUserProfile.getUsername()
    2. com.atlassian.sal
      DefaultUserManager$JiraUserProfile.getUsername
      1. com.atlassian.sal.jira.user.DefaultUserManager$JiraUserProfile.getUsername(DefaultUserManager.java:253)
      1 frame
    3. com.atlassian.jira
      ExampleServlet.doGet
      1. com.atlassian.jira.examples.ExampleServlet.doGet(ExampleServlet.java:78)
      1 frame
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      2. javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      2 frames
    5. com.atlassian.plugin
      DelegatingPluginServlet.service
      1. com.atlassian.plugin.servlet.DelegatingPluginServlet.service(DelegatingPluginServlet.java:42)
      1 frame
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      1 frame
    7. com.atlassian.plugin
      ServletModuleContainerServlet.service
      1. com.atlassian.plugin.servlet.ServletModuleContainerServlet.service(ServletModuleContainerServlet.java:52)
      1 frame
    8. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      1 frame