ICEpush
  1. ICEpush
  2. PUSH-18

Null pointer exception in createPushId is causing bugus pushIds to be sent to the client

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Alpha3
    • Component/s: Push Server
    • Labels:
      None
    • Environment:
      Affects Glassfish (and probably others as well)

      Description

      It seems that sometime the javacript call for ice.push.createPushId will send a request without the browser id header. This in turn causes a null pointer exception on the server which will response with an error html snippet in place of the request push id. Even though the status of the response is 500 - the consumer of the js client api will not be told an error occurred and will simply be handed the snippet of HTML as the push id. This causes much grief in the subsequent API calls.

      the following stacktrace is seen in the GF3 server logs:

      java.lang.RuntimeException: java.lang.RuntimeException: wrapped Exception: java.lang.NullPointerException
      at org.icepush.servlet.ICEpushServlet.service(ICEpushServlet.java:26)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
      at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
      at java.lang.Thread.run(Thread.java:637)
      Caused by: java.lang.RuntimeException: wrapped Exception: java.lang.NullPointerException
      at org.icepush.servlet.MainServlet.service(MainServlet.java:66)
      at org.icepush.servlet.ICEpushServlet.service(ICEpushServlet.java:20)
      ... 25 more
      Caused by: java.lang.NullPointerException
      at org.icepush.servlet.BrowserDispatcher.getBrowserIDFromCookie(BrowserDispatcher.java:76)
      at org.icepush.servlet.BrowserDispatcher.service(BrowserDispatcher.java:47)
      at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:44)
      at org.icepush.servlet.MainServlet.service(MainServlet.java:44)
      ... 26 more

        Activity

        Hide
        Patrick Wilson added a comment -

        Suggested solution:

        1.) fix javascript api methods to throw a JS exception if the status of the response is not 200.
        2.) fix either the javascript to ensure a broswer id cookie is created on startup - or allow the server to gracefully assign a new browser id if one was not provided with the request.

        Thoughts?

        Show
        Patrick Wilson added a comment - Suggested solution: 1.) fix javascript api methods to throw a JS exception if the status of the response is not 200. 2.) fix either the javascript to ensure a broswer id cookie is created on startup - or allow the server to gracefully assign a new browser id if one was not provided with the request. Thoughts?
        Hide
        Patrick Wilson added a comment -

        Not sure if you are the one to assign this too... It needs the attention of someone on the core team.

        Show
        Patrick Wilson added a comment - Not sure if you are the one to assign this too... It needs the attention of someone on the core team.
        Hide
        Carlo Guglielmin added a comment - - edited

        I've attached a TCP analysis from Wireshark.

        This might be related, basically the ice.pushid is missing which causes a 500 response from the server, which seems like it can send some browsers (the Firefox line) into a constant loop of GETs.

        Show
        Carlo Guglielmin added a comment - - edited I've attached a TCP analysis from Wireshark. This might be related, basically the ice.pushid is missing which causes a 500 response from the server, which seems like it can send some browsers (the Firefox line) into a constant loop of GETs.
        Hide
        Brad Kroeger added a comment -

        Seeing the same thing with the Wicket application.

        Firefox console:

        items.join is not a function
        anonymous("1g4d9zdxx:278", " ")code.icepush (line 307)
        anonymous()code.icepush (line 102)
        enlistPushIDsWithBrowser(Object name=ids)code.icepush (line 1598)
        enlistPushIDWithWindow("1g4d9zdxx:278")code.icepush (line 1611)
        anonymous("1g4d9zdxx:278", function())code.icepush (line 1628)
        icechat-wicket?wicket:interface=:2:::)icechat-...ce=:2:::: (line 36)
        [Break on this error] return items.join(separator);\n

        Firefox page source has the following:

        <script wicket:id="pushJavascript" type="text/javascript">ice.push.register('1g4d9zdxx:278',function()

        {window.location.reload();}

        );</script>

        Output from server:

        Caused by: java.lang.RuntimeException: Query does not contain parameter named: ice.pushid
        at org.icepush.servlet.ServletRequestResponse.checkExistenceOf(ServletRequestResponse.java:304)
        at org.icepush.servlet.ServletRequestResponse.getParameterAsStrings(ServletRequestResponse.java:141)
        at org.icepush.BlockingConnectionServer$3.service(BlockingConnectionServer.java:82)
        at org.icepush.BlockingConnectionServer.service(BlockingConnectionServer.java:109)
        at org.icepush.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:46)
        at org.icepush.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:51)
        at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:44)
        at org.icepush.servlet.BrowserDispatcher$BrowserEntry.service(BrowserDispatcher.java:105)
        at org.icepush.servlet.BrowserDispatcher.service(BrowserDispatcher.java:49)
        at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:44)
        at org.icepush.servlet.MainServlet.service(MainServlet.java:44)
        at org.icepush.servlet.ICEpushServlet.service(ICEpushServlet.java:20)
        ... 30 more

        Show
        Brad Kroeger added a comment - Seeing the same thing with the Wicket application. Firefox console: items.join is not a function anonymous("1g4d9zdxx:278", " ")code.icepush (line 307) anonymous()code.icepush (line 102) enlistPushIDsWithBrowser(Object name=ids)code.icepush (line 1598) enlistPushIDWithWindow("1g4d9zdxx:278")code.icepush (line 1611) anonymous("1g4d9zdxx:278", function())code.icepush (line 1628) icechat-wicket?wicket:interface=:2::: )icechat-...ce=:2:::: (line 36) [Break on this error] return items.join(separator);\n Firefox page source has the following: <script wicket:id="pushJavascript" type="text/javascript">ice.push.register('1g4d9zdxx:278',function() {window.location.reload();} );</script> Output from server: Caused by: java.lang.RuntimeException: Query does not contain parameter named: ice.pushid at org.icepush.servlet.ServletRequestResponse.checkExistenceOf(ServletRequestResponse.java:304) at org.icepush.servlet.ServletRequestResponse.getParameterAsStrings(ServletRequestResponse.java:141) at org.icepush.BlockingConnectionServer$3.service(BlockingConnectionServer.java:82) at org.icepush.BlockingConnectionServer.service(BlockingConnectionServer.java:109) at org.icepush.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:46) at org.icepush.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:51) at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:44) at org.icepush.servlet.BrowserDispatcher$BrowserEntry.service(BrowserDispatcher.java:105) at org.icepush.servlet.BrowserDispatcher.service(BrowserDispatcher.java:49) at org.icepush.servlet.PathDispatcher.service(PathDispatcher.java:44) at org.icepush.servlet.MainServlet.service(MainServlet.java:44) at org.icepush.servlet.ICEpushServlet.service(ICEpushServlet.java:20) ... 30 more
        Hide
        Brad Kroeger added a comment -

        Forgot to add the following was also in the FF console:

        uncaught exception: Cannot find value for cookie: ice.pushids

        Show
        Brad Kroeger added a comment - Forgot to add the following was also in the FF console: uncaught exception: Cannot find value for cookie: ice.pushids
        Hide
        Mircea Toma added a comment -

        ice.push.createPushId, ice.push.notify, ice.push.addGroupMember, ice.push.removeGroupMember function are now throwing an exception if an error occurs on the server side (HTTP 500 received). This will allow the API client code to be more informed about what is going on the server and take appropriate measures such as a retry or fail fast.

        Show
        Mircea Toma added a comment - ice.push.createPushId, ice.push.notify, ice.push.addGroupMember, ice.push.removeGroupMember function are now throwing an exception if an error occurs on the server side (HTTP 500 received). This will allow the API client code to be more informed about what is going on the server and take appropriate measures such as a retry or fail fast.
        Hide
        Mircea Toma added a comment - - edited

        If some browsers are able to send an AJAX request before the page is fully loaded then any call to ice.push.* function should be done in an 'onload' callback:

        window.onload = function()

        { var id = ice.push.createPushId(); .... .... }

        ;

        This approach will ensure that Ajax requests are sent after the page loaded and browser ID cookie was set.

        Show
        Mircea Toma added a comment - - edited If some browsers are able to send an AJAX request before the page is fully loaded then any call to ice.push.* function should be done in an 'onload' callback: window.onload = function() { var id = ice.push.createPushId(); .... .... } ; This approach will ensure that Ajax requests are sent after the page loaded and browser ID cookie was set.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Patrick Wilson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: