[jsword-devel] [JIRA] Commented: (JS-174) Infinite recursion getting osis id for a TreeKey

DM Smith (JIRA) jira at crosswire.org
Sat Mar 12 06:27:25 MST 2011


    [ http://www.crosswire.org/bugs/browse/JS-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14112#comment-14112 ] 

DM Smith commented on JS-174:
-----------------------------

This is a silly bug in unused code.
The KeyVisitor for getName() getOsisId() and getOsisRef() all call key.getXXX().

On Keys other than TreeKey, it will work just fine. But on a TreeKey it will recurse.

One of the things that this points out is that we need more robust JUnit test cases.

How were you hoping to use the results of the call?

> Infinite recursion getting osis id for a TreeKey
> ------------------------------------------------
>
>                 Key: JS-174
>                 URL: http://www.crosswire.org/bugs/browse/JS-174
>             Project: JSword
>          Issue Type: Bug
>          Components: o.c.jsword.passage
>    Affects Versions: 1.6.1
>         Environment: All
>            Reporter: Martin Denham
>            Assignee: DM Smith
>
> I am not sure if it makes sense to get an osis id for a TreeKey treeKey.getName works fine but when I tried treeKey.getOsisID it failed with some sort of infinite recursion error.  I wonder if the new java 5 for loop in KeyUtil.visit is causing a problem.
> Here is my test:
> 	Book book = getBook("Pilgrim");  // Bunyan's Pilgrim's Progress
> 	Key key = book.getKey("THE FIRST STAGE");
> 	key.getOsisID(); // error occurs here
> Here is the top of the stack trace:
> java.lang.StackOverflowError
> 	at java.util.Stack.peek(Stack.java:86)
> 	at org.crosswire.jsword.passage.KeyIterator.prepare(KeyIterator.java:49)
> 	at org.crosswire.jsword.passage.KeyIterator.hasNext(KeyIterator.java:63)
> 	at org.crosswire.jsword.passage.KeyIterator.next(KeyIterator.java:68)
> 	at org.crosswire.jsword.passage.KeyIterator.next(KeyIterator.java:36)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:50)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> 	at org.crosswire.jsword.passage.KeyUtil.visit(KeyUtil.java:53)
> // the calls to .visit go on and on...

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the jsword-devel mailing list