ctubbsii commented on a change in pull request #1551: Use sets instead of
arrays for volumes
URL: https://github.com/apache/accumulo/pull/1551#discussion_r389026181
##########
File path:
core/src/main/java/org/apache/accumulo/core/volume/VolumeConfiguration.java
##########
@@ -107,29 +110,31 @@ public static String
getConfiguredBaseDir(AccumuloConfiguration conf,
try {
// pass through URI to unescape hex encoded chars (e.g. convert %2C
to "," char)
- configuredBaseDirs[i++] = new Path(new URI(namespace)).toString();
+ configuredBaseDirs.add(new Path(new URI(namespace)).toString());
} catch (URISyntaxException e) {
throw new
IllegalArgumentException(Property.INSTANCE_VOLUMES.getKey() + " contains "
+ namespace + " which has a syntax error", e);
}
}
}
- return configuredBaseDirs;
+ LinkedHashSet<String> deduplicated = new LinkedHashSet<>();
+ deduplicated.addAll(configuredBaseDirs);
+ if (deduplicated.isEmpty()) {
+ throw new IllegalArgumentException(
+ Property.INSTANCE_VOLUMES.getKey() + " contains no volumes (" + ns +
")");
+ }
+ if (deduplicated.size() < configuredBaseDirs.size()) {
+ throw new IllegalArgumentException(
+ Property.INSTANCE_VOLUMES.getKey() + " contains duplicate volumes ("
+ ns + ")");
Review comment:
This code is likely to change with #1397, so I didn't want to spend too much
time adding more stuff like that just yet, but can do so with #1397.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services