users@jersey.java.net

[Jersey] Re: aroundReadFrom - close never called

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Sun, 14 Apr 2013 15:13:58 -0700

Thanks, now watching the issue!

Arun

On 4/14/13 1:00 PM, miroslav fuksa wrote:
> Hi Arun,
>
> I created a test case based on your interceptor and the close method
> is not called too (only the connection stream is closed but not the
> new supplied input stream). The close should be called for intercepted
> stream. I have created an issue:
>
> http://java.net/jira/browse/JERSEY-1845
>
> Mira
>
>
> On 13.4.2013 23:50, Arun Gupta wrote:
>> 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