jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Zitting <jukka.zitt...@gmail.com>
Subject Re: svn commit: r745847 - /jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java
Date Thu, 19 Feb 2009 13:12:19 GMT
Hi,

On Thu, Feb 19, 2009 at 2:00 PM,  <mreutegg@apache.org> wrote:
> +            // make sure close is only called once, otherwise HDFS complains
> +            // and throws an IOException :-/
> +            return new FilterInputStream(fs.open(path)) {
> +
> +                boolean closed = false;
> +
> +                public void close() throws IOException {
> +                    if (!closed) {
> +                        try {
> +                            super.close();
> +                        } finally {
> +                            closed = true;
> +                        }
> +                    }
> +                }
> +            };

Another one of my Commons IO hints, the AutoCloseInputStream class [1]
nicely handles this case.

[1] http://commons.apache.org/io/api-release/org/apache/commons/io/input/AutoCloseInputStream.html

BR,

Jukka Zitting

Mime
View raw message