Improvements to PortUtil to avoid reusing ports
This commit is contained in:
parent
c482d22cff
commit
3e57fdb491
|
@ -117,6 +117,11 @@ public class PortUtil {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Log who asked for the port, just in case that's useful
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
StackTraceElement previousElement = stackTraceElements[2];
|
||||
ourLog.info("Returned available port {} for: {}", nextCandidatePort, previousElement.toString());
|
||||
|
||||
/*
|
||||
* This is an attempt to make sure the port is actually
|
||||
* free before releasing it. For whatever reason on Linux
|
||||
|
@ -145,11 +150,6 @@ public class PortUtil {
|
|||
// // ignore
|
||||
// }
|
||||
|
||||
// Log who asked for the port, just in case that's useful
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
StackTraceElement previousElement = stackTraceElements[2];
|
||||
// ourLog.info("Returned available port {} for: {}", nextCandidatePort, previousElement.toString());
|
||||
|
||||
return nextCandidatePort;
|
||||
|
||||
}
|
||||
|
|
|
@ -55,11 +55,10 @@ public class PortUtilTest {
|
|||
for (int j = 0; j < portsPerTaskCount; j++) {
|
||||
int nextFreePort = portUtil.getNextFreePort();
|
||||
|
||||
try {
|
||||
ServerSocket ss = new ServerSocket();
|
||||
try (ServerSocket ss = new ServerSocket()) {
|
||||
ss.bind(new InetSocketAddress("localhost", nextFreePort));
|
||||
} catch (IOException e) {
|
||||
ourLog.error("Failure binding new port: " + e.toString(), e);
|
||||
ourLog.error("Failure binding new port " + nextFreePort + ": " + e.toString(), e);
|
||||
fail(e.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -178,37 +178,6 @@ public class SystemProviderTransactionSearchDstu3Test extends BaseJpaDstu3Test {
|
|||
assertThat(actualIds, contains(ids.subList(5, 10).toArray(new String[0])));
|
||||
}
|
||||
|
||||
/**
|
||||
* 30 searches in one batch! Whoa!
|
||||
*/
|
||||
@Test
|
||||
public void testBatchWithManyGets() {
|
||||
List<String> ids = create20Patients();
|
||||
|
||||
|
||||
Bundle input = new Bundle();
|
||||
input.setType(BundleType.BATCH);
|
||||
for (int i = 0; i < 30; i++) {
|
||||
input
|
||||
.addEntry()
|
||||
.getRequest()
|
||||
.setMethod(HTTPVerb.GET)
|
||||
.setUrl("Patient?_count=5&identifier=urn:foo|A,AAAAA" + i);
|
||||
}
|
||||
|
||||
Bundle output = ourClient.transaction().withBundle(input).execute();
|
||||
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(output));
|
||||
|
||||
assertEquals(30, output.getEntry().size());
|
||||
for (int i = 0; i < 30; i++) {
|
||||
Bundle respBundle = (Bundle) output.getEntry().get(i).getResource();
|
||||
assertEquals(5, respBundle.getEntry().size());
|
||||
assertThat(respBundle.getLink("next").getUrl(), not(nullValue()));
|
||||
List<String> actualIds = toIds(respBundle);
|
||||
assertThat(actualIds, contains(ids.subList(0, 5).toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransactionWithGetHardLimitLargeSynchronous() {
|
||||
List<String> ids = create20Patients();
|
||||
|
|
|
@ -351,7 +351,7 @@ public class SystemProviderTransactionSearchR4Test extends BaseJpaR4Test {
|
|||
.addEntry()
|
||||
.getRequest()
|
||||
.setMethod(HTTPVerb.GET)
|
||||
.setUrl("Patient?_count=5&identifier=urn:foo|A,AAAAA" + i);
|
||||
.setUrl("Patient?_count=5&_sort=family&identifier=urn:foo|A,AAAAA" + i);
|
||||
}
|
||||
|
||||
Bundle output = ourClient.transaction().withBundle(input).execute();
|
||||
|
|
Loading…
Reference in New Issue