tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anil K. Vijendran" <>
Subject Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core
Date Fri, 29 Oct 1999 00:50:28 GMT
James Todd wrote:

> i wonder why that method doesn't have a throws
> clause (ie IllegalArgumentExcpetion) as part of
> it's signature to begin with.

Cause IAE is a RuntimeException.

> i think wrapping it and checking for null is the
> safest way to go.


> now, regarding principle here, i agree and in this
> case i chose to "handle" null or badly formed query
> string arguments by nulling out the associated
> paramters hashtable. the fact that nothing is in
> the catch block (ie ignoring the exception) is just
> a result of how this logic is implemented ... put
> another way, this implementation knowingly ignores
> this excpetion and effectively nulls the parmaters
> if an error is thrown. i see no need to propogate
> this exception further so i stopped it in it's tracks.

I'm sorry; I don't believe this is the raison d'etre of exceptions. (I have done
stuff like this in the past but not as pervasively as I'm seeing here. This should
not become a pattern)  Exceptions should NOT be used for control flow or indicators
of results. If you want an indicator of the result then modify the method signature
to give you a return value.

In the first place how did you figure out that HttpUtils.parseQS throws an exception?
By reading the source, right? Why is there such reliance on white box behaviour (or
the implementation of other methods)? What if the exception is thrown for other
reasons, i.e for example, if I modify it later to deal with some more error cases?
(You don't want to revisit core.RequestImpl.setQS everytime HttpUtils.parseQS
changes, do you?) Agreed you read the source but why are you catching Exception there
instead of IAE? (If pQS throws say a NPE, then you end up catching and silently
consuming it and it becomes REALLY hard and time consuming to get to the bottom of
such things.)

The reason I'm sensitive about this is because some of us have spent inordinate
amounts of time debugging while a simple stack trace would've been a life saver.

Peace, Anil +<:-)

View raw message