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

    • Sub-task
    • Status: Closed
    • Could
    • Resolution: Fixed
    • None
    • Core 2.4.0
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: