Hi Greg,
Moving over to the users list. Thanks for finding this. I found the
underlying problem, which is due a really silly bug in the
implementation of the Response.getMetadata implementation. I will fix
it today.
Paul.
On May 2, 2008, at 6:17 PM, Giacovelli, Greg wrote:
> I have noticed that this method seems to replay the state of the
> response it is based off of. And it seems as if it duplicates the
> data. For example,
> Given the code:
>
> //SomeResource Class GET method
> …
> catch(SubException e){
> Response response = ResponseFactory.getResponseBasedOffException(e);
> ResponseBuilder builder = ResponseBuilder.fromResponse(response);
> builder = builder.entity("Could not process overall Request").type
> ("text/plain");
> throw new WebApplicationException(builder.build());
> }
>
>
> …
> // Inside of ResponseFactory
> Response getResponseBasedOffException(RootException e){
> ResponseBuilder builder = Response.status(500);
> builder = builder.header(“Exception”,e.getClass().getName());
> return builder.build();
> }
>
> // SubException inherits from RootException
>
> Response getResponseBasedOffException(SubException e){
> ResponseBuilder builder = Response.fromResponse
> (getResponseBasedOffException((RootException)e);
> builder.header(“SubException-Data”,e.getSpecialString());
> return builder.build();
>
> }
>
> The response it generates is this:
>
>
> HTTP/1.1 1 Exception: SubException
> Exception: SubException
> Exception: SubException
> Exception: SubException
> SubException-Data: myspecial String
> SubException-Data: myspecial String
> SubException-Data: myspecial String
> Content-Type: text/plain
> Date: Fri, 02 May 2008 16:12:03 GMT
> Server: Apache-Coyote/1.1
> Connection: close
>
> Could not process overall Request
>
>
> Is this just a misunderstanding of how the ResponseBuilder and the
> factory method of Response.fromResponse(Response) work? Or is this
> really a bug?
>
>
> -Greg Giacovelli
>