ppalaga commented on a change in pull request #1988:
URL: https://github.com/apache/camel-quarkus/pull/1988#discussion_r517204637



##########
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:
       I see. Is the TestResourceLifecycleManager instance on which start() and 
stop() are called different?
   A comment somewhere would be nice so that future readers do not need to 
wonder.




----------------------------------------------------------------
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


Reply via email to