2

How is the null check statement below throwing a Nullpointer Exception? Is the request perhaps null? I'm confused Somebody help.

if(!getTGTid(request).equalsIgnoreCase(null) || 
!getTGTid(request).equalsIgnoreCase("")) {

Method

private String getTGTid(HttpServletRequest request) {
return request.getParameter("tgtId"); 
}
OAM
  • 105
  • 8

1 Answers1

1

If getTGTid(request) is null, getTGTid(request).equalsIgnoreCase(null) will throw NullPointerException.

Use

if (getTGTid(request) != null && !getTGTid(request).equalsIgnoreCase(""))
Eran
  • 387,369
  • 54
  • 702
  • 768