0

I am not sure and facing strange nullpointer issue as below. could someone please help me on this in the below code

 if ((COUNTRY_CODE.equalsIgnoreCase(Country.TEST.name())) && (strCellId.matches("[0-9]*")))

is throwing nullpointer in the log file(as per line number). The only offending code i can see is strCellId.matches("[0-9]*") if strCellId is null

however, StringUtils.isNotEmpty(strCellId) is called already before we enter to if condition. please see the condition

public static boolean validateCellId(String strCellId)
{
  if (StringUtils.isNotEmpty(strCellId)) {
     //here the nullpointer is coming  
    if ((COUNTRY_CODE.equalsIgnoreCase(Country.TEST.name())) && (strCellId.matches("[0-9]*"))) {
      return true;
    }
  }

  return false;
}
zsxwing
  • 20,270
  • 4
  • 37
  • 59
Karn_way
  • 1,005
  • 3
  • 19
  • 42
  • Null pointer exception at which line? what call? – Chiron Feb 13 '14 at 14:52
  • I have updated the comment in the code. Also i believe even we call this validateCellId method with null then stringutil should take care and should not allow to enter into inner if condition. please let me know if i am missing something obvious – Karn_way Feb 13 '14 at 14:57
  • Can you provide the stack track? You may forget to initial the `COUNTRY_CODE` or `Country.TEST`. – zsxwing Feb 14 '14 at 03:18
  • its my bad. my Country was not initialized. Thanks. – Karn_way Feb 14 '14 at 04:43

1 Answers1

0

Its My Bad . @zsxwing you are right. My country was not initialized, i should have check this, i just overlooked it with confidence.Thanks

Karn_way
  • 1,005
  • 3
  • 19
  • 42