ppalaga commented on a change in pull request #1988: URL: https://github.com/apache/camel-quarkus/pull/1988#discussion_r517184827
########## 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: How is the caching supposed to work, when you remove the server on every stop()? I thought the cache was meant to keep the same server instance for multiple test classes referring to the same TestResourceLifecycleManager. Maybe you meant something different? ---------------------------------------------------------------- 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