diff --git a/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLock.java b/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLock.java index 87faa0be2..dd9d76617 100644 --- a/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLock.java +++ b/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLock.java @@ -8,7 +8,9 @@ public final class NatsJetStreamLock extends AbstractSimpleLock { private final NatsJetStreamLockProvider natsJetStreamLockProvider; - protected NatsJetStreamLock(@NonNull LockConfiguration lockConfiguration, @NonNull NatsJetStreamLockProvider natsJetStreamLockProvider) { + protected NatsJetStreamLock( + @NonNull LockConfiguration lockConfiguration, + @NonNull NatsJetStreamLockProvider natsJetStreamLockProvider) { super(lockConfiguration); this.natsJetStreamLockProvider = natsJetStreamLockProvider; } diff --git a/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLockProvider.java b/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLockProvider.java index 6fb45a037..c38eadca9 100644 --- a/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLockProvider.java +++ b/providers/jetstream/shedlock-provider-jetstream/src/main/java/net/javacrumbs/shedlock/provider/nats/jetstream/NatsJetStreamLockProvider.java @@ -1,18 +1,16 @@ package net.javacrumbs.shedlock.provider.nats.jetstream; +import static net.javacrumbs.shedlock.core.ClockProvider.now; + import io.nats.client.Connection; import io.nats.client.JetStreamApiException; import io.nats.client.api.KeyValueConfiguration; - -import static net.javacrumbs.shedlock.core.ClockProvider.now; - import java.io.IOException; import java.time.Duration; import java.util.Optional; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; - import net.javacrumbs.shedlock.core.LockConfiguration; import net.javacrumbs.shedlock.core.LockProvider; import net.javacrumbs.shedlock.core.SimpleLock; @@ -29,7 +27,7 @@ public class NatsJetStreamLockProvider implements LockProvider, AutoCloseable { private final Logger log = LoggerFactory.getLogger(NatsJetStreamLockProvider.class); - + private final ScheduledExecutorService unlockScheduler = Executors.newSingleThreadScheduledExecutor(); private final Connection connection; @@ -66,11 +64,7 @@ public Optional lock(@NonNull LockConfiguration lockConfiguration) { .name(bucketName) .ttl(lockTime) .build()); - connection - .keyValue(bucketName) - .create( - "LOCKED", - "ShedLock internal value. Do not touch.".getBytes()); + connection.keyValue(bucketName).create("LOCKED", "ShedLock internal value. Do not touch.".getBytes()); log.debug("Acquired lock for bucketName: {}", bucketName); @@ -131,8 +125,7 @@ private Runnable catchExceptions(Runnable runnable) { public void close() { unlockScheduler.shutdown(); try { - if (!unlockScheduler.awaitTermination( - Duration.ofSeconds(2).toMillis(), TimeUnit.MILLISECONDS)) { + if (!unlockScheduler.awaitTermination(Duration.ofSeconds(2).toMillis(), TimeUnit.MILLISECONDS)) { unlockScheduler.shutdownNow(); } } catch (InterruptedException ignored) {