summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.server
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2016-08-29 12:18:38 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2016-08-30 20:51:02 +0200
commitd52bf2eee0eb8cd05d2c62c9b86e29db2616734c (patch)
treecd2b1dcc58cf9d294647771605179366acbb2baa /org.eclipse.jgit.lfs.server
parentac856720220153a152924d08a5a4fbe262d6bdd0 (diff)
downloadjgit-d52bf2eee0eb8cd05d2c62c9b86e29db2616734c.tar.gz
jgit-d52bf2eee0eb8cd05d2c62c9b86e29db2616734c.zip
Add specific exception for LFS unavailable
Instead of returning null, LfsProtocolServlet#getLargeFileRepository should throw LfsUnavailable. If null is returned, throw a generic LfsException. Handle LfsException as an internal server error and return HTTP 500. Change-Id: I33e2a19fcc0fde8aaf0f703860c8fa8ce2de2db5 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.lfs.server')
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
index b0736bbc29..e9fb5051d0 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
@@ -44,6 +44,7 @@ package org.eclipse.jgit.lfs.server;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.http.HttpStatus.SC_FORBIDDEN;
+import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
import static org.apache.http.HttpStatus.SC_INSUFFICIENT_STORAGE;
import static org.apache.http.HttpStatus.SC_NOT_FOUND;
import static org.apache.http.HttpStatus.SC_OK;
@@ -70,6 +71,7 @@ import org.eclipse.jgit.lfs.errors.LfsInsufficientStorage;
import org.eclipse.jgit.lfs.errors.LfsRateLimitExceeded;
import org.eclipse.jgit.lfs.errors.LfsRepositoryNotFound;
import org.eclipse.jgit.lfs.errors.LfsRepositoryReadOnly;
+import org.eclipse.jgit.lfs.errors.LfsUnavailable;
import org.eclipse.jgit.lfs.errors.LfsValidationError;
import com.google.gson.FieldNamingPolicy;
@@ -104,8 +106,7 @@ public abstract class LfsProtocolServlet extends HttpServlet {
* @param path
* the path
*
- * @return the large file repository storing large files or null if the
- * request is not supported.
+ * @return the large file repository storing large files.
* @throws LfsException
* @since 4.5
*/
@@ -157,14 +158,12 @@ public abstract class LfsProtocolServlet extends HttpServlet {
try {
repo = getLargeFileRepository(request, path);
if (repo == null) {
- sendError(res, w, SC_SERVICE_UNAVAILABLE,
- "LFS is not available"); //$NON-NLS-1$
- } else {
- res.setStatus(SC_OK);
- TransferHandler handler = TransferHandler
- .forOperation(request.operation, repo, request.objects);
- gson.toJson(handler.process(), w);
+ throw new LfsException("unexpected error"); //$NON-NLS-1$
}
+ res.setStatus(SC_OK);
+ TransferHandler handler = TransferHandler
+ .forOperation(request.operation, repo, request.objects);
+ gson.toJson(handler.process(), w);
} catch (LfsValidationError e) {
sendError(res, w, SC_UNPROCESSABLE_ENTITY, e.getMessage());
} catch (LfsRepositoryNotFound e) {
@@ -177,8 +176,10 @@ public abstract class LfsProtocolServlet extends HttpServlet {
sendError(res, w, SC_BANDWIDTH_LIMIT_EXCEEDED, e.getMessage());
} catch (LfsInsufficientStorage e) {
sendError(res, w, SC_INSUFFICIENT_STORAGE, e.getMessage());
- } catch (LfsException e) {
+ } catch (LfsUnavailable e) {
sendError(res, w, SC_SERVICE_UNAVAILABLE, e.getMessage());
+ } catch (LfsException e) {
+ sendError(res, w, SC_INTERNAL_SERVER_ERROR, e.getMessage());
} finally {
w.flush();
}