[jax-rs-spec users] [jsr339-experts] Re: Filters, Interceptors and Priorities

From: Markus KARG <>
Date: Sat, 27 Oct 2012 15:05:00 +0200

> >> try
> >> {
> >> setOutputStream(GZIPOutputStream);
> >> proceed();
> >> }
> >> finally
> >> {
> >> gzipOutputStream.finish();
> >> }
> >
> > This can be done easily with a filter instead, which can call
> finish()
> > on itself as soon as close() is invoked. So I do not need an entity
> > interceptor for this:
> >
> > filter(req,resp) {
> > ...
> >
> > setEntityStream(MyFilterWhichCallsFinishAtClose(getEntityStream()));
> > }
> >
> Not following you. You mean wrap the OutputSTream to call finish() on
> close()? I'm not even sure it is guaranteed close() will be called (or
> should be called). Plus, not pushing/popping the outputstream is real
> bad practice.

Yes, doing finish() inside of @Overwrite'd close(). I tried it and it works
like a charm using Jersey 2.0 M08-1 and JAX-RS 2.0 M12. I do not see why a
stream should not be closed, as obviously there is no other way to detect
the end of the stream? If that MUST NOT be done, the spec must clearly
forbid it.

And why is this a bad practice? What negative side effects shall it produce?
If that MUST be done, the spec must clearly enforce it.

See, I do not have a problem with the current API design (well I do have in
fact, but the real showstoppers are already found in JIRA). I have a problem
with the fact that the spec and JavaDocs let open so much questions that Jan
and I (and in part Sergey) had to ask lots of possibly dumb questions to you
and Marek. And see, we *did* follow the discussions, but just did not
understood still so we had to ask again and again. What the real problem is
is not the API, it is the deficit of information in the spec and the

So what I learned after three weeks of public review is that the same
questions will surely come up at the user community after final release and
the spec leads should deal with that. My proposal would be that the spec and
JavaDocs are overhauled to answer unambiguously all the "dumb" questions
Jan, Sergey and me asked in past weeks.

Thanks for you patience