You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Jukka Zitting <ju...@gmail.com> on 2009/02/19 14:12:19 UTC

Re: svn commit: r745847 - /jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java

Hi,

On Thu, Feb 19, 2009 at 2:00 PM,  <mr...@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

Re: svn commit: r745847 - /jackrabbit/sandbox/jackrabbit-hadoop/src/main/java/org/apache/jackrabbit/hadoop/HadoopDataRecord.java

Posted by Marcel Reutegger <ma...@day.com>.
On Thu, Feb 19, 2009 at 14:12, Jukka Zitting <ju...@gmail.com> wrote:
> 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

ah, thanks ;)

regards
 marcel