Open GoogleCodeExporter opened 8 years ago
First things first. I loaded the project in Eclipse and looked through the
relevant method calls:
* DaisyEbookReaderService
* WriteDataToXmlFile
and in this method the error is triggered in the following line of code:
eTitle.appendChild(doc.createTextNode(daisybook.getTitle()));
My guess is the problem may be caused if daisy book.getTitle() returns null.
But I don't know for sure. Perhaps we can isolate the call to
createTextNode(...) and write some skeletal code to see how it behaves when
it's passed null. We can do this in a separate JUnit test case.
I also notice this method combines two tasks:
1. creating the document hierarchy in memory
2. writing the result to a file
Perhaps we can usefully improve the code and the testability by splitting the
code into separate distinct method calls?
Also the method returns void (nothing) and several exceptions are caught and
logged but otherwise suppressed. NPEs are not caught which caused the NPE to
cause the activity DaisyReaderDownloadBooks to be terminated. So perhaps we can
look at what the method should do to communicate relevant problems back to its
callers?
Original comment by julianharty
on 21 Aug 2013 at 8:02
When we get to thinking about exceptions and error handling & reporting
resources such as:
http://www.oracle.com/technetwork/java/effective-exceptions-092345.html and the
Exceptions chapter of Josh Block's Effective Java (second edition in my case)
seem relevant
Original comment by julianharty
on 21 Aug 2013 at 8:03
Right. I've been able to isolate one cause of the NPE which only occurs in the
Android run time, not J2SE 6. See commits:
https://github.com/julianharty/new-android-daisy-reader/commit/16748aef78fda1448
f7f594583a3c04dfc01577d (where I've described the findings so far)
https://github.com/julianharty/new-android-daisy-reader/commit/f32a59f8272f788ef
9f05243d629b12a21158189 (merge of changes with recent additions from LogiGear)
https://github.com/julianharty/new-android-daisy-reader/commit/7f3475b2cb6d4feff
1a4ac978fbb38ef0fe26d1f (my first spike)
Next step is to read the docs.
Original comment by julianharty
on 21 Aug 2013 at 8:40
Hmmm
http://developer.android.com/reference/org/w3c/dom/Document.html#createTextNode(
java.lang.String) tells me nothing relevant :(
Original comment by julianharty
on 21 Aug 2013 at 8:41
As a thought, perhaps we could replace null with a blank string for logical
elements such as a book's title if we can't obtain a title? Or should we make
the title optional in the data structure?
Original comment by julianharty
on 21 Aug 2013 at 8:43
Original issue reported on code.google.com by
julianharty
on 21 Aug 2013 at 7:54