Browse Source

Report PackProtocolExceptions to client during receive-pack

We have done this since forever with the "wanted old new ref" error,
so let's do it for other such errors thrown in the same block as well.

Change-Id: Ib3b1c7f05e31a5b3e40e85eb07b16736920a033b
stable-4.1
Dave Borowitz 10 years ago
parent
commit
6e4e34bb9e
  1. 3
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
  2. 8
      org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
  3. 5
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

3
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java

@ -76,6 +76,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.PackProtocolException;
import org.eclipse.jgit.errors.UnpackException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue;
@ -200,7 +201,7 @@ class ReceivePackServlet extends HttpServlet {
consumeRequestBody(req);
out.close();
} catch (UnpackException e) {
} catch (UnpackException | PackProtocolException e) {
// This should be already reported to the client.
log(rp.getRepository(), e.getCause());
consumeRequestBody(req);

8
org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java

@ -60,7 +60,7 @@ public class PackProtocolException extends TransportException {
* @param uri
* URI used for transport
* @param s
* message
* message, which may be shown to an end-user.
*/
public PackProtocolException(final URIish uri, final String s) {
super(uri + ": " + s); //$NON-NLS-1$
@ -73,7 +73,7 @@ public class PackProtocolException extends TransportException {
* @param uri
* URI used for transport
* @param s
* message
* message, which may be shown to an end-user.
* @param cause
* root cause exception
*/
@ -86,7 +86,7 @@ public class PackProtocolException extends TransportException {
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
* message
* message, which may be shown to an end-user.
*/
public PackProtocolException(final String s) {
super(s);
@ -96,7 +96,7 @@ public class PackProtocolException extends TransportException {
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
* message
* message, which may be shown to an end-user.
* @param cause
* root cause exception
*/

5
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

@ -1065,6 +1065,7 @@ public abstract class BaseReceivePack {
protected void recvCommands() throws IOException {
PushCertificateParser certParser = getPushCertificateParser();
FirstLine firstLine = null;
try {
for (;;) {
String line;
try {
@ -1116,6 +1117,10 @@ public abstract class BaseReceivePack {
certParser.addCommand(cmd);
}
}
} catch (PackProtocolException e) {
sendError(e.getMessage());
throw e;
}
}
static ReceiveCommand parseCommand(String line) throws PackProtocolException {

Loading…
Cancel
Save