Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

BrokenNullCheck

843785Jul 11 2008 — edited Jul 11 2008
HttpSession session = request.getSession();
String wfmsId = request.getParameter("wfmsId");
if(wfmsId == null && wfmsId.trim().equals(""))
{
session.removeAttribute("wfmsID");
}
else
{
session.setAttribute("wfmsID",wfmsId);
}

when i do the code review (using PMD tool) it shows the below description as:
The null check is broken since it will throw a Nullpointer itself.
The reason is that a method is called on the object when it is null.
It is likely that you used || instead of && or vice versa.

please suggest me.
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2008
Added on Jul 11 2008
21 comments
470 views