Hi Oleg,

> Fixed some potential problems reported by Findbugs
> 
> Modified: 
> jakarta/httpcomponents/trunk/http-core/src/java/org/apache/http/HeaderElement.java
> -            this.parameters = parameters;
> +            this.parameters = new NameValuePair[parameters.length];
> +            System.arraycopy(parameters, 0, this.parameters, 0, 
> parameters.length);

Calling <array>.clone() instead of creating a manual copy
could make use of JVM optimizations for array cloning.
Here and in several other places.

Have you considered the impact of all the new object creations?
You've spent a lot of time to minimize object creations.
Yes, returning an internally stored array is a potential risk.
But I often prefer to document "DO NOT MODIFY" in the JavaDocs
and avoid the creation of a temporary object. In particular for
seemingly fast operations such as getters, which are often
called without giving a second thought about performance.
If the object that keeps the array is itself short-lived and
not meant for use by multiple threads, then only the application
that illegaly modifies the array is at risk.


>      public HttpParams setBooleanParameter(final String name, boolean value) {
> -        setParameter(name, new Boolean(value));
> +        setParameter(name, value ? Boolean.TRUE : Boolean.FALSE);
>          return this;
>      }

You can use Boolean.valueOf(value) to avoid the ?: operator.
It's JavaDocs suggest it as an alternative to the boolean constructor:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Boolean.html#valueOf(boolean)

cheers,
  Roland



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to