Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3354

NullPointerException on jetty 6.1.5 with faces-redirect=true action result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.9
    • 2.0.10, 2.1.4
    • General
    • None
    • Ubuntu 11, jetty 6.1.5, MyFaces Core 2.0.9, Primefaces 3.0M3

    Description

      XHTML file:

      <p:commandButton id="saveAndGo"
      value="Save and Go"
      action="#

      {launchBean.saveAction}

      "
      ajax="false">
      </p:commandButton>

      Backing Bean method:

      public String saveAction()
      throws Exception

      { ProcessInstance process = _createProcessInstance(); return "/home/assistants/assistant?faces-redirect=true&processInstanceId=" + process.getId(); }

      Invoking the command button produces the following stack trace, causing part of the next page to terminate rendering:

      java.lang.NullPointerException
      at java.io.Writer.write(Writer.java:140)
      at org.mortbay.jetty.NCSARequestLog.log(NCSARequestLog.java:319)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:51)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
      at org.mortbay.jetty.Server.handle(Server.java:313)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
      at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
      at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

      The section of jetty code that throws the NullPointerException is as follows (offending line highlighted):

      if (_logCookies)
      {
      Cookie[] cookies = request.getCookies();
      if (cookies == null || cookies.length == 0)
      _writer.write(" -");
      else
      {
      _writer.write(" \"");
      for (int i = 0; i < cookies.length; i++)

      { if (i != 0) _writer.write(';'); _writer.write(cookies[i].getName()); _writer.write('='); _writer.write(cookies[i].getValue()); // <<-- NullPointerException }

      _writer.write("\"");
      }
      }

      Caused because the cookie oam.Flash.REDIRECT has a null value.

      Looking at the source code for Myfaces Core - org.apache.myfaces.shared.context.flash.FlashImpl, the function _restoreRedirectValue has the following code which is used to remove the cookie:

      if (cookie != null)

      { // the cookie exists means there was a redirect, regardless of the value externalContext.getRequestMap().put( FLASH_PREVIOUS_REQUEST_REDIRECT, Boolean.TRUE); // A redirect happened, so it is safe to remove the cookie, setting // the maxAge to 0 seconds. The effect is we passed FLASH_REDIRECT param // to this request object cookie.setMaxAge(0); cookie.setPath(_getCookiePath(externalContext)); cookie.setValue(null); httpResponse.addCookie(cookie); }

      My understanding is that a cookie can be removed by setMaxAge(0). Hence the setValue(null) is redundant. Removing this should fix the issue.

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            jeross Joe Rossi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: