Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when trying to compare a String and a null-Property. #1311

Closed
p-f opened this issue Jun 12, 2019 · 2 comments

Comments

@p-f
Copy link
Collaborator

commented Jun 12, 2019

Comparing a String-type PropertyValue to a null-type PropertyValue leads to a NullPointerException.

In StringStrategy, the comparison is implemented as:

  @Override
  public int compare(String value, Object other) {
    if (other instanceof String) {
      return value.compareTo((String) other);
    }
    throw new IllegalArgumentException(String.format(
      "Incompatible types: %s, %s", value.getClass(), other.getClass()));
  }

Calling it with the other parameter null, which will be the case for null-type properties, will result in a NPE, since other.getClass() fails.

@p-f

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 12, 2019

I had a look at the javadoc description again and it seem like a NullPointerException is expected when comparing to null. The problem here is that PropertyValue.NULL_VALUE is not a primitive null value and should thus be comparable.

@p-f

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 8, 2019

Fixed in #1343

@p-f p-f closed this Aug 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.