summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2015-05-06 15:47:34 -0700
committerShawn Pearce <spearce@spearce.org>2015-05-06 15:47:34 -0700
commitae592cc65576d1acac2bb6a8ed12c9160b403f0a (patch)
treead9319cca5f35efc6b7e18982a3db8df1c7d9f25 /org.eclipse.jgit.http.server
parent72857c52ece8aa4c1dc8f7145c1b0fdbfc82a297 (diff)
downloadjgit-ae592cc65576d1acac2bb6a8ed12c9160b403f0a.tar.gz
jgit-ae592cc65576d1acac2bb6a8ed12c9160b403f0a.zip
Add repository name to failures in HTTP server log
If UploadPack or ReceivePack has an exception record an identifier associated with the repository as part of the log message. This can help the HTTP admin track down the offending repository and take action to repair the root cause. Change-Id: I58f22b33cdb40994f044a26fba9fe965b45be51d
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r--org.eclipse.jgit.http.server/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties4
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java13
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java10
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java15
5 files changed, 32 insertions, 11 deletions
diff --git a/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF
index 94d62f34d6..2c76d74548 100644
--- a/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.http.server/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: javax.servlet;version="[2.5.0,3.0.0)",
javax.servlet.http;version="[2.5.0,3.0.0)",
org.eclipse.jgit.errors;version="[4.0.0,4.1.0)",
+ org.eclipse.jgit.internal.storage.dfs;version="[4.0.0,4.1.0)",
org.eclipse.jgit.internal.storage.file;version="[4.0.0,4.1.0)",
org.eclipse.jgit.lib;version="[4.0.0,4.1.0)",
org.eclipse.jgit.nls;version="[4.0.0,4.1.0)",
diff --git a/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties b/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties
index dbc5bf7b8f..83c39277c1 100644
--- a/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties
+++ b/org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties
@@ -11,8 +11,8 @@ encodingNotSupportedByThisLibrary={0} "{1}": not supported by this library.
expectedRepositoryAttribute=Expected Repository attribute
filterMustNotBeNull=filter must not be null
internalServerError=Internal server error
-internalErrorDuringReceivePack=Internal error during receive-pack
-internalErrorDuringUploadPack=Internal error during upload-pack
+internalErrorDuringReceivePack=Internal error during receive-pack to {0}
+internalErrorDuringUploadPack=Internal error during upload-pack from {0}
internalServerErrorRequestAttributeWasAlreadySet=Internal server error, request attribute {0} was already set when {1} was invoked.
invalidBoolean=Invalid boolean {0} = {1}
invalidIndex=Invalid index: {0}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
index a8e312d3f0..9756feb0b0 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
@@ -62,6 +62,7 @@ import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
import static org.eclipse.jgit.util.HttpSupport.HDR_USER_AGENT;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.List;
import javax.servlet.Filter;
@@ -192,14 +193,12 @@ class ReceivePackServlet extends HttpServlet {
out.close();
} catch (UnpackException e) {
// This should be already reported to the client.
- getServletContext().log(
- HttpServerText.get().internalErrorDuringReceivePack,
- e.getCause());
+ log(rp.getRepository(), e.getCause());
consumeRequestBody(req);
out.close();
} catch (Throwable e) {
- getServletContext().log(HttpServerText.get().internalErrorDuringReceivePack, e);
+ log(rp.getRepository(), e);
if (!rsp.isCommitted()) {
rsp.reset();
sendError(req, rsp, SC_INTERNAL_SERVER_ERROR);
@@ -207,4 +206,10 @@ class ReceivePackServlet extends HttpServlet {
return;
}
}
+
+ private void log(Repository git, Throwable e) {
+ getServletContext().log(MessageFormat.format(
+ HttpServerText.get().internalErrorDuringReceivePack,
+ ServletUtils.identify(git)), e);
+ }
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
index 8d56d84c97..042ccf3dd7 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ServletUtils.java
@@ -62,6 +62,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.internal.storage.dfs.DfsRepository;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
@@ -273,6 +274,15 @@ public final class ServletUtils {
return ObjectId.fromRaw(md.digest()).getName();
}
+ static String identify(Repository git) {
+ if (git instanceof DfsRepository) {
+ return ((DfsRepository) git).getDescription().getRepositoryName();
+ } else if (git.getDirectory() != null) {
+ return git.getDirectory().getPath();
+ }
+ return "unknown";
+ }
+
private ServletUtils() {
// static utility class only
}
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
index 7aefcbd809..443eebb4d4 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
@@ -61,6 +61,7 @@ import static org.eclipse.jgit.http.server.ServletUtils.getRepository;
import static org.eclipse.jgit.util.HttpSupport.HDR_USER_AGENT;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.List;
import javax.servlet.Filter;
@@ -76,9 +77,9 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue;
import org.eclipse.jgit.transport.RefAdvertiser.PacketLineOutRefAdvertiser;
+import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.UploadPackInternalServerErrorException;
-import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
import org.eclipse.jgit.transport.resolver.UploadPackFactory;
@@ -203,14 +204,12 @@ class UploadPackServlet extends HttpServlet {
} catch (UploadPackInternalServerErrorException e) {
// Special case exception, error message was sent to client.
- getServletContext().log(
- HttpServerText.get().internalErrorDuringUploadPack,
- e.getCause());
+ log(up.getRepository(), e.getCause());
consumeRequestBody(req);
out.close();
} catch (Throwable e) {
- getServletContext().log(HttpServerText.get().internalErrorDuringUploadPack, e);
+ log(up.getRepository(), e);
if (!rsp.isCommitted()) {
rsp.reset();
sendError(req, rsp, SC_INTERNAL_SERVER_ERROR);
@@ -218,4 +217,10 @@ class UploadPackServlet extends HttpServlet {
return;
}
}
+
+ private void log(Repository git, Throwable e) {
+ getServletContext().log(MessageFormat.format(
+ HttpServerText.get().internalErrorDuringUploadPack,
+ ServletUtils.identify(git)), e);
+ }
}