Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-17976

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Low
    • None
    • 3.0.1, 5.3-OD-11
    • None

    Description

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

      Steps to reproduce

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

      Expected behavior

      User get deleted

      Actual behavior

      The following error is thrown

      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 (truncated):

      CONTENTID CONTENTTYPE VERSION CREATOR LASTMODIFIER LASTMODDATE PREVVER PAGEID
      23592962 'COMMENT' 2 'partha' 'partha' '2009-12-04 15:33:55' (null) 23396354
      23592963 'COMMENT' 1 'partha' 'partha' '2009-12-04 15:33:42' 23592962 (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.

      Workaround

      This SQL query will not work in Confluence 5.3 and above

      1. Enable SQL logging as per to obtain the username of the user being deleted. If you already know the username then proceed to next step.
      2. Remove all Comments associated with the user in the BodyContent table:
        DELETE FROM BODYCONTENT WHERE CONTENTID IN (SELECT CONTENTID FROM CONTENT WHERE CREATOR='<NAME>' AND CONTENTTYPE='COMMENT');
        
      1. Remove all Comments associated with the user in the Content table:
        SELECT CONTENTID FROM CONTENT WHERE CREATOR='<NAME>' AND CONTENTTYPE='COMMENT';
        

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: