Details
-
Type: Bug
-
Status: Closed (View Workflow)
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.7
-
Component/s: None
-
Labels:None
Description
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. Books.installed().removeBook(book); // Actually do the delete // This should be a call on installer. book.getDriver().delete(book); }The problem is that
book.getDriver().delete(book)
also calls
Books.installed().removeBook(dead)
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)
else {
throw new BookException(JSOtherMsg.lookupText("Could not remove unregistered Book:
", 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.