diff options
4 files changed, 16 insertions, 20 deletions
diff --git a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java index 957531b9f7f..6888626633b 100644 --- a/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java +++ b/config-application-package/src/main/java/com/yahoo/config/model/application/provider/PreGeneratedFileRegistry.java @@ -20,31 +20,28 @@ public class PreGeneratedFileRegistry implements FileRegistry { private final String fileSourceHost; private final Map<String, String> path2Hash = new LinkedHashMap<>(); - private static String entryDelimiter = "\t"; - private static Pattern entryDelimiterPattern = Pattern.compile(entryDelimiter, Pattern.LITERAL); + private static final String entryDelimiter = "\t"; + private static final Pattern entryDelimiterPattern = Pattern.compile(entryDelimiter, Pattern.LITERAL); private PreGeneratedFileRegistry(Reader readerArg) { - BufferedReader reader = new BufferedReader(readerArg); - try { + try (BufferedReader reader = new BufferedReader(readerArg)) { fileSourceHost = reader.readLine(); if (fileSourceHost == null) - throw new RuntimeException("Error while reading pre generated file registry"); + throw new RuntimeException("Error while reading pre-generated file registry"); String line; while ((line = reader.readLine()) != null) { addFromLine(line); } - } catch(IOException e) { - throw new RuntimeException("Error while reading pre generated file registry", e); - } finally { - try { - reader.close(); - } catch(IOException e) {} + } catch (IOException e) { + throw new RuntimeException("Error while reading pre-generated file registry", e); } } private void addFromLine(String line) { String[] parts = entryDelimiterPattern.split(line); + if (parts.length < 2) + throw new IllegalArgumentException("Cannot split '" + line + "' into two parts"); addEntry(parts[0], parts[1]); } @@ -58,8 +55,7 @@ public class PreGeneratedFileRegistry implements FileRegistry { builder.append(registry.fileSourceHost()).append('\n'); for (FileRegistry.Entry entry : entries) { - builder.append(entry.relativePath).append(entryDelimiter).append(entry.reference.value()). - append('\n'); + builder.append(entry.relativePath).append(entryDelimiter).append(entry.reference.value()).append('\n'); } return builder.toString(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java index 7484e0cd9a0..1b5be1c2f97 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/Admin.java @@ -264,7 +264,8 @@ public class Admin extends AbstractConfigProducer implements Serializable { FileDistributor fileDistributor = fileDistribution.getFileDistributor(); HostResource hostResource = hostSystem().getHostByHostname(fileDistributor.fileSourceHost()); if (hostResource == null && ! multitenant) - throw new IllegalArgumentException("Could not find " + host + " in the application's " + hostSystem()); + throw new IllegalArgumentException("Could not find " + fileDistributor.fileSourceHost() + + " in the application's " + hostSystem()); FileDistributionConfigProvider configProvider = new FileDistributionConfigProvider(fileDistribution, diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java index 685856d5cf8..11cec9efd95 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationPackage.java @@ -93,8 +93,7 @@ public class ZKApplicationPackage implements ApplicationPackage { try { return PreGeneratedFileRegistry.importRegistry(zkApplication.getDataReader(fileRegistryNode)); } catch (Exception e) { - throw new RuntimeException("Could not determine which files to distribute. " + - "Please try redeploying the application", e); + throw new RuntimeException("Could not determine which files to distribute", e); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java index f03550c0a80..68dd5396cf1 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java @@ -51,7 +51,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final TenantListener tenantListener; private final PermanentApplicationPackage permanentApplicationPackage; private final HostRegistries hostRegistries; - private final FileDistributionFactory fileDistributionProvider; + private final FileDistributionFactory fileDistributionFactory; private final ModelFactoryRegistry modelFactoryRegistry; private final Optional<Provisioner> hostProvisioner; private final Zone zone; @@ -65,7 +65,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private TestComponentRegistry(Curator curator, ConfigCurator configCurator, Metrics metrics, ModelFactoryRegistry modelFactoryRegistry, PermanentApplicationPackage permanentApplicationPackage, - FileDistributionFactory fileDistributionProvider, + FileDistributionFactory fileDistributionFactory, HostRegistries hostRegistries, ConfigserverConfig configserverConfig, SessionPreparer sessionPreparer, @@ -86,7 +86,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { this.defRepo = defRepo; this.permanentApplicationPackage = permanentApplicationPackage; this.hostRegistries = hostRegistries; - this.fileDistributionProvider = fileDistributionProvider; + this.fileDistributionFactory = fileDistributionFactory; this.modelFactoryRegistry = modelFactoryRegistry; this.hostProvisioner = hostProvisioner; this.sessionPreparer = sessionPreparer; @@ -247,6 +247,6 @@ public class TestComponentRegistry implements GlobalComponentRegistry { return secretStore; } - public FileDistributionFactory getFileDistributionProvider() { return fileDistributionProvider; } + public FileDistributionFactory getFileDistributionFactory() { return fileDistributionFactory; } } |