Bug 456007 - BUG - Use of Wrong Operator in String Comparison - PatternParser.java
Summary: BUG - Use of Wrong Operator in String Comparison - PatternParser.java
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Library (show other bugs)
Version: 1.6.9   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-22 17:14 EST by david camilo espitia manrique CLA
Modified: 2015-01-07 20:07 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description david camilo espitia manrique CLA 2014-12-22 17:14:53 EST
We are currently using aspectjweaver-1.6.9.jar and during veracode analysis, this scanner found this bug in WildAnnotationTypePattern.java(line 1211,1213,1285,1288,1291,1296,1299,1302,1305,1309,1335,1783,1808 and 1819) :

Type: Use of Wrong Operator in String Comparison

Description:
Using '==' to compare two strings for equality or '!=' for inequality actually compares the object references rather than
their values. It is unlikely that this reflects the intended application logic.

Recommendations
Use the equals() method to compare strings, not the '==' or '!=' operator.
Comment 1 david camilo espitia manrique CLA 2014-12-22 17:15:32 EST
We are currently using aspectjweaver-1.6.9.jar and during veracode analysis, this scanner found this bug in PatternParser.java(line 1211,1213,1285,1288,1291,1296,1299,1302,1305,1309,1335,1783,1808 and 1819) :

Type: Use of Wrong Operator in String Comparison

Description:
Using '==' to compare two strings for equality or '!=' for inequality actually compares the object references rather than
their values. It is unlikely that this reflects the intended application logic.

Recommendations
Use the equals() method to compare strings, not the '==' or '!=' operator.
Comment 2 david camilo espitia manrique CLA 2014-12-22 17:22:17 EST
(In reply to david camilo espitia manrique from comment #0)
> We are currently using aspectjweaver-1.6.9.jar and during veracode analysis,
> this scanner found this bug in  PatternParser.java(line
> 1211,1213,1285,1288,1291,1296,1299,1302,1305,1309,1335,1783,1808 and 1819) :
> 
> Type: Use of Wrong Operator in String Comparison
> 
> Description:
> Using '==' to compare two strings for equality or '!=' for inequality
> actually compares the object references rather than
> their values. It is unlikely that this reflects the intended application
> logic.
> 
> Recommendations
> Use the equals() method to compare strings, not the '==' or '!=' operator.
Comment 3 Andrew Clement CLA 2015-01-07 20:07:16 EST
I think these aren't a real problem due to a mixture of using constants and string interning going on. There are thousands of testcases that exercise the pattern parser, and from what I can tell it is complaining about here, if these were a problem AspectJ really wouldn't be working.