You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/29 12:12:01 UTC

[lucene-solr] 06/22: @609 Remove returned anon classes.

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

markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 9ec63109174a4c8752d567a6d8471c0663ef456a
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Fri Aug 28 09:39:46 2020 -0500

    @609 Remove returned anon classes.
---
 .../apache/solr/servlet/SolrDispatchFilter.java    | 62 ++++++++++++----------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index cbdb8b8..f254233 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -653,21 +653,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {
   public static HttpServletRequest closeShield(HttpServletRequest request, boolean retry) {
     if (!retry) {
       return new HttpServletRequestWrapper(request) {
-
         @Override
         public ServletInputStream getInputStream() throws IOException {
-
-          return new ServletInputStreamWrapper(super.getInputStream()) {
-            @Override
-            public void close() {
-              // even though we skip closes, we let local tests know not to close so that a full understanding can take
-              // place
-              assert Thread.currentThread().getStackTrace()[2].getClassName().matches(
-                  "org\\.apache\\.(?:solr|lucene).*") ? false : true : CLOSE_STREAM_MSG;
-              this.stream = ClosedServletInputStream.CLOSED_SERVLET_INPUT_STREAM;
-            }
-          };
-
+          return new CloseShieldServletInputStreamWrapper(request.getInputStream());
         }
       };
     } else {
@@ -688,23 +676,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {
   public static HttpServletResponse closeShield(HttpServletResponse response, boolean retry) {
     if (!retry) {
       return new HttpServletResponseWrapper(response) {
-
         @Override
         public ServletOutputStream getOutputStream() throws IOException {
-
-          return new ServletOutputStreamWrapper(super.getOutputStream()) {
-            @Override
-            public void close() {
-              // even though we skip closes, we let local tests know not to close so that a full understanding can take
-              // place
-              assert Thread.currentThread().getStackTrace()[2].getClassName().matches(
-                  "org\\.apache\\.(?:solr|lucene).*") ? false
-                      : true : CLOSE_STREAM_MSG;
-              stream = ClosedServletOutputStream.CLOSED_SERVLET_OUTPUT_STREAM;
-            }
-          };
-
-
+          return new CloseShieldServletOutputStreamWrapper(response.getOutputStream());
         }
 
         @Override
@@ -713,7 +687,6 @@ public class SolrDispatchFilter extends BaseSolrFilter {
           response.getWriter().write(msg);
         }
 
-
         @Override
         public void sendError(int sc) throws IOException {
           sendError(sc, "Solr ran into an unexpected problem and doesn't seem to know more about it. There may be more information in the Solr logs.");
@@ -723,4 +696,35 @@ public class SolrDispatchFilter extends BaseSolrFilter {
       return response;
     }
   }
+
+  private static class CloseShieldServletInputStreamWrapper extends ServletInputStreamWrapper {
+    public CloseShieldServletInputStreamWrapper(ServletInputStream stream) throws IOException {
+      super(stream);
+    }
+
+    @Override
+    public void close() {
+      // even though we skip closes, we let local tests know not to close so that a full understanding can take
+      // place
+      assert Thread.currentThread().getStackTrace()[2].getClassName().matches(
+          "org\\.apache\\.(?:solr|lucene).*") ? false : true : CLOSE_STREAM_MSG;
+      this.stream = ClosedServletInputStream.CLOSED_SERVLET_INPUT_STREAM;
+    }
+  }
+
+  private static class CloseShieldServletOutputStreamWrapper extends ServletOutputStreamWrapper {
+    public CloseShieldServletOutputStreamWrapper(ServletOutputStream stream) {
+      super(stream);
+    }
+
+    @Override
+    public void close() {
+      // even though we skip closes, we let local tests know not to close so that a full understanding can take
+      // place
+      assert Thread.currentThread().getStackTrace()[2].getClassName().matches(
+          "org\\.apache\\.(?:solr|lucene).*") ? false
+              : true : CLOSE_STREAM_MSG;
+      stream = ClosedServletOutputStream.CLOSED_SERVLET_OUTPUT_STREAM;
+    }
+  }
 }