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/28 14:40:32 UTC
[lucene-solr] 03/03: @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_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 68f87ad7e5db5883482fd8c60058a00177a1b1c1
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;
+ }
+ }
}