Skip to content

ZoneFactory.createZone() uses == for String comparison #43

Description

@prashantpiyush1111

createZone() compares String values using == instead of .equals().

== compares object references rather than the actual String contents. This can work accidentally when callers pass string literals because of Java String interning, but it will fail when zoneId is created dynamically, such as from configuration, user input, string concatenation, or new String(...).

For example:

String zoneId = new String("US/Pacific");

In this case, zoneId == "US/Pacific" evaluates to false, causing createZone() to return null.

Please use .equals() for String comparison (or a String switch) so the comparison is based on the actual value.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions