Bug: Return value of String.replace(CharSequence, CharSequence) ignored
in org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer.createPattern(String)

The return value of this method should be checked. One common cause of
this warning is to invoke a method on an immutable object, thinking that
it updates the object. For example, in the following code fragment,
String dateString = getHeaderField(name);
dateString.trim();


the programmer seems to be thinking that the trim() method will update
the String referenced by dateString. But since Strings are immutable,
the trim() function returns a new String value, which is being ignored
here. The code should be corrected to:
String dateString = getHeaderField(name);
dateString = dateString.trim();


Rank: Scariest (3), confidence: High
Pattern: RV_RETURN_VALUE_IGNORED
Type: RV, Category: CORRECTNESS (Correctness)


Change-Id: I742c36e979c97ce67bbe1ef69abd8d19cfa04ec8
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
3 files changed