myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Rossi (Created) (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Created] (MYFACES-3354) NullPointerException on jetty 6.1.5 with faces-redirect=true action result
Date Tue, 11 Oct 2011 19:55:12 GMT
NullPointerException on jetty 6.1.5 with faces-redirect=true action result
--------------------------------------------------------------------------

                 Key: MYFACES-3354
                 URL: https://issues.apache.org/jira/browse/MYFACES-3354
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 2.0.9
         Environment: Ubuntu 11, jetty 6.1.5, MyFaces Core 2.0.9, Primefaces 3.0M3
            Reporter: Joe Rossi
            Priority: Minor


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.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message