diff --git a/src/main/java/org/aksw/iguana/cc/query/handler/QueryHandler.java b/src/main/java/org/aksw/iguana/cc/query/handler/QueryHandler.java index dc043b98..8a3f0dad 100644 --- a/src/main/java/org/aksw/iguana/cc/query/handler/QueryHandler.java +++ b/src/main/java/org/aksw/iguana/cc/query/handler/QueryHandler.java @@ -141,7 +141,7 @@ public record Pattern(@JsonProperty(required = true) URI endpoint, Long limit, B public Pattern(URI endpoint, Long limit, Boolean caching) { this.endpoint = endpoint; this.limit = limit == null ? 2000 : limit; - this.caching = true; + this.caching = caching == null || caching; } } } @@ -184,19 +184,20 @@ public QueryHandler(Config config) throws IOException { if (Files.exists(instancePath)) { LOGGER.info("Already existing query pattern instances have been found and will be reused. Delete the following file to regenerate them: {}", instancePath); querySource = createQuerySource(instancePath); - } - final List instances = instantiatePatternQueries(querySource, config.pattern); - if (config.pattern.caching) { - Files.createFile(instancePath); - try (var writer = Files.newBufferedWriter(instancePath)) { - for (String instance : instances) { - writer.write(instance); - writer.newLine(); + } else { + final List instances = instantiatePatternQueries(querySource, config.pattern); + if (config.pattern.caching) { + Files.createFile(instancePath); + try (var writer = Files.newBufferedWriter(instancePath)) { + for (String instance : instances) { + writer.write(instance); + writer.newLine(); + } } + querySource = createQuerySource(instancePath); + } else { + querySource = new StringListQuerySource(instances); } - querySource = createQuerySource(instancePath); - } else { - querySource = new StringListQuerySource(instances); } }