Merge pull request #2180 from jamesagnew/im_20201118_fix_package_load_when_no_desc

Fixed NPE in package loader when package description is null
This commit is contained in:
IanMMarshall 2020-11-19 11:13:57 -05:00 committed by GitHub
commit 275b25c2cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 13 deletions

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 2180
title: "Loading a package without a description was causing a null pointer exception. This has been fixed."

View File

@ -217,11 +217,13 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac
}
boolean currentVersion = updateCurrentVersionFlagForAllPackagesBasedOnNewIncomingVersion(thePackageId, packageVersionId);
String packageDesc;
if (npmPackage.description().length() > NpmPackageVersionEntity.PACKAGE_DESC_LENGTH) {
packageDesc = npmPackage.description().substring(0, NpmPackageVersionEntity.PACKAGE_DESC_LENGTH - 4) + "...";
} else {
packageDesc = npmPackage.description();
String packageDesc = null;
if (npmPackage.description() != null) {
if (npmPackage.description().length() > NpmPackageVersionEntity.PACKAGE_DESC_LENGTH) {
packageDesc = npmPackage.description().substring(0, NpmPackageVersionEntity.PACKAGE_DESC_LENGTH - 4) + "...";
} else {
packageDesc = npmPackage.description();
}
}
if (currentVersion) {
getProcessingMessages(npmPackage).add("Marking package " + thePackageId + "#" + thePackageVersionId + " as current version");

View File

@ -39,7 +39,7 @@ public class IgInstallerDstu3Test extends BaseJpaDstu3Test {
@Autowired
private IPackageCacheManager myPackageCacheManager;
private Server myServer;
private NpmTestR4.FakeNpmServlet myFakeNpmServlet;
private NpmR4Test.FakeNpmServlet myFakeNpmServlet;
@Autowired
private INpmPackageVersionDao myPackageVersionDao;
private int myPort;
@ -50,7 +50,7 @@ public class IgInstallerDstu3Test extends BaseJpaDstu3Test {
myServer = new Server(0);
ServletHandler proxyHandler = new ServletHandler();
myFakeNpmServlet = new NpmTestR4.FakeNpmServlet();
myFakeNpmServlet = new NpmR4Test.FakeNpmServlet();
ServletHolder servletHolder = new ServletHolder(myFakeNpmServlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
myServer.setHandler(proxyHandler);

View File

@ -31,7 +31,7 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
public class NpmTestDstu3 extends BaseJpaDstu3Test {
public class NpmDstu3Test extends BaseJpaDstu3Test {
private static final Logger ourLog = LoggerFactory.getLogger(FakeNpmServlet.class);
@Autowired
@ -99,7 +99,7 @@ public class NpmTestDstu3 extends BaseJpaDstu3Test {
ourLog.info("Fail Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome();
assertEquals("Profile http://fhir.de/StructureDefinition/condition-de-basis/0.2, Element 'Condition.subject': minimum required = 1, but only found 0", oo.getIssueFirstRep().getDiagnostics());
assertEquals("Condition.subject: minimum required = 1, but only found 0 (from http://fhir.de/StructureDefinition/condition-de-basis/0.2)", oo.getIssueFirstRep().getDiagnostics());
}
}

View File

@ -64,9 +64,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
public class NpmTestR4 extends BaseJpaR4Test {
public class NpmR4Test extends BaseJpaR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(NpmTestR4.class);
private static final Logger ourLog = LoggerFactory.getLogger(NpmR4Test.class);
@Autowired
public IPackageInstallerSvc igInstaller;
@Autowired

View File

@ -19,9 +19,9 @@ import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class NpmSearchTestR4 extends BaseJpaR4Test {
public class NpmSearchR4Test extends BaseJpaR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(NpmSearchTestR4.class);
private static final Logger ourLog = LoggerFactory.getLogger(NpmSearchR4Test.class);
@Autowired
public IPackageInstallerSvc igInstaller;
@Autowired