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 2018/05/12 04:33:25 UTC
lucene-solr:master: SOLR-12290: Update assert messages about closing
request / response streams.
Repository: lucene-solr
Updated Branches:
refs/heads/master bad0e3f16 -> 4c09a13af
SOLR-12290: Update assert messages about closing request / response streams.
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4c09a13a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4c09a13a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4c09a13a
Branch: refs/heads/master
Commit: 4c09a13afb441bdce1c440263ea61cdb5f10b141
Parents: bad0e3f
Author: markrmiller <ma...@apache.org>
Authored: Fri May 11 23:31:53 2018 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Fri May 11 23:32:25 2018 -0500
----------------------------------------------------------------------
.../org/apache/solr/servlet/SolrDispatchFilter.java | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4c09a13a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
----------------------------------------------------------------------
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 0419f97..4f9ead4 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -519,6 +519,15 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}
}
+ private static String CLOSE_RESPONSE_STREAM_MSG = "Attempted close of response output stream - in general you should not do this, "
+ + "you may spoil connection reuse and possibly disrupt a client. If you must close without actually needing to close, "
+ + "use a CloseShield*Stream. Closing or flushing the stream commits the response and prevents us from modifying it and "
+ + "closing the stream prevents us from gauranteeing ourselves that streams are fully read for proper connection reuse.";
+
+ private static String CLOSE_REQUEST_STREAM_MSG = "We should not normally close the request input stream - we prefer to let the"
+ + " container manage the lifecycle of these streams and we prefer streams to remain open so we can use our own code to "
+ + "ensure streams are fully read for connection reuse.";
+
/**
* Wrap the request's input stream with a close shield. If this is a
* retry, we will assume that the stream has already been wrapped and do nothing.
@@ -542,7 +551,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
// 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 : "Attempted close of request input stream - never do this, you will spoil connection reuse and possibly disrupt a client";
+ "org\\.apache\\.(?:solr|lucene).*") ? false : true : CLOSE_REQUEST_STREAM_MSG;
this.stream = ClosedServletInputStream.CLOSED_SERVLET_INPUT_STREAM;
}
};
@@ -577,7 +586,8 @@ public class SolrDispatchFilter extends BaseSolrFilter {
// 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 : "Attempted close of response output stream - never do this, you will spoil connection reuse and possibly disrupt a client";
+ "org\\.apache\\.(?:solr|lucene).*") ? false
+ : true : CLOSE_RESPONSE_STREAM_MSG;
stream = ClosedServletOutputStream.CLOSED_SERVLET_OUTPUT_STREAM;
}
};