tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anil K. Vijendran" <Anil.Vijend...@eng.sun.com>
Subject Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Request.java
Date Thu, 28 Oct 1999 23:41:17 GMT
I strongly agree. Throw/catch is expensive first. Secondly it is just BAD on
principle to catch and ignore exceptions.

It should be pretty straightforward to just test for null, not call
parseQueryString but set the parameters to null.

Hans Bergsten wrote:

> gonzo@hyperreal.org wrote:
> >
> > gonzo       99/10/28 15:54:56
> >
> >   Modified:    src/share/org/apache/tomcat/core Tag: TOMCAT_J2EE_10F_102199
> >                         Request.java
> > [...]
> >        public void setQueryString(String queryString) {
> >            this.queryString = queryString;
> >   +
> >   +        Hashtable parameters = null;
> >   +
> >   +        // catch any parse exceptions
> >   +
> >   +        try {
> >   +            parameters = HttpUtils.parseQueryString(queryString);
> >   +        } catch (Exception e) {
> >   +        }
> >   +
> >   +        this.parameters = parameters;
> >        }
>
> Why not test queryString for null and only call parseQueryString if it
> has a value? Throwing and catching an exception is pretty expensive and
> should be avoided, IMHO, when it's possible. You may still want to wrap
> the parseQueryString in a try/catch block to handle possible queryString
> syntax errors, but I suggest you add the null test as well.
>
> Hans
> --
> Hans Bergsten           hans@gefionsoftware.com
> Gefion Software         http://www.gefionsoftware.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

--
Peace, Anil +<:-)



Mime
View raw message