You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2012/12/22 01:32:37 UTC
svn commit: r1425213 - in /lucene/dev/branches/branch_4x: ./ dev-tools/
lucene/ lucene/analysis/
lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/
lucene/benchmark/ lucene/codecs/ lucene/core/
lucene/core/src/test/org/apache/l...
Author: hossman
Date: Sat Dec 22 00:32:36 2012
New Revision: 1425213
URL: http://svn.apache.org/viewvc?rev=1425213&view=rev
Log:
SOLR-3972: Fix ShowFileRequestHandler to not log a warning in the (expected) situation of a file not found. (merge r1425207)
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/BUILD.txt (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt (props changed)
lucene/dev/branches/branch_4x/lucene/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/MIGRATE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/README.txt (props changed)
lucene/dev/branches/branch_4x/lucene/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java (props changed)
lucene/dev/branches/branch_4x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_4x/lucene/build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/codecs/ (props changed)
lucene/dev/branches/branch_4x/lucene/common-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.cfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/index.40.optimized.nocfs.zip (props changed)
lucene/dev/branches/branch_4x/lucene/demo/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/grouping/ (props changed)
lucene/dev/branches/branch_4x/lucene/highlighter/ (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (props changed)
lucene/dev/branches/branch_4x/lucene/join/ (props changed)
lucene/dev/branches/branch_4x/lucene/licenses/ (props changed)
lucene/dev/branches/branch_4x/lucene/memory/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/module-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/queries/ (props changed)
lucene/dev/branches/branch_4x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_4x/lucene/sandbox/ (props changed)
lucene/dev/branches/branch_4x/lucene/site/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/suggest/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/tools/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/solr/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/README.txt (props changed)
lucene/dev/branches/branch_4x/solr/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/solr/build.xml (props changed)
lucene/dev/branches/branch_4x/solr/cloud-dev/ (props changed)
lucene/dev/branches/branch_4x/solr/common-build.xml (props changed)
lucene/dev/branches/branch_4x/solr/contrib/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/ (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt (props changed)
lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/scripts/ (props changed)
lucene/dev/branches/branch_4x/solr/site/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/testlogging.properties (props changed)
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1425213&r1=1425212&r2=1425213&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Sat Dec 22 00:32:36 2012
@@ -372,6 +372,9 @@ Bug Fixes
* SOLR-4134: Standard (XML) request writer cannot "set" multiple values into
multivalued field with partial updates. (Luis Cappa Banda, Will Butler, shalin)
+* SOLR-3972: Fix ShowFileRequestHandler to not log a warning in the
+ (expected) situation of a file not found. (hossman)
+
Other Changes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java?rev=1425213&r1=1425212&r2=1425213&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java Sat Dec 22 00:32:36 2012
@@ -154,8 +154,9 @@ public class ShowFileRequestHandler exte
// Make sure the file exists, is readable and is not a hidden file
if (!zkClient.exists(adminFile, true)) {
- throw new SolrException(ErrorCode.BAD_REQUEST, "Can not find: "
- + adminFile);
+ rsp.setException(new SolrException(ErrorCode.NOT_FOUND, "Can not find: "
+ + adminFile));
+ return;
}
// Show a directory listing
@@ -210,7 +211,8 @@ public class ShowFileRequestHandler exte
try {
configdir = new File( loader.getClassLoader().getResource(loader.getConfigDir()).toURI() );
} catch (URISyntaxException e) {
- throw new SolrException( ErrorCode.FORBIDDEN, "Can not access configuration directory!");
+ rsp.setException(new SolrException( ErrorCode.FORBIDDEN, "Can not access configuration directory!", e));
+ return;
}
}
String fname = req.getParams().get("file", null);
@@ -232,12 +234,16 @@ public class ShowFileRequestHandler exte
// Make sure the file exists, is readable and is not a hidden file
if( !adminFile.exists() ) {
- throw new SolrException( ErrorCode.BAD_REQUEST, "Can not find: "+adminFile.getName()
- + " ["+adminFile.getAbsolutePath()+"]" );
+ rsp.setException(new SolrException
+ ( ErrorCode.NOT_FOUND, "Can not find: "+adminFile.getName()
+ + " ["+adminFile.getAbsolutePath()+"]" ));
+ return;
}
if( !adminFile.canRead() || adminFile.isHidden() ) {
- throw new SolrException( ErrorCode.BAD_REQUEST, "Can not show: "+adminFile.getName()
- + " ["+adminFile.getAbsolutePath()+"]" );
+ rsp.setException(new SolrException
+ ( ErrorCode.NOT_FOUND, "Can not show: "+adminFile.getName()
+ + " ["+adminFile.getAbsolutePath()+"]" ));
+ return;
}
// Show a directory listing
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java?rev=1425213&r1=1425212&r2=1425213&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java Sat Dec 22 00:32:36 2012
@@ -24,7 +24,10 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.SolrException;
import org.apache.solr.util.ExternalPaths;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.response.SolrQueryResponse;
import org.junit.BeforeClass;
import java.io.IOException;
@@ -43,6 +46,41 @@ public class ShowFileRequestHandlerTest
createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
}
+ public void test404ViaHttp() throws SolrServerException {
+ SolrServer server = getSolrServer();
+ QueryRequest request = new QueryRequest(params("file",
+ "does-not-exist-404.txt"));
+ request.setPath("/admin/file");
+ try {
+ QueryResponse resp = request.process(server);
+ fail("didn't get 404 exception");
+ } catch (SolrException e) {
+ assertEquals(404, e.code());
+ }
+ }
+
+ public void test404Locally() throws Exception {
+
+ // we need to test that executing the handler directly does not
+ // throw an exception, just sets the exception on the response.
+ initCore("solrconfig.xml", "schema.xml");
+ try {
+ // bypass TestHarness since it will throw any exception found in the
+ // response.
+ SolrCore core = h.getCore();
+ SolrQueryResponse rsp = new SolrQueryResponse();
+ core.execute(core.getRequestHandler("/admin/file"),
+ req("file", "does-not-exist-404.txt"), rsp);
+ assertNotNull("no exception in response", rsp.getException());
+ assertTrue("wrong type of exception: " + rsp.getException().getClass(),
+ rsp.getException() instanceof SolrException);
+ assertEquals(404, ((SolrException)rsp.getException()).code());
+
+ } catch (Exception e) {
+ assertNull("Should not have caught an exception", e);
+ }
+ }
+
public void testDirList() throws SolrServerException {
SolrServer server = getSolrServer();
//assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4