Skip to content

Commit a8c7b36

Browse files
committed
Fix config file hash calculation
1 parent 781926d commit a8c7b36

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/backend/AbstractContainerBackend.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,20 @@ protected boolean isPrivileged() {
266266
}
267267

268268

269+
private File getPathToConfigFile() {
270+
String path = environment.getProperty("spring.config.location");
271+
if (path != null) {
272+
return Paths.get(path).toFile();
273+
}
274+
275+
File file = Paths.get(ContainerProxyApplication.CONFIG_FILENAME).toFile();
276+
if (file.exists()) {
277+
return file;
278+
}
279+
280+
return null;
281+
}
282+
269283
/**
270284
* Calculates a hash of the config file (i.e. application.yaml).
271285
*/
@@ -281,11 +295,8 @@ private String calculateInstanceId() throws IOException, NoSuchAlgorithmExceptio
281295
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
282296
objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
283297

284-
File file = Paths.get(ContainerProxyApplication.CONFIG_FILENAME).toFile();
285-
if (!file.exists()) {
286-
file = Paths.get(ContainerProxyApplication.CONFIG_DEMO_PROFILE).toFile();
287-
}
288-
if (!file.exists()) {
298+
File file = getPathToConfigFile();
299+
if (file == null) {
289300
// this should only happen in tests
290301
instanceId = "unknown-instance-id";
291302
return instanceId;

0 commit comments

Comments
 (0)