Project

Profile

Help

Bug #2195

NullPointerException in com.saxonica.pull.TreeWalker

Added by Michael Kay almost 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
Start date:
2014-10-22
Due date:
% Done:

100%

Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:

Description

Gunther Rademacher reports on the saxon-help list:

I have a piece of code that worked with Saxon-EE 9.5, but throws a NPE with 9.6. It

uses PullToStax and TreeWalker to get Stax events from a DOM source.

A complete reproduction is shown below.

In the actual application, different types of sources are mapped to Stax events, for

peeking at some initial fragment of those sources. PullToStax came in handy to

accomplish this for DOM sources. I might of course implement that differently.

Concerning PullToStax and TreeWalker, I am not sure whether they are considered

part of the official API. I may also be misusing them in some way. Should I possibly

give up this approach?

History

#1 Updated by Michael Kay almost 5 years ago

  • Status changed from New to Resolved

Thanks for reporting it. I've added your test case as a JUnit test and have produced a patch which will be committed on the 9.6 and 9.7 branches.

This code hasn't changed substantially for quite a while, but it was affected by a change to the SequenceIterator interface, and the change was made incorrectly. The general principle now is that SequenceIterator no longer maintains the values of position() and current(), and anyone who needs access to these values needs to wrap the SequenceIterator in a FocusTrackingIterator. It's then important always to call next() on the wrapping FocusTrackingIterator, but the TreeWalker fails to follow this rule and calls next() on the underlying SequenceIterator instead, leavng FocusTrackingIterator.current() set to null.

#2 Updated by O'Neil Delpratt almost 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.6.0.2

Bug fix applied to the maintenance release Saxon 9.6.0.2

#3 Updated by O'Neil Delpratt almost 4 years ago

  • Sprint/Milestone set to 9.6.0.2
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release 9.6.0.2 added

Please register to edit this issue

Also available in: Atom PDF