You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2019/07/25 20:39:47 UTC
[accumulo] branch 2.0 updated: fix #1286 throw exception on empty
bulk import (#1292)
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.0 by this push:
new 3a4a4d6 fix #1286 throw exception on empty bulk import (#1292)
3a4a4d6 is described below
commit 3a4a4d6dbb60803b269139f2f20814c96481187e
Author: Keith Turner <kt...@apache.org>
AuthorDate: Thu Jul 25 16:39:42 2019 -0400
fix #1286 throw exception on empty bulk import (#1292)
---
.../org/apache/accumulo/core/clientImpl/bulk/BulkImport.java | 5 ++++-
.../java/org/apache/accumulo/test/functional/BulkNewIT.java | 10 ++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
index 7635b21..48a7f93 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
@@ -131,6 +131,9 @@ public class BulkImport implements ImportDestinationArguments, ImportMappingOpti
mappings = computeMappingFromPlan(fs, tableId, srcPath);
}
+ if (mappings.isEmpty())
+ throw new IllegalArgumentException("Attempted to import zero files from " + srcPath);
+
BulkSerialize.writeLoadMapping(mappings, srcPath.toString(), fs::create);
List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableId.canonical().getBytes(UTF_8)),
@@ -186,7 +189,7 @@ public class BulkImport implements ImportDestinationArguments, ImportMappingOpti
@Override
public ImportMappingOptions plan(LoadPlan plan) {
- this.plan = plan;
+ this.plan = Objects.requireNonNull(plan);
return this;
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java
index ddcabf9..95e9b2f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BulkNewIT.java
@@ -367,6 +367,16 @@ public class BulkNewIT extends SharedMiniClusterBase {
}
}
+ @Test(expected = IllegalArgumentException.class)
+ public void testEmptyDir() throws Exception {
+ try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
+ String dir = getDir("/testBulkFile-");
+ FileSystem fs = getCluster().getFileSystem();
+ fs.mkdirs(new Path(dir));
+ c.tableOperations().importDirectory(dir).to(tableName).load();
+ }
+ }
+
private void addSplits(AccumuloClient client, String tableName, String splitString)
throws Exception {
SortedSet<Text> splits = new TreeSet<>();