[jsword-devel] Concurrency issue?

DM Smith dmsmith at crosswire.org
Mon Feb 28 13:58:40 MST 2011


Chris,

I haven't seen your problem before. However,

The line:
     requiredTransformation.iterator().next().getFile()
looks suspicious as the contract to iterator requires calling hasNext() 
before calling next() and only calling next() when hasNext() returns true.

The reason for this is that hasNext() typically sets up what next() returns.

Some implementations of an iterator will have the constructor setting up 
the first value to return and having next() do double duty of setting up 
the next value and returning the current value. In this case repeatedly 
calling next might work.

Also calling, iterator().next(), if calling next() without hasNext() 
works, should only ever return the first value as the call to iterator 
should set up a fresh iterator.

In Him,
     DM

On 02/27/2011 05:37 PM, Chris Burrell wrote:
> The code I'm running into issues with is here. It could well be I'm 
> mis-using the library?
> final SAXEventProvider osissep = bookData.getSAXEventProvider();
>             TransformingSAXEventProvider htmlsep = null;
>             htmlsep = (TransformingSAXEventProvider) new Converter() {
>
>                 public SAXEventProvider convert(final SAXEventProvider 
> provider) throws TransformerException {
>                     try {
>                         // for now, we just assume that we'll only 
> have one option, but this may change later
>                         // TODO, we can probably cache the resource
>                         final TransformingSAXEventProvider tsep = new 
> TransformingSAXEventProvider(getClass()
>                                 
> .getResource(requiredTransformation.iterator().next().getFile()).toURI(),
>                                 osissep);
>
>                         // set parameters here
>                         setOptions(tsep, options, version, reference);
>                         setupInterlinearOptions(tsep, 
> interlinearVersion, reference);
>                         return tsep;
>                     } catch (final URISyntaxException e) {
>                         throw new StepInternalException("Failed to 
> load resource correctly", e);
>                     }
>                 }
>
>             }.convert(osissep);
>
>
> On 27 February 2011 16:52, Chris Burrell <chris at burrell.me.uk 
> <mailto:chris at burrell.me.uk>> wrote:
>
>     Hello...
>
>     I was just wondering if someone has come across this issue before?
>
>     I have two panes loading two passages (1 ESV, 1 KJV). I am getting
>     the following issue fairly frequently. (this is different to the
>     issue I raised quite a while ago, in that the one before was
>     corruption in the book reading driver).
>
>     Caused by: java.lang.IllegalStateException: Root element not set
>     at org.jdom.Document.getRootElement(Document.java:218)
>     at
>     org.crosswire.jsword.book.filter.osis.OSISFilter.parse(OSISFilter.java:149)
>     at
>     org.crosswire.jsword.book.filter.osis.OSISFilter.toOSIS(OSISFilter.java:74)
>     at
>     org.crosswire.jsword.book.basic.AbstractPassageBook.getOsisIterator(AbstractPassageBook.java:90)
>     at
>     org.crosswire.jsword.book.BookData.getOsisContent(BookData.java:157)
>     at
>     org.crosswire.jsword.book.BookData.getOsisFragment(BookData.java:100)
>     at
>     org.crosswire.jsword.book.BookData.getSAXEventProvider(BookData.java:113)
>     at
>     com.tyndalehouse.step.core.service.impl.JSwordServiceImpl.getOsisText(JSwordServiceImpl.java:131)
>     at
>     com.tyndalehouse.step.core.service.impl.BibleInformationServiceImpl.getPassageText(BibleInformationServiceImpl.java:57)
>     at
>     com.tyndalehouse.step.rest.controllers.BibleController.getBibleText(BibleController.java:101)
>     at
>     com.tyndalehouse.step.rest.controllers.BibleController.getBibleText(BibleController.java:60)
>     ... 28 more
>
>     Also DM, have you started looking at JS-109? Just wondering...
>     Chris
>
>
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20110228/650dc4ef/attachment.html>


More information about the jsword-devel mailing list