From b13cb914d08e1d105db61166eaf2929affe54961 Mon Sep 17 00:00:00 2001 From: tomaytotomato <971697+tomaytotomato@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:27:41 +0100 Subject: [PATCH 1/2] fix https://github.com/tomaytotomato/location4j/issues/9 --- .../loader/DefaultCountriesDataLoaderImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java b/library/src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java index 5c85c5b..c523acb 100644 --- a/library/src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java +++ b/library/src/main/java/com/tomaytotomato/loader/DefaultCountriesDataLoaderImpl.java @@ -9,9 +9,13 @@ import java.util.logging.Level; import java.util.logging.Logger; +/** + * The default loader for retrieving Countries from the DEFAULT_FILE located in the location4j.jar + * + */ public class DefaultCountriesDataLoaderImpl implements CountriesDataLoader { - private static final String DEFAULT_FILE = "location4j.bin"; + private static final String DEFAULT_FILE = "/location4j.bin"; private final List countries = new ArrayList<>(); /** @@ -19,7 +23,7 @@ public class DefaultCountriesDataLoaderImpl implements CountriesDataLoader { */ public DefaultCountriesDataLoaderImpl() { var logger = Logger.getLogger(this.getClass().getName()); - try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(DEFAULT_FILE)) { + try (InputStream inputStream = getClass().getResourceAsStream(DEFAULT_FILE)) { logger.info("Attempting to load countries from " + DEFAULT_FILE); if (inputStream == null) { throw new IllegalArgumentException("File not found: " + DEFAULT_FILE); @@ -34,7 +38,6 @@ public DefaultCountriesDataLoaderImpl() { private void loadLocationsFromBinary(InputStream inputStream, Logger logger) throws IOException, ClassNotFoundException { try (var objectInputStream = new ObjectInputStream(inputStream)) { - // Read the list of countries from the binary file List loadedCountries = (List) objectInputStream.readObject(); this.countries.addAll(loadedCountries); logger.info("Successfully loaded countries binary file"); From 659b7aae1484cb816148b000b8d87aa82371875e Mon Sep 17 00:00:00 2001 From: tomaytotomato <971697+tomaytotomato@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:31:06 +0100 Subject: [PATCH 2/2] updating build.yml with new modules structure --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1c9767..82816f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,12 @@ name: Build on: push: paths: - - 'src/**' + - 'library/src/**' - 'pom.xml' - '.github/**' pull_request: paths: - - 'src/**' + - 'library/src/**' - 'pom.xml' - '.github/**'