ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: [Patch] FileUtils to use own close method
Date Wed, 15 Dec 2004 12:14:01 GMT
On Mon, 13 Dec 2004, kj <kevin.jackson@it.fts-vn.com> wrote:

> -FileUtils now uses close to close inputstreams inside itself

I've applied this part of the patch, but have some more comments on
the rest:

> +        int stackSize = s.size();
>          while (tok.hasMoreTokens()) {
>              String thisToken = tok.nextToken();
>              if (".".equals(thisToken)) {
>                  continue;
>              } else if ("..".equals(thisToken)) {
> -                if (s.size() < 2) {
> -                    throw new BuildException("Cannot resolve path " + orig);
> -                } else {
> +                if (stackSize > 2) {
>                      s.pop();
> +                } else {
> +                    throw new BuildException("Cannot resolve path " + orig);
>                  }

here s.pop() is going to change s.size(), but you don't update
stackSize.

> +        /* If we have Java => 1.4, we can use NIO
> +         * This buffer comparison simply maps the entire file into memory,
> +         * it's not concerned with memory usage - for large files this
> +         * may cause problems         
> +         */
> +        if (JavaEnvUtils.getJavaVersion().equals(JavaEnvUtils.JAVA_1_4)
> +                ||JavaEnvUtils.getJavaVersion().equals(JavaEnvUtils.JAVA_1_5)
> +                ) {

If you want to assert JDK 1.4+, you better reverse the logic for
forwards compatibility reasons.  I.e. check that we currently are not
running on JDK 1.2 or 1.3 (less than 1.2 is not possible anymore).

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message