diff options
author | Harald Musum <musum@verizonmedia.com> | 2022-10-31 12:11:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 12:11:32 +0100 |
commit | ffd568166c37540d7b5f31e77522f2c35075414c (patch) | |
tree | 0785dfe22532c16f91662db3de163bacfd374a8c /configserver | |
parent | 5c7c221d98120c0eaf826f06c2a24bd305024ae6 (diff) | |
parent | 26eb6c17a2a253de73c181949627fdabb7b23061 (diff) |
Merge pull request #24638 from vespa-engine/hmusum/handle-both-schemas-and-searchdefinitions-in-app-better
Better error handling if both schemas/ and searchdefinitions/ exist [run-systemtest]
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index 89ca0265008..b36e8d2d37c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -841,15 +841,24 @@ public class SessionRepository { File schemasDir = applicationDir.resolve(ApplicationPackage.SCHEMAS_DIR.getRelative()).toFile(); File sdDir = applicationDir.resolve(ApplicationPackage.SEARCH_DEFINITIONS_DIR.getRelative()).toFile(); if (sdDir.exists() && sdDir.isDirectory()) { - File[] sdFiles = sdDir.listFiles(); - if (sdFiles != null) { - Files.createDirectories(schemasDir.toPath()); - Arrays.asList(sdFiles).forEach(file -> Exceptions.uncheck( - () -> Files.move(file.toPath(), - schemasDir.toPath().resolve(file.toPath().getFileName()), - StandardCopyOption.REPLACE_EXISTING))); + try { + File[] sdFiles = sdDir.listFiles(); + if (sdFiles != null) { + Files.createDirectories(schemasDir.toPath()); + Arrays.asList(sdFiles).forEach(file -> Exceptions.uncheck( + () -> Files.move(file.toPath(), + schemasDir.toPath().resolve(file.toPath().getFileName()), + StandardCopyOption.REPLACE_EXISTING))); + } + Files.delete(sdDir.toPath()); + } catch (IOException | UncheckedIOException e) { + if (schemasDir.exists() && schemasDir.isDirectory()) + throw new InvalidApplicationException( + "Both " + ApplicationPackage.SCHEMAS_DIR.getRelative() + "/ and " + ApplicationPackage.SEARCH_DEFINITIONS_DIR + + "/ exist in application package, please remove " + ApplicationPackage.SEARCH_DEFINITIONS_DIR + "/", e); + else + throw e; } - Files.delete(sdDir.toPath()); } } |