From 4c15882a6bfc4fbd9fb0a39902d9fe46fc31e7ee Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Wed, 23 Oct 2024 10:20:06 -0400 Subject: [PATCH] ensure JVM ID is nulled if connection fails --- src/main/java/io/cryostat/targets/TargetJvmIdUpdateJob.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/cryostat/targets/TargetJvmIdUpdateJob.java b/src/main/java/io/cryostat/targets/TargetJvmIdUpdateJob.java index 0bac9462c..e28bb2e53 100644 --- a/src/main/java/io/cryostat/targets/TargetJvmIdUpdateJob.java +++ b/src/main/java/io/cryostat/targets/TargetJvmIdUpdateJob.java @@ -63,8 +63,8 @@ private void updateTargetJvmId(long id) { QuarkusTransaction.requiringNew() .run( () -> { + Target target = Target.getTargetById(id); try { - Target target = Target.getTargetById(id); target.jvmId = connectionManager .executeDirect( @@ -74,10 +74,11 @@ private void updateTargetJvmId(long id) { .map(JvmIdentifier::getHash) .await() .atMost(connectionTimeout); - target.persist(); } catch (Exception e) { + target.jvmId = null; logger.error(e); } + target.persist(); }); } }