cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Oliver" <coli...@SeeBeyond.com>
Subject RE: NPEs in FlowLayer
Date Wed, 29 Oct 2003 21:19:55 GMT
OK. I see your point. But I'm guessing the bug is in the core in this
case, not JXForms. Can you describe the problem in more detail.

CHris

-----Original Message-----
From: Ugo Cei [mailto:u.cei@cbim.it] 
Sent: Wednesday, October 29, 2003 1:14 PM
To: dev@cocoon.apache.org
Subject: Re: NPEs in FlowLayer

Christopher Oliver wrote:
> 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




Mime
View raw message