Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1315

NPE in Observation when listener restricted by node type and property deleted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.7.0.Final, 3.0.0.Alpha1
    • 2.6.0.Final
    • JCR
    • None
    • Hide

      Assume that a node type "uscdr:file" has been defined in a .cnd file loaded at startup. An event listener is added as follows:

      int EVENT_MASK = Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED;
      session.getWorkspace().getObservationManager().addEventListener(this, EVENT_MASK, null, true, null, new String[] {"uscdr:file"}, false);
      

      Now, if a property is deleted from a node of type uscdr:file, the following NPE occurs:

      21:43:55,988 ERROR [STDERR] Exception in thread "pool-12-thread-1" java.lang.NullPointerException
      21:43:55,988 ERROR [STDERR] 	at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.acceptBasedOnNodeTypeName(JcrObservationManager.java:814)
      21:43:55,988 ERROR [STDERR] 	at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.notify(JcrObservationManager.java:1006)
      21:43:55,988 ERROR [STDERR] 	at org.modeshape.graph.observe.NetChangeObserver.notify(NetChangeObserver.java:362)
      21:43:55,989 ERROR [STDERR] 	at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.notify(JcrObservationManager.java:975)
      21:43:55,989 ERROR [STDERR] 	at org.modeshape.jcr.JcrRepository$RepositoryObservationManager$1.run(JcrRepository.java:1974)
      21:43:55,989 ERROR [STDERR] 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      21:43:55,989 ERROR [STDERR] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      21:43:55,989 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:662)
      

      and the EventListener is never invoked.

      The following code avoids the NPE:

      int EVENT_MASK = Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED;
      session.getWorkspace().getObservationManager().addEventListener(this, EVENT_MASK, null, true, null, null, false);
      
      Show
      Assume that a node type "uscdr:file" has been defined in a .cnd file loaded at startup. An event listener is added as follows: int EVENT_MASK = Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED; session.getWorkspace().getObservationManager().addEventListener(this, EVENT_MASK, null, true, null, new String[] {"uscdr:file"}, false); Now, if a property is deleted from a node of type uscdr:file, the following NPE occurs: 21:43:55,988 ERROR [STDERR] Exception in thread "pool-12-thread-1" java.lang.NullPointerException 21:43:55,988 ERROR [STDERR] at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.acceptBasedOnNodeTypeName(JcrObservationManager.java:814) 21:43:55,988 ERROR [STDERR] at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.notify(JcrObservationManager.java:1006) 21:43:55,988 ERROR [STDERR] at org.modeshape.graph.observe.NetChangeObserver.notify(NetChangeObserver.java:362) 21:43:55,989 ERROR [STDERR] at org.modeshape.jcr.JcrObservationManager$JcrListenerAdapter.notify(JcrObservationManager.java:975) 21:43:55,989 ERROR [STDERR] at org.modeshape.jcr.JcrRepository$RepositoryObservationManager$1.run(JcrRepository.java:1974) 21:43:55,989 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 21:43:55,989 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 21:43:55,989 ERROR [STDERR] at java.lang.Thread.run(Thread.java:662) and the EventListener is never invoked. The following code avoids the NPE: int EVENT_MASK = Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED; session.getWorkspace().getObservationManager().addEventListener(this, EVENT_MASK, null, true, null, null, false);
    • Hide

      Don't specify the node type restriction and ignore changes to nodes that are not of the desired type in the EventListener. (More expensive, but avoids the NPE).

      Show
      Don't specify the node type restriction and ignore changes to nodes that are not of the desired type in the EventListener. (More expensive, but avoids the NPE).

    Description

      An NPE occurs in a background thread when listening for Event.PROPERTY_REMOVED events, the watched nodes are restricted by a node type, and a property on the watched node type is deleted. The EvenListener is never called after the property deletion.

      Attachments

        Activity

          People

            hchiorean Horia Chiorean (Inactive)
            jonathandfields_jira Jonathan Fields (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: