jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: ReaderInterceptor example question

From: Markus KARG <markus_at_headcrashing.eu>
Date: Mon, 22 Oct 2012 18:53:00 +0200

Ever thought about what comes out in the end actually in case an exception
happens...?

> -----Original Message-----
> From: Bill Burke [mailto:bburke_at_redhat.com]
> Sent: Montag, 22. Oktober 2012 15:39
> To: jsr339-experts_at_jax-rs-spec.java.net
> Subject: [jsr339-experts] Re: ReaderInterceptor example question
>
> I think this is more a best-practice rather than a must, what you all
> think?
>
> On 10/21/2012 8:06 AM, Jan Algermissen wrote:
> > Hi
> >
> > in the spec it says in the reader interceptor example
> >
> >
> > @Override
> > Object aroundReadFrom(ReaderInterceptorContext ctx) ... {
> >
> > InputStream old = ctx.getInputStream();
> > ctx.setInputStream(new GZIPInputStream(old));
> > try {
> >
> > return ctx.proceed();
> > } finally {
> >
> > ctx.setInputStream(old);
> > }
> >
> > }
> >
> >
> > Which means that the old input stream will *always* be restore, not
> just in the exceptional case.
> >
> > I wonder: am I just making some stupid mistake or is that a bug in
> the text or is that a pattern that has to be applied to every reader
> interceptor anyone is going to write?
> >
> >
> > Jan
> >
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com