Bug 57144 - Improve ClientAbortException.getMessage() to provide non-null message in Tomcat 7
Summary: Improve ClientAbortException.getMessage() to provide non-null message in Tomc...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.56
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-26 00:20 UTC by Konstantin Kolinko
Modified: 2014-10-26 12:13 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2014-10-26 00:20:49 UTC
For reference - r1634258 and r1360468

I was backporting a test for BZ 54928 from Tomcat 8 to Tomcat 7 and noted a difference in output. The code was:

 log.info("Exception caught " + e.getMessage());

In Tomcat 7 (7.0.56+) it resulted in
 "Exception caught null"
while on Tomcat 8 (8.0.14+) it was
 "Exception caught Software caused connection abort: socket write error".

When I changed the code to use e.toString() it became:
in Tomcat 7:
 "Exception caught ClientAbortException:  java.net.SocketException: Software caused connection abort: socket write error"
in Tomcat 8:
 "Exception caught org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error"


The difference comes from r1360468. Essentially Tomcat 8 delegates processing to original implementations in java.lang.Throwable, while the old code in Tomcat 7 has its own implementation of getMessage() and toString().

There are two differences:

a) The Throwable(Throwable cause) constructor in Java initializes message as cause.toString() while in ClientAbortException(Throwable) the message defaults to being null.

b) Throwable.toString() uses the fully qualified name of a class, while ClientAbortException.toString() prints just "ClientAbortException".
Comment 1 Konstantin Kolinko 2014-10-26 12:13:59 UTC
Fixed in Tomcat 7 by r1634311 and will be in 7.0.57 onwards.