Browse Source

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
tags/v4.0.0.201505191015-rc1
Shawn Pearce 9 years ago
parent
commit
a870a8a03c

+ 1
- 0
org.eclipse.jgit.http.server/resources/org/eclipse/jgit/http/server/HttpServerText.properties View File

parameterNotSet=Parameter {0} not set parameterNotSet=Parameter {0} not set
pathForParamNotFound={0} (for {1}) not found pathForParamNotFound={0} (for {1}) not found
pathNotSupported={0} not supported pathNotSupported={0} not supported
receivedCorruptObject=Cannot receive {0} into {1}
repositoryAccessForbidden=Git access forbidden repositoryAccessForbidden=Git access forbidden
repositoryNotFound=Git repository not found repositoryNotFound=Git repository not found
servletAlreadyInitialized=Servlet already initialized servletAlreadyInitialized=Servlet already initialized

+ 1
- 0
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/HttpServerText.java View File

/***/ public String parameterNotSet; /***/ public String parameterNotSet;
/***/ public String pathForParamNotFound; /***/ public String pathForParamNotFound;
/***/ public String pathNotSupported; /***/ public String pathNotSupported;
/***/ public String receivedCorruptObject;
/***/ public String repositoryAccessForbidden; /***/ public String repositoryAccessForbidden;
/***/ public String repositoryNotFound; /***/ public String repositoryNotFound;
/***/ public String servletAlreadyInitialized; /***/ public String servletAlreadyInitialized;

+ 10
- 0
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java View File

import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;


import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.UnpackException; import org.eclipse.jgit.errors.UnpackException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue; import org.eclipse.jgit.transport.InternalHttpServerGlue;


rp.receive(getInputStream(req), out, null); rp.receive(getInputStream(req), out, null);
out.close(); 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) { } catch (UnpackException e) {
// This should be already reported to the client. // This should be already reported to the client.
log(rp.getRepository(), e.getCause()); log(rp.getRepository(), e.getCause());

Loading…
Cancel
Save