[jsword-devel] [JIRA] Created: (JS-216) Error in BookInstaller.deleteBook and APIExamples.installBook

Martin Denham (JIRA) jira at crosswire.org
Tue Mar 27 11:33:47 MST 2012

Error in BookInstaller.deleteBook and APIExamples.installBook

                 Key: JS-216
                 URL: http://www.crosswire.org/bugs/browse/JS-216
             Project: JSword
          Issue Type: Bug
            Reporter: Martin Denham
            Assignee: DM Smith
            Priority: Minor

I used the deleteBook code from BookInstaller in And Bible but there is an error in it.

Here is the example code:

    public void deleteBook(Book book) throws BookException {
        // Make the book unavailable.
        // This is normally done via listeners.

        // Actually do the delete
        // This should be a call on installer.

The problem is that 
also calls 
meaning it is called twice for the same book - See SwordBookDriver.delete(Book dead)

So the problem is that Books.removeBook() is called twice.

Now, Books.removeBook contains:
        boolean removed = books.remove(book);
        if (removed) {
            fireBooksChanged(instance, book, false);
        } else {
            throw new BookException(JSOtherMsg.lookupText("Could not remove unregistered Book: {0}", book.getName()));

so the second time it throws a BookException because the book has already been removed.

The simple fix is not to call Books.installed().removeBook(book) at the very start of the example code at the top, and this is what I have done in And Bible code.  However, there seems to be a deliberate purpose in the call so that is probably not the correct solution.

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