Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
3.0-M2
-
None
Description
The HttpBindingSupport class has a general exception reporter that handles uncaught exceptions by sending them back to the client as HTML messages. The code looks like this:
PrintWriter writer = response.getWriter();
writer.println("Request failed with error: " + e);
e.printStackTrace(writer);
But the HttpMarshaler class, in preparing the normal response, has the following line:
getTransformer().toResult(message.getContent(), new StreamResult(response.getOutputStream()));
If this transformer fails, the error reporting logic will get an IllegalStateException, because you cannot ask for the response writer after you have already obtained the response output stream. The solution is to ask for the output stream again (you are allowed to get it more than once) and created a new PrintWriter: The following code seems to work just fine:
PrintWriter writer = null;
try
catch (IllegalStateException ise)
{ OutputStream os = response.getOutputStream(); writer = new PrintWriter (os); } writer.println("Request failed with error: " + e);
e.printStackTrace(writer);
A corrected version of the source file (you also need another import statement) is attached.