Re: JSR311: Response isn't adequate

From: Bill Burke <>
Date: Wed, 05 Mar 2008 14:31:48 -0500

Marc Hadley wrote:
> On Mar 5, 2008, at 1:12 PM, Marc Hadley wrote:
>> On Mar 3, 2008, at 1:20 PM, Stephan Koops wrote:
>>> I think, it's good, to use getOutputStream(Result), because this make
>>> it clearer, what is meant with the method. It could throw an
>>> IllegalArgumentException, if an entity is set.
>>> When using read only interfaces, very often we accpet a
>>> UnsupportedOperationException, why no here an IllegalArgumentException?
>> I guess we could do that but it might be a bit counter-intuitive for
>> users. The alternative would be to write any entity and then return
>> the output stream. The suggested method signature was intended to
>> avoid this issue but I agree that:
>> Response r = Response.created("someuri").type("sometype").build();
>> OutputStream os = so.getOutputStream(r);
>> is neater than:
>> Response r = Response.created("someuri").type("sometype").build();
>> OutputStream os = so.getOutputStream(r.getStatus(), r.getMetadata());
>> What do others think, do you prefer getOutputStream(Response) or
>> getOutputStream(int, MultivaluedMap<String, Object>).
> The following should have read: if you prefer the former, do you prefer
> throwing an IllegalArgumentException if Response has an entity or should
> the method write the entity and return a stream positioned at the end of
> it.

IMO, i'd prefer response.getOutputStream() and ditch StreamedOutput. It
would be even simpler.

But I vote for so.getOutputStream(response) if those are the only 2
choices. Don't care on the exception.

Bill Burke
JBoss, a division of Red Hat