NPE when removing a user which has created a comment that has been edited

XMLWordPrintable

      NOTE: This bug report is for Confluence Cloud. Using Confluence Server? See the corresponding bug report.

      Steps to reproduce

      0) Ensure you have hooked up your install to mysql
      1) Create a user
      2) Let that user create a comment in a page
      3) Let that user edit that comment and save
      4) Log in as admin and try to remove the user created at 1)

      You will get the following:

      2009-12-04 15:52:49,748 ERROR [http-8080-1] [atlassian.confluence.servlet.ConfluenceServletDispatcher] sendError Could not execute action
       -- referer: http://localhost:8080/admin/users/viewuser.action?username=partha | url: /admin/users/removeuser.action | userName: wikiadmin
      org.apache.velocity.exception.MethodInvocationException: Invocation of method 'isUserRemovable' in  class com.atlassian.confluence.user.actions.RemoveUserAction threw exception java.lang.NullPointerException at /admin/users/removeuser.vm[line 31, column 23]
      	at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:223)
      	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:252)
      	at org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.java:460)
      	at org.apache.velocity.runtime.parser.node.ASTNotNode.evaluate(ASTNotNode.java:63)
      	at org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:62)
      ...
      Caused by: java.lang.NullPointerException
      	at com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao.mySqlGetSpacesContainingCommentsByUser(HibernateSpaceDao.java:222)
      	at com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao.getSpacesContainingCommentsByUser(HibernateSpaceDao.java:192)
      	at com.atlassian.confluence.spaces.DefaultSpaceManager.getSpacesContainingCommentsBy(DefaultSpaceManager.java:309)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:20)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      	at $Proxy35.getSpacesContainingCommentsBy(Unknown Source)
      	at com.atlassian.confluence.user.DefaultUserContentManager.getUserCommentedSpaces(DefaultUserContentManager.java:38)
      	at com.atlassian.confluence.user.DefaultUserContentManager.hasAuthoredContent(DefaultUserContentManager.java:17)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at com.atlassian.spring.interceptors.SpringProfilingInterceptor.invoke(SpringProfilingInterceptor.java:20)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      	at $Proxy58.hasAuthoredContent(Unknown Source)
      

      This will fail on:

                  spaces.add(comment.getPage().getSpace());
      

      in com.atlassian.confluence.spaces.persistence.dao.hibernate.HibernateSpaceDao#mySqlGetSpacesContainingCommentsByUser

      as

      comment.getPage() will be null for the original comment (i.e. the comment that was edited).

      Database:

      CONTENTID CONTENTTYPE TITLE VERSION CREATOR CREATIONDATE LASTMODIFIER LASTMODDATE VERSIONCOMMENT PREVVER CONTENT_STATUS SPACEID PARENTID MESSAGEID PAGEID PARENTCOMMENTID USERNAME DRAFTPAGEID DRAFTSPACEKEY DRAFTTYPE DRAFTPAGEVERSION CHILD_POSITION
      23592962 'COMMENT' (null) 2 'partha' '2009-12-04 15:33:42' 'partha' '2009-12-04 15:33:55' '' (null) 'current' (null) (null) (null) 23396354 (null) (null) (null) (null) (null) (null) (null)
      23592963 'COMMENT' (null) 1 'partha' '2009-12-04 15:33:42' 'partha' '2009-12-04 15:33:42' '' 23592962 'current' (null) (null) (null) (null) (null) (null) (null) (null) (null) (null) (null)

      Notice that the pageid for the editted comment is null.

      We should either set the pageid for comments that are edited, which won't help for comments that have already been edited, or we simply assume that comments with no page, are old comments and skip them.

              Assignee:
              Steve Haffenden (Inactive)
              Reporter:
              Partha
              Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: