jamesnetherton commented on a change in pull request #1988: URL: https://github.com/apache/camel-quarkus/pull/1988#discussion_r517218920
########## File path: integration-tests-support/wiremock/src/main/java/org/apache/camel/quarkus/test/wiremock/WireMockTestResourceLifecycleManager.java ########## @@ -78,30 +82,35 @@ */ @Override public void stop() { - if (server != null) { - LOG.info("Stopping WireMockServer"); - if (server.getRecordingStatus().getStatus().equals(RecordingStatus.Recording)) { - LOG.info("Stopping recording"); - SnapshotRecordResult recordResult = server.stopRecording(); - - List<StubMapping> stubMappings = recordResult.getStubMappings(); - if (isDeleteRecordedMappingsOnError()) { - for (StubMapping mapping : stubMappings) { - int status = mapping.getResponse().getStatus(); - if (status >= 300 && mapping.shouldBePersisted()) { - try { - String fileName = mapping.getName() + "-" + mapping.getId() + ".json"; - Path mappingFilePath = Paths.get("./src/test/resources/mappings/", fileName); - Files.deleteIfExists(mappingFilePath); - LOG.infof("Deleted mapping file %s as status code was %d", fileName, status); - } catch (IOException e) { - LOG.errorf("Failed to delete mapping file %s", e, mapping.getName()); + WireMockServer server = getServer(); + try { + if (server != null) { + LOG.info("Stopping WireMockServer"); + if (server.getRecordingStatus().getStatus().equals(RecordingStatus.Recording)) { + LOG.info("Stopping recording"); + SnapshotRecordResult recordResult = server.stopRecording(); + + List<StubMapping> stubMappings = recordResult.getStubMappings(); + if (isDeleteRecordedMappingsOnError()) { + for (StubMapping mapping : stubMappings) { + int status = mapping.getResponse().getStatus(); + if (status >= 300 && mapping.shouldBePersisted()) { + try { + String fileName = mapping.getName() + "-" + mapping.getId() + ".json"; + Path mappingFilePath = Paths.get("./src/test/resources/mappings/", fileName); + Files.deleteIfExists(mappingFilePath); + LOG.infof("Deleted mapping file %s as status code was %d", fileName, status); + } catch (IOException e) { + LOG.errorf("Failed to delete mapping file %s", e, mapping.getName()); + } } } } } + server.stop(); } - server.stop(); + } finally { + servers.remove(getServerKey()); Review comment: > the TestResourceLifecycleManager instance on which start() and stop() are called different? No it's the same. I have tricked myself into thinking that caching was needed. It was something odd in the Geocoder tests that made me go down this path. Let me rework things a little. I can probably drop the first commit entirely... ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org