-5
if (responseEntity.getBody().getMeta().getCode() != ApiExceptionEnum.SUCCESS.code()) {
    return null;
}

code like this,

responseEntity.getBody().getMeta().getCode() -> Integer  1
ApiExceptionEnum.SUCCESS.code() -> Integer 1

sometimes it will return null !!

why ?

the response is from redis

Uwe Allner
  • 3,057
  • 7
  • 31
  • 42
Jason Yu
  • 58
  • 1
  • 7

1 Answers1

0

In this case == or != checks whether compared objects are pointing to the same place in memory. To compare values stored in compared objects, use .equals() method inherited by all Java objects from Object class.

Przemysław Moskal
  • 3,321
  • 2
  • 8
  • 20
  • when the Interger is 1 , why it doesn't aotuunboxing? – Jason Yu Dec 18 '17 at 11:50
  • @JasonYu Because equals() method is inherited by objects, primitive types are not considered as objects in Java and they aren't inheriting anything. If you call this method it means that you want to compare objects, not primitive types – Przemysław Moskal Dec 18 '17 at 12:02