Bug 57144

Summary: Improve ClientAbortException.getMessage() to provide non-null message in Tomcat 7
Product: Tomcat 7 Reporter: Konstantin Kolinko <knst.kolinko>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: enhancement    
Priority: P2    
Version: 7.0.56   
Target Milestone: ---   
Hardware: PC   
OS: All   

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.