Ugo Cei wrote:
Sorry, but I don't agree. NPE's are indications of bugs. Hiding those with checks for null doesn't help matters, IMO.
I have my share of doubts when it comes to these matters. This is my line of reasoning:
The Flowscript is a core component of Cocoon. We should apply defensive programming in order to protect the core from potentially buggy or malicious client code.
I am assuming that:
1. JXForms is "client code" and not part of the core. 2. The bug is in JXForms.
In any case, it is clearly a prerequisite of FOM_Cocoon.invalidate that the "request" member variable is not null. Given that, even if we find the bug that is causing the present problems, we cannot guarantee that there aren't more lurking somewhere, how do we verify that the prerequisite always holds?
A. Do we add a null check and log a message if the check fails?
B. Do we let the code throw an NPE without an explaining message?
C. Do we catch the NPE and rethrow some other kind of runtime exception?
D. Do we "assert request != null" and hope everybody is using Java 1.4? (just joking)
I agree with you that option A might hide some bugs, but I don't like option B either. While we wait for Java 1.3 to be considered obsolete and unsupported, maybe option C is the best one. What do you think?
Ugo
