From a1cb61bcf6e48b03961e9ee73eb6b1327af28304 Mon Sep 17 00:00:00 2001 From: Roger Floriano <31597636+petruki@users.noreply.github.com> Date: Wed, 4 Dec 2024 21:19:16 -0800 Subject: [PATCH] Fixes #336 - Invalid path for Snapshot location (#337) --- pom.xml | 2 +- .../com/github/switcherapi/client/SwitcherExecutorImpl.java | 5 ++--- .../switcherapi/client/SwitcherSnapshotAutoUpdateTest.java | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 040cbc54..cc2ac0da 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ com.github.switcherapi switcher-client jar - 2.2.1 + 2.2.2 Switcher Client Switcher Client SDK for working with Switcher API diff --git a/src/main/java/com/github/switcherapi/client/SwitcherExecutorImpl.java b/src/main/java/com/github/switcherapi/client/SwitcherExecutorImpl.java index abc9f8fb..20baf552 100644 --- a/src/main/java/com/github/switcherapi/client/SwitcherExecutorImpl.java +++ b/src/main/java/com/github/switcherapi/client/SwitcherExecutorImpl.java @@ -8,11 +8,10 @@ import com.github.switcherapi.client.service.remote.ClientRemote; import com.github.switcherapi.client.utils.SnapshotLoader; import com.github.switcherapi.client.utils.SwitcherUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Objects; - public abstract class SwitcherExecutorImpl implements SwitcherExecutor { private static final Logger logger = LoggerFactory.getLogger(SwitcherExecutorImpl.class); @@ -40,7 +39,7 @@ protected Domain initializeSnapshotFromAPI(ClientRemote clientRemote) final Snapshot snapshot = clientRemote.resolveSnapshot(); final String snapshotLocation = switcherProperties.getValue(ContextKey.SNAPSHOT_LOCATION); - if (Objects.nonNull(snapshotLocation)) { + if (StringUtils.isNotBlank(snapshotLocation)) { SnapshotLoader.saveSnapshot(snapshot, snapshotLocation, environment); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotAutoUpdateTest.java b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotAutoUpdateTest.java index fbb4ceb5..cf7a4e60 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotAutoUpdateTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotAutoUpdateTest.java @@ -173,6 +173,7 @@ void shouldUpdateSnapshot_remote_inMemory() { .apiKey("[API_KEY]") .environment("generated_mock_default_5") .local(true) + .snapshotLocation("") .snapshotAutoLoad(true) .snapshotAutoUpdateInterval("1m")); @@ -182,6 +183,7 @@ void shouldUpdateSnapshot_remote_inMemory() { //test CountDownHelper.wait(2); assertEquals(2, Switchers.getSnapshotVersion()); + assertTrue(Files.notExists(Paths.get("/generated_mock_default_5.json"))); } @Test