From 598d06313ba690b69e7625805c9b2183e260cc5d Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 5 Mar 2024 17:57:46 +0300 Subject: [PATCH] Remove shutdown hook register on supplied Launch --- .../java/com/epam/reportportal/karate/ReportPortalHook.java | 3 +-- .../com/epam/reportportal/karate/ReportPortalPublisher.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/epam/reportportal/karate/ReportPortalHook.java b/src/main/java/com/epam/reportportal/karate/ReportPortalHook.java index 749684f..b3d49dc 100644 --- a/src/main/java/com/epam/reportportal/karate/ReportPortalHook.java +++ b/src/main/java/com/epam/reportportal/karate/ReportPortalHook.java @@ -83,7 +83,6 @@ public ReportPortalHook() { public ReportPortalHook(Supplier launchSupplier) { launch = new MemoizingSupplier<>(launchSupplier); - shutDownHook = registerShutdownHook(this::finishLaunch); } /** @@ -120,7 +119,7 @@ public void finishLaunch() { System.getProperty("rp.launch.id") ); launchObject.finish(rq); - if (Thread.currentThread() != shutDownHook) { + if (shutDownHook != null && Thread.currentThread() != shutDownHook) { unregisterShutdownHook(shutDownHook); } } diff --git a/src/main/java/com/epam/reportportal/karate/ReportPortalPublisher.java b/src/main/java/com/epam/reportportal/karate/ReportPortalPublisher.java index eb6bb13..7c0701b 100644 --- a/src/main/java/com/epam/reportportal/karate/ReportPortalPublisher.java +++ b/src/main/java/com/epam/reportportal/karate/ReportPortalPublisher.java @@ -69,7 +69,6 @@ public ReportPortalPublisher(ReportPortal reportPortal) { public ReportPortalPublisher(Supplier launchSupplier) { launch = new MemoizingSupplier<>(launchSupplier); - shutDownHook = registerShutdownHook(this::finishLaunch); } /** @@ -114,7 +113,7 @@ public void finishLaunch() { System.getProperty("rp.launch.id") ); launchObject.finish(rq); - if (Thread.currentThread() != shutDownHook) { + if (shutDownHook != null && Thread.currentThread() != shutDownHook) { unregisterShutdownHook(shutDownHook); } }