[jsword-devel] Concurrency issue?
Chris Burrell
chris at burrell.me.uk
Thu Mar 3 11:44:41 MST 2011
Thanks DM, I've now managed to narrow down the problem and have a unit test
that replicates the issue:
Could someone lend me a hand and run a simple junit test to test this on
another environment? The test below fails on my laptop (java 1.6 update 22)
with that particular error I described earlier.
@Test
public void testConcurrencyIssueOnBookData() throws NoSuchKeyException,
BookException,
InterruptedException {
final String name = "KJV";
final String ref = "Rom.1.1";
final Runnable t = new Runnable() {
@Override
public void run() {
final Book b0 = Books.installed().getBook(name);
BookData bd1;
try {
bd1 = new BookData(b0, b0.getKey(ref));
* bd1.getSAXEventProvider();*
} catch (final NoSuchKeyException e) {
e.printStackTrace();
} catch (final BookException e) {
e.printStackTrace();
}
}
};
int ii = 0;
while (ii++ < 1000) {
final Thread t1 = new Thread(t);
final Thread t2 = new Thread(t);
t1.start();
t2.start();
t1.join();
t2.join();
}
}
The issue I have in the test above occurs with this line:
bd1.getSAXEventProvider(); (bold above)
If I put a breakpoint on the call to getSAXEventProvider and let one thread
run through things look alright. If I put it line below, I get one of three
scenarios. (so we may be looking at a couple of bugs)
75% stacktrace as below
20% no text returned, or garbled text (e.g. cross refs showing in the text
displayed when they weren't asked for...)
5% it works
If someone could try and run it and feedback that would be helpful (running
latest version of jsword)
Chris
On 28 February 2011 20:58, DM Smith <dmsmith at crosswire.org> wrote:
> 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> 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 listjsword-devel at crosswire.orghttp://www.crosswire.org/mailman/listinfo/jsword-devel
>
>
>
> _______________________________________________
> 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/20110303/12cb8376/attachment.html>
More information about the jsword-devel
mailing list