Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 411616

Summary: Application crash with very long messages
Product: [RT] RAP Reporter: Ralf Sternberg <rsternberg>
Component: IncubatorAssignee: Project Inbox <rap.incubator-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: sergeysavenko
Version: 2.1   
Target Milestone: 2.2 RC1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Quick fix none

Description Ralf Sternberg CLA 2013-06-25 11:24:01 EDT
* Open http://rap.eclipsesource.com/rapdemo/examples#ckeditor
* Enter a very long text (tried with 250 lines of "Lorem ipsum dolor sit amet.")
* Press "Show source" button
* Enjoy the crash

Stacktrace:

org.eclipse.rap.json.ParseException: Expected value at 1:0
	org.eclipse.rap.json.JsonParser.error(JsonParser.java:316)
	org.eclipse.rap.json.JsonParser.expected(JsonParser.java:312)
	org.eclipse.rap.json.JsonParser.readValue(JsonParser.java:74)
	org.eclipse.rap.json.JsonParser.parse(JsonParser.java:33)
	org.eclipse.rap.json.JsonValue.readFrom(JsonValue.java:88)
	org.eclipse.rap.json.JsonObject.readFrom(JsonObject.java:99)
	org.eclipse.rap.rwt.internal.protocol.ProtocolUtil.getClientMessage(ProtocolUtil.java:66)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.isSessionShutdown(LifeCycleServiceHandler.java:227)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:77)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:66)
	org.eclipse.rap.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:119)
	org.eclipse.rap.rwt.engine.RWTServlet.handleRequest(RWTServlet.java:106)
	org.eclipse.rap.rwt.engine.RWTServlet.doPost(RWTServlet.java:99)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.eclipse.rap.rwt.osgi.internal.CutOffContextPathWrapper.service(CutOffContextPathWrapper.java:106)
	org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
	org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
	org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Comment 1 Ralf Sternberg CLA 2013-06-25 11:26:42 EDT
The issue might not be related to the DropDown widget at all, but to the message size. The response contains the header "Transfer-Encoding: chunked".
Comment 2 Ivan Furnadjiev CLA 2013-07-09 11:56:51 EDT
*** Bug 412575 has been marked as a duplicate of this bug. ***
Comment 3 Ivan Furnadjiev CLA 2013-07-17 08:31:42 EDT
Reproducible with workbench demo deployed as war in GlassFish 4. The demo crashes at startup with the same exception. Response headers of the first post request:
...
Content-Type	application/json;charset=UTF-8
Date	Wed, 17 Jul 2013 12:24:21 GMT
Server	GlassFish Server Open Source Edition 4.0
Set-Cookie	settingStore=1374060776553_0; Expires=Tue, 15-Oct-2013 12:24:20 GMT
Transfer-Encoding	chunked
X-Powered-By	Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)
Comment 4 Ivan Furnadjiev CLA 2013-07-17 11:16:07 EDT
Created attachment 233559 [details]
Quick fix

The reason for this issue is still under investigation. Nevertheless, this patch seems to fix the problem with GlassFish 4. It replaces the usage of request.getReader() in ProtocolUtil#getClientMessage() with manually constructed buffered reader from request input stream. The problem occurs only in RAP 2.1 where the minimal JSON parser is used. I can't reproduce it with RAP 2.0.
Comment 5 Ivan Furnadjiev CLA 2013-07-18 11:11:49 EDT
I can't reproduce the crash from the description with Tomcat 5.5.35, 6.0.37 and 7.0.42 installed locally (Windows 7 x64).
Comment 6 Ivan Furnadjiev CLA 2013-11-15 09:22:10 EST
The experiments with the Glassfish 4 indicate that it's indeed a servlet container bug and that using request.getInputStream() instead of getReader() reliably works around this problem. Applied this workaround in commit e57579bf2b4b6eb80d9377ae7ec8d336a99c9d68.