milleruntime commented on a change in pull request #1551: Use sets instead of
arrays for volumes
URL: https://github.com/apache/accumulo/pull/1551#discussion_r388969624
##########
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:
Can never have enough sanity checks! Could create unit tests for these
checks, one where two configured Volumes get normalized to the same Path.
----------------------------------------------------------------
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