Bug 58534

Summary: Repeated Conditional Test
Product: Tomcat 8 Reporter: Anthony Whitford <anthony>
Component: WebSocketAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: trivial    
Priority: P2    
Version: 8.0.x-trunk   
Target Milestone: ----   
Hardware: Macintosh   
OS: Mac OS X 10.1   
Attachments: Patch to remove repeated conditional tests
Patch for similar problem for AprEndpoint

Description Anthony Whitford 2015-10-25 19:19:46 UTC
In org.apache.tomcat.websocket.pojo.PojoMethodMapping, there are cases like this:

    if (currentClazz == clazzPojo ||
        (currentClazz != clazzPojo && !isMethodOverride(open, method))) {


The clause 'currentClazz != clazzPojo' is redundant since we know 'currentClazz == clazzPojo' is false.


This is repeated several times.
Comment 1 Anthony Whitford 2015-10-25 19:20:50 UTC
Created attachment 33208 [details]
Patch to remove repeated conditional tests
Comment 2 Anthony Whitford 2015-10-25 19:25:04 UTC
Created attachment 33209 [details]
Patch for similar problem for AprEndpoint

I discovered the same problem with org.apache.tomcat.util.net.AprEndpoint, so please see the second patch too.
Comment 3 Violeta Georgieva 2015-10-27 13:55:44 UTC
Hi,

Thanks for the report and the patch.
The fix is available in trunk, 8.0.x (for 8.0.29 onwards) and 7.0.x (for 7.0.66
onwards)

Regards,
Violeta