Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5845 Search and fix minor errors and typos
  3. TRUNK-5940

Bad practice - Comparison of String objects using == or !=

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Could
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Core 2.4.0
    • Component/s: None
    • Labels:
    • Complexity:
      Low

      Description

      Following the SonarQube:

      This code compares a java.lang.String parameter for reference equality using the == or != operators. Requiring callers to pass only String constants or interned strings to a method is unnecessarily fragile, and rarely leads to measurable performance gains. Consider using the equals(Object) method instead.

      First case:

      Second case:

      Solution:
      Replace == comparison with equals().

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              miirochristopher Christopher Miiro
              Reporter:
              sacull Lukasz Debicki
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: