Bug 348587 - RWT does not compile against javax.servlet 3.0
Summary: RWT does not compile against javax.servlet 3.0
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.5 M1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 348315
  Show dependency tree
 
Reported: 2011-06-07 11:02 EDT by Rüdiger Herrmann CLA
Modified: 2011-08-23 12:59 EDT (History)
1 user (show)

See Also:


Attachments
List of compile errors (11.88 KB, patch)
2011-06-07 11:02 EDT, Rüdiger Herrmann CLA
no flags Details | Diff
Draft patch (13.15 KB, patch)
2011-06-11 09:46 EDT, Rüdiger Herrmann CLA
no flags Details | Diff
Alternative solution (23.56 KB, patch)
2011-06-12 21:04 EDT, Rüdiger Herrmann CLA
no flags Details | Diff
Performance comparison (2.40 KB, patch)
2011-06-15 09:53 EDT, Rüdiger Herrmann CLA
no flags Details | Diff
Performance comparison II (2.76 KB, patch)
2011-06-24 09:07 EDT, Rüdiger Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rüdiger Herrmann CLA 2011-06-07 11:02:09 EDT
When compiling org.eclipse.rap.rwt against javax.servlet 3.0 from Orbit [1], I get compile errors because RWT implements these interfaces that have been extended in 3.0:
* HttpServletRequest
* HttpServletResponse
* ServletContext
I will attach the full list of compile errors.

[1] http://download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/
Comment 1 Rüdiger Herrmann CLA 2011-06-07 11:02:36 EDT
Created attachment 197506 [details]
List of compile errors
Comment 2 Rüdiger Herrmann CLA 2011-06-11 09:46:47 EDT
Created attachment 197834 [details]
Draft patch

Adds the missing methods to our implementations of HttpServletRequest, HttpServletResponse and ServletContext.
As a consequence, we need to import package javax.servlet.descriptor, which does not exist in the 2.3 API (which is the current minimal version we require). If we don't find another solution we would need to increase the minimum required servlet API to 2.5 (IIRC in this version javax.servlet.descriptor was introduced)
Comment 3 Rüdiger Herrmann CLA 2011-06-12 21:04:02 EDT
Created attachment 197869 [details]
Alternative solution

The HttpServletRequest and HttpServletResponse objects in FakeContextUtil are created as JDK proxies.
Only calls to HttpServletRequest#getSession(), #getSession(boolean) and #getLocale() are answered. All other methods throw UnsupportedOperationException.
This approach allows us to stay with the current servlet 2.3 API as a minimum requirement and is future-proof. If new methods are added to these interfaces, they continue to compile and throw an UnsupportedOperationException at runtime.
Comment 4 Rüdiger Herrmann CLA 2011-06-15 09:53:36 EDT
Created attachment 198023 [details]
Performance comparison

Compares performance of first patch (extending the interface) and alternative patch (creating proxy from interface)
Comment 5 Rüdiger Herrmann CLA 2011-06-24 09:07:29 EDT
Created attachment 198523 [details]
Performance comparison II

The performance of proxies can be greatly improved. Instead of calling Proxy#newProxyInstance() each time, the proxy class can be created once with a call to Proxy#getProxyClass(). Instantiating the proxy is then a matter of calling constructor.newInstance().
The time to create 1000 proxy instances is now down to 0.009 s (instead of 0.105 s).
Comment 6 Rüdiger Herrmann CLA 2011-06-24 13:48:51 EDT
Implementing the interfaces from javax.servlet 3.0 implies that a javax.servlet 3.0 bundle is present in the target platform. As org.eclipse.equinox.http.jetty requires javax.servlet [2.5,2.6), we would have to ship two javax.servlet bundles (2.x and 3.0)

To avoid potential conflicts and confusion that results from having two versions of the same bundle and with improved performance in creating proxies, we decided to take the proxy approach for now. With some luck, Equinox will adopt Jetty 8 (bug 309529 and bug 304152) within the 3.8 development cycle and the problem vanishes. I opened bug 350300 to reconsider this decision around 1.5 M5.

Our test fixture also implements parts of the servlet API. Where necessary, the new methods were added to the existing implementations. This in turn means that running the tests requires the servlet API 3.0 to be present.

Changes are in CVS HEAD
Comment 7 Austin Riddle CLA 2011-08-23 12:56:50 EDT
The presence of the 2 servlet bundle versions seems to break feature based launches. I cannot seem to get equinox to load the 2.5 and 3.0 versions at the same time using feature based launches.

(In reply to comment #6)
> Implementing the interfaces from javax.servlet 3.0 implies that a javax.servlet
> 3.0 bundle is present in the target platform. As org.eclipse.equinox.http.jetty
> requires javax.servlet [2.5,2.6), we would have to ship two javax.servlet
> bundles (2.x and 3.0)
> 
> To avoid potential conflicts and confusion that results from having two
> versions of the same bundle and with improved performance in creating proxies,
> we decided to take the proxy approach for now. With some luck, Equinox will
> adopt Jetty 8 (bug 309529 and bug 304152) within the 3.8 development cycle and
> the problem vanishes. I opened bug 350300 to reconsider this decision around
> 1.5 M5.
> 
> Our test fixture also implements parts of the servlet API. Where necessary, the
> new methods were added to the existing implementations. This in turn means that
> running the tests requires the servlet API 3.0 to be present.
> 
> Changes are in CVS HEAD
Comment 8 Austin Riddle CLA 2011-08-23 12:59:27 EDT
If I add additional bundles to the launch config and specify the older api, it works. Sorry, for the false alarm.

(In reply to comment #7)
> The presence of the 2 servlet bundle versions seems to break feature based
> launches. I cannot seem to get equinox to load the 2.5 and 3.0 versions at the
> same time using feature based launches.