GitServlet: allow to override default error handlers

GitServlet delegates repository access over HTTP to the GitFilter
servlet.

GitServlet, in turn, can be extended by jgit consumers to provide custom
logic when handling such operations.

This is the case, for example, with Gerrit Code Review, which provides
custom behavior with a GitOverHttpServlet [1].

Among possible customizations, the ability of specifying a custom error
handler for UploadPack and ReceivePack was already introduced in
GitFilter by Idd3b87d6b and I9c708aa5a2, respectively.

However the `setUploadPackErrorHandler` and `setReceivePackErrorHandler`
methods were never added to the GitServlet.

Expose the `setUploadPackErrorHandler` and `setReceivePackErrorHandler`
methods to the GitServlet, so that consumers of the jgit library might
specify custom error handlers.

[1] https://gerrit.googlesource.com/gerrit/+/refs/heads/stable-3.2/java/com/google/gerrit/httpd/GitOverHttpServlet.java#95

Change-Id: I712d485ff68b662b48c71ef75650c5a155950d23
This commit is contained in:
Antonio Barone 2021-09-01 12:04:07 +02:00 committed by Matthias Sohn
parent 59aec9b15a
commit 8470771510
1 changed files with 22 additions and 0 deletions

View File

@ -112,6 +112,17 @@ public void setUploadPackFactory(UploadPackFactory<HttpServletRequest> f) {
gitFilter.setUploadPackFactory(f);
}
/**
* Set a custom error handler for git-upload-pack.
*
* @param h
* A custom error handler for git-upload-pack.
* @since 5.9.1
*/
public void setUploadPackErrorHandler(UploadPackErrorHandler h) {
gitFilter.setUploadPackErrorHandler(h);
}
/**
* Add upload-pack filter
*
@ -136,6 +147,17 @@ public void setReceivePackFactory(ReceivePackFactory<HttpServletRequest> f) {
gitFilter.setReceivePackFactory(f);
}
/**
* Set a custom error handler for git-receive-pack.
*
* @param h
* A custom error handler for git-receive-pack.
* @since 5.9.1
*/
public void setReceivePackErrorHandler(ReceivePackErrorHandler h) {
gitFilter.setReceivePackErrorHandler(h);
}
/**
* Add receive-pack filter
*