Fixes NPE in HgConfigPackageResource for non-existing packages.

This commit is contained in:
Johannes Schnatterer
2018-08-07 10:44:18 +02:00
parent 869821f6db
commit adde70f090
2 changed files with 13 additions and 9 deletions

View File

@@ -80,12 +80,15 @@ public class HgConfigPackageResource {
HgPackage pkg = pkgReader.getPackage(pkgId);
// First path param cannot be null (leaving it results in 405)
if (HgInstallerFactory.createInstaller()
.installPackage(client, handler, SCMContext.getContext().getBaseDirectory(), pkg)) {
response = Response.noContent().build();
if (pkg != null) {
if (HgInstallerFactory.createInstaller()
.installPackage(client, handler, SCMContext.getContext().getBaseDirectory(), pkg)) {
response = Response.noContent().build();
} else {
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
} else {
response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
response = Response.status(Response.Status.NOT_FOUND).build();
}
return response;