Tapestry 5
  1. Tapestry 5
  2. TAP5-1854

AjaxComponentEventRequestHandler doesn't handle the case where a response has already be returned, and may append an empty JSON Object to the response

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.3.3, 5.4
    • Component/s: tapestry-core
    • Labels:
      None
    • Environment:
      WebSphere on linux, and Jetty on osx

      Description

      In committ 1155178 the removal of "if (resultProcessorInvoked.get()) return" seems to have reintroduced an old issue (#TAPESTRY-2619).
      When running on a Servlet engine that does not honor HttpResponse.getOutputStream().close() - i.e. subsequent writing to the responses outputstream will be written to the client - which is true for WebSphere but not for Jetty, the final line in AjaxComponentEventRequestHandler will write an new jsonobject to the response, resulting in an invalid json structure.

      My guess would be that the following block of code:
      -------------
      if ((!resultProcessorInvoked.get()) && queue.isPartialRenderInitialized())

      { partialRenderer.renderPartialPageMarkup(); return; }

      // Send an empty JSON reply if no value was returned from the component event handler method.
      // This is the typical behavior when an Ajax component event handler returns null.

      JSONObject reply = new JSONObject();

      resultProcessor.processResultValue(reply);
      }
      ---------------
      should be replaced with:
      ---------------
      if ((!resultProcessorInvoked.get()) && queue.isPartialRenderInitialized())
      { partialRenderer.renderPartialPageMarkup(); return; }

      // If the result processor was passed a value, then it will already have rendered, and there is nothing more to do.
      if (resultProcessorInvoked.get()) return;

      // Send an empty JSON reply if no value was returned from the component event handler method.
      // This is the typical behavior when an Ajax component event handler returns null.

      JSONObject reply = new JSONObject();

      resultProcessor.processResultValue(reply);
      }
      ------------------

        Issue Links

          Activity

          Hide
          Hudson added a comment -

          Integrated in tapestry-5.3-freestyle #12 (See https://builds.apache.org/job/tapestry-5.3-freestyle/12/)
          TAP5-1854: AjaxComponentEventRequestHandler doesn't handle the case where a response has already be returned, and may append an empty JSON Object to the response (Revision 1293020)

          Result = SUCCESS
          hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1293020
          Files :

          • /tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java
          Show
          Hudson added a comment - Integrated in tapestry-5.3-freestyle #12 (See https://builds.apache.org/job/tapestry-5.3-freestyle/12/ ) TAP5-1854 : AjaxComponentEventRequestHandler doesn't handle the case where a response has already be returned, and may append an empty JSON Object to the response (Revision 1293020) Result = SUCCESS hlship : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1293020 Files : /tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/AjaxComponentEventRequestHandler.java
          Hide
          khalil haddad added a comment -

          Hello,
          I think this issue has to be reopened. I'm running on this configuration :

          • Tapestry 5.3.7
          • Tapestry5-jQuery 3.3.7
          • WAS 8.5
          • IBM J9 VM (build 2.6, JRE 1.7.0 AIX ppc64-64 Compressed References 20141013_217026)

          When I try to access to a page which includes a jQuery datatable, I have systematically the same error :
          "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error."

          If I inspect the JSON data received from the server, I notice that an empty JSON {} is added at the end of the data like in the issue #TAPESTRY-2619 .

          The same application works fine on Tomcat 7.

          Show
          khalil haddad added a comment - Hello, I think this issue has to be reopened. I'm running on this configuration : Tapestry 5.3.7 Tapestry5-jQuery 3.3.7 WAS 8.5 IBM J9 VM (build 2.6, JRE 1.7.0 AIX ppc64-64 Compressed References 20141013_217026) When I try to access to a page which includes a jQuery datatable, I have systematically the same error : "DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error." If I inspect the JSON data received from the server, I notice that an empty JSON {} is added at the end of the data like in the issue # TAPESTRY-2619 . The same application works fine on Tomcat 7.

            People

            • Assignee:
              Howard M. Lewis Ship
              Reporter:
              Kai Lilleby
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development