summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server/src/org/eclipse/jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2015-05-06 16:02:27 -0700
committerShawn Pearce <spearce@spearce.org>2015-05-06 16:02:27 -0700
commita870a8a03cf66024eae9a9425e5f699c5df8522e (patch)
treef91e3c177f753886980d7a3564f3342c22d19ce6 /org.eclipse.jgit.http.server/src/org/eclipse/jgit
parentae592cc65576d1acac2bb6a8ed12c9160b403f0a (diff)
downloadjgit-a870a8a03cf66024eae9a9425e5f699c5df8522e.tar.gz
jgit-a870a8a03cf66024eae9a9425e5f699c5df8522e.zip
Skip logging stack trace on corrupt objects
Instead of dumping a full stack trace when a client sends an invalid commit, record only a short line explaining the attempt: Cannot receive Invalid commit c0ff33...: invalid author into /tmp/jgit.git The text alone is sufficient to explain the problem and the stack trace does not lend any additional useful information. ObjectChecker is quite clear about its rejection cases. Change-Id: Ifc8cf06032489dc6431be1ba66101cf3d4299218
Diffstat (limited to 'org.eclipse.jgit.http.server/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java1
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java10
2 files changed, 11 insertions, 0 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java
index a8dd1b10c9..dff90a6c8b 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java
@@ -76,6 +76,7 @@ public class HttpServerText extends TranslationBundle {
/***/ public String parameterNotSet;
/***/ public String pathForParamNotFound;
/***/ public String pathNotSupported;
+ /***/ public String receivedCorruptObject;
/***/ public String repositoryAccessForbidden;
/***/ public String repositoryNotFound;
/***/ public String servletAlreadyInitialized;
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 9756feb0b0..cd066b0c74 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
@@ -75,6 +75,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.UnpackException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue;
@@ -191,6 +192,15 @@ class ReceivePackServlet extends HttpServlet {
rp.receive(getInputStream(req), out, null);
out.close();
+ } catch (CorruptObjectException e ) {
+ // This should be already reported to the client.
+ getServletContext().log(MessageFormat.format(
+ HttpServerText.get().receivedCorruptObject,
+ e.getMessage(),
+ ServletUtils.identify(rp.getRepository())));
+ consumeRequestBody(req);
+ out.close();
+
} catch (UnpackException e) {
// This should be already reported to the client.
log(rp.getRepository(), e.getCause());