SshTestGitServer: : ensure UploadPack is closed to fix resource leak

Change-Id: Ib766f1d56b3ca7940c593ebfe0ac68fc5028a11c
This commit is contained in:
Matthias Sohn 2022-11-20 21:33:17 +01:00
parent bde09c185f
commit 396508e283
1 changed files with 7 additions and 7 deletions

View File

@ -480,13 +480,13 @@ protected GitUploadPackCommand(String command,
@Override
public void run() {
UploadPack uploadPack = new UploadPack(repository);
String gitProtocol = getEnvironment().getEnv().get("GIT_PROTOCOL");
if (gitProtocol != null) {
uploadPack
.setExtraParameters(Collections.singleton(gitProtocol));
}
try {
try (UploadPack uploadPack = new UploadPack(repository)) {
String gitProtocol = getEnvironment().getEnv()
.get("GIT_PROTOCOL");
if (gitProtocol != null) {
uploadPack.setExtraParameters(
Collections.singleton(gitProtocol));
}
uploadPack.upload(getInputStream(), getOutputStream(),
getErrorStream());
onExit(0);