[groovy] branch GROOVY_3_0_X updated: GROOVY-9819: bump jsp-api/servlet-api versions to 2.3.3/4.0.1 (port to 3_0_X)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch GROOVY_3_0_X updated: GROOVY-9819: bump jsp-api/servlet-api versions to 2.3.3/4.0.1 (port to 3_0_X)

paulk
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new 1dbe95a  GROOVY-9819: bump jsp-api/servlet-api versions to 2.3.3/4.0.1 (port to 3_0_X)
1dbe95a is described below

commit 1dbe95aeb91fd278028df5d920708d615dd4bf36
Author: Paul King <[hidden email]>
AuthorDate: Tue Nov 17 20:49:11 2020 +1000

    GROOVY-9819: bump jsp-api/servlet-api versions to 2.3.3/4.0.1 (port to 3_0_X)
---
 build.gradle                                       |  2 ++
 subprojects/groovy-servlet/build.gradle            |  4 ++--
 .../main/java/groovy/servlet/ServletBinding.java   | 22 +++++++++++++++++++++-
 .../groovy/servlet/ServletBindingTest.groovy       |  8 ++++++++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/build.gradle b/build.gradle
index bd718f6..1cf7c94 100644
--- a/build.gradle
+++ b/build.gradle
@@ -163,6 +163,8 @@ ext {
     junit5Version = '5.7.0'
     junit5PlatformVersion = '1.7.0'
     jcipAnnotationsVersion = '1.0'
+    jspApiVersion = '2.3.3'
+    servletApiVersion = '4.0.1'
 }
 
 dependencies {
diff --git a/subprojects/groovy-servlet/build.gradle b/subprojects/groovy-servlet/build.gradle
index 9a20eea..710c7f8 100644
--- a/subprojects/groovy-servlet/build.gradle
+++ b/subprojects/groovy-servlet/build.gradle
@@ -17,10 +17,10 @@
  *  under the License.
  */
 dependencies {
-    api('javax.servlet:javax.servlet-api:3.0.1') { dep ->
+    api("javax.servlet:javax.servlet-api:$servletApiVersion") { dep ->
         provided dep
     }
-    api('javax.servlet:jsp-api:2.0') { dep ->
+    api("javax.servlet:jsp-api:$jspApiVersion") { dep ->
         provided dep
         exclude(group: 'javax.servlet', module: 'servlet-api')
     }
diff --git a/subprojects/groovy-servlet/src/main/java/groovy/servlet/ServletBinding.java b/subprojects/groovy-servlet/src/main/java/groovy/servlet/ServletBinding.java
index b626969..d17a8aa 100644
--- a/subprojects/groovy-servlet/src/main/java/groovy/servlet/ServletBinding.java
+++ b/subprojects/groovy-servlet/src/main/java/groovy/servlet/ServletBinding.java
@@ -27,6 +27,7 @@ import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
+import javax.servlet.WriteListener;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.ByteArrayOutputStream;
@@ -131,8 +132,27 @@ public class ServletBinding extends Binding {
         }
         public ServletOutputStream getOutputStream() {
             return new ServletOutputStream() {
+                @Override
+                public boolean isReady() {
+                    try {
+                        return getResponseStream().isReady();
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+
+                @Override
+                public void setWriteListener(WriteListener writeListener) {
+                    try {
+                        getResponseStream().setWriteListener(writeListener);
+                    } catch (IOException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+
+                @Override
                 public void write(int b) throws IOException {
-                    getResponseStream().write(b);                    
+                    getResponseStream().write(b);
                 }
                 public void close() throws IOException {
                     getResponseStream().close();
diff --git a/subprojects/groovy-servlet/src/test/groovy/groovy/servlet/ServletBindingTest.groovy b/subprojects/groovy-servlet/src/test/groovy/groovy/servlet/ServletBindingTest.groovy
index 079c7cc..c8becfc 100644
--- a/subprojects/groovy-servlet/src/test/groovy/groovy/servlet/ServletBindingTest.groovy
+++ b/subprojects/groovy-servlet/src/test/groovy/groovy/servlet/ServletBindingTest.groovy
@@ -23,6 +23,7 @@ import groovy.xml.MarkupBuilder
 
 import javax.servlet.ServletContext
 import javax.servlet.ServletOutputStream
+import javax.servlet.WriteListener
 import javax.servlet.http.HttpServletRequest
 import javax.servlet.http.HttpServletResponse
 import javax.servlet.http.HttpSession
@@ -257,5 +258,12 @@ class ServletBindingTest extends GroovyTestCase {
  * Test specific sub class to stub out the ServletOutputStream class.
  */
 class OutputStreamStub extends ServletOutputStream {
+    @Override
     void write(int x) { }
+
+    @Override
+    boolean isReady() { return false }
+
+    @Override
+    void setWriteListener(WriteListener writeListener) {}
 }