users@jersey.java.net

[Jersey] aroundReadFrom - close never called

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Sat, 13 Apr 2013 14:50:51 -0700

I created a aroundReadFrom interceptor and deployed on the client-side:

ric.setInputStream(new FilterInputStream(ric.getInputStream()) {

             final ByteArrayOutputStream baos = new ByteArrayOutputStream();

             @Override
             public int read() throws IOException {
                 System.out.println("read");
                 return super.read();
             }

             @Override
             public int read(byte[] b) throws IOException {
                 System.out.println("read(byte[]");
                 return super.read(b);
             }

             @Override
             public int read(byte[] b, int off, int len) throws
IOException {
                 System.out.println("read(byte[], int, int)");
                 baos.write(b, off, len);
                 return super.read(b, off, len);
             }

             @Override
             public void close() throws IOException {
                 System.out.println("### " + baos.toString());
                 super.close();
             }
         });

A POST request invokes only the read(byte[], int, int) method and close
is never called.

Is that the expected behavior ?

Arun

-- 
http://twitter.com/arungupta
http://blogs.oracle.com/arungupta