Author: daijy Date: Tue Sep 3 19:56:01 2013 New Revision: 1519818 URL: http://svn.apache.org/r1519818 Log: [HIVE-4586] - WebHCat should return 404 error for undefined resource (Daniel Dai)
Modified: hive/trunk/RELEASE_NOTES.txt hive/trunk/hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/CatchallExceptionMapper.java hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java Modified: hive/trunk/RELEASE_NOTES.txt URL: http://svn.apache.org/viewvc/hive/trunk/RELEASE_NOTES.txt?rev=1519818&r1=1519817&r2=1519818&view=diff ============================================================================== --- hive/trunk/RELEASE_NOTES.txt (original) +++ hive/trunk/RELEASE_NOTES.txt Tue Sep 3 19:56:01 2013 @@ -15,6 +15,7 @@ Release Notes - Hive - Version 0.11.0 * [HIVE-4326] - Clean up remaining items in hive/hcatalog/historical/trunk ** Bug + * [HIVE-4586] - WebHCat should return 404 error for undefined resource * [HIVE-4820] - webhcat_config.sh should set default values for HIVE_HOME and HCAT_PREFIX that work with default build tree structure * [HIVE-2264] - Hive server is SHUTTING DOWN when invalid queries beeing executed. * [HIVE-2332] - If all of the parameters of distinct functions are exists in group by columns, query fails in runtime Modified: hive/trunk/hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/CatchallExceptionMapper.java URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/CatchallExceptionMapper.java?rev=1519818&r1=1519817&r2=1519818&view=diff ============================================================================== --- hive/trunk/hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/CatchallExceptionMapper.java (original) +++ hive/trunk/hcatalog/webhcat/svr/src/main/java/org/apache/hcatalog/templeton/CatchallExceptionMapper.java Tue Sep 3 19:56:01 2013 @@ -26,6 +26,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.jetty.http.HttpStatus; +import com.sun.jersey.api.NotFoundException; + /** * Map all exceptions to the Jersey response. This lets us have nice * results in the error body. @@ -37,6 +39,9 @@ public class CatchallExceptionMapper public Response toResponse(Exception e) { LOG.error(e.getMessage(), e); + if (e instanceof NotFoundException) { + return SimpleWebException.buildMessage(HttpStatus.NOT_FOUND_404, null, e.getMessage()); + } return SimpleWebException.buildMessage(HttpStatus.INTERNAL_SERVER_ERROR_500, null, e.getMessage()); } } Modified: hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java?rev=1519818&r1=1519817&r2=1519818&view=diff ============================================================================== --- hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java (original) +++ hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java Tue Sep 3 19:56:01 2013 @@ -102,7 +102,7 @@ public class TestWebHCatE2e { @Test public void invalidPath() throws IOException { MethodCallRetVal p = doHttpCall(templetonBaseUrl + "/no_such_mapping/database", HTTP_METHOD_TYPE.GET); - Assert.assertEquals(p.getAssertMsg(), HttpStatus.INTERNAL_SERVER_ERROR_500, p.httpStatusCode); + Assert.assertEquals(p.getAssertMsg(), HttpStatus.NOT_FOUND_404, p.httpStatusCode); } /** * tries to drop table in a DB that doesn't exist