Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
public final class MutableDemo {

    // java.net.HttpCookie is mutable
    public void UseMutableInput(HttpCookie cookie) {
        if (cookie == null) {
            throw new NullPointerException();
        }

        //check if cookie has expired
        if(cookie.hasExpired())
        {
          //cookie is no longer valid, handle condition
        }

          doLogic(cookie);  //cookie may have expired since time of check resulting in an exception

    }
}

...