jmark99 commented on a change in pull request #2558:
URL: https://github.com/apache/accumulo/pull/2558#discussion_r837863217
##########
File path:
test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
##########
@@ -63,69 +65,50 @@ public void run() throws Exception {
bw.addMutation(m);
}
- boolean caught = false;
// try to scan table
try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY))
{
-
- try {
+ assertThrows(Exception.class, () -> {
for (Entry<Key,Value> entry : scanner) {
entry.getKey();
}
- } catch (Exception e) {
- caught = true;
- }
-
- if (!caught)
- throw new Exception("Scan did not fail");
-
- // try to batch scan the table
- try (BatchScanner bs = c.createBatchScanner(tableName,
Authorizations.EMPTY, 2)) {
- bs.setRanges(Collections.singleton(new Range()));
+ });
Review comment:
Re-worked to separate the iterator() call from the next() call.
##########
File path:
test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
##########
@@ -63,69 +65,50 @@ public void run() throws Exception {
bw.addMutation(m);
}
- boolean caught = false;
// try to scan table
try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY))
{
-
- try {
+ assertThrows(Exception.class, () -> {
for (Entry<Key,Value> entry : scanner) {
entry.getKey();
}
- } catch (Exception e) {
- caught = true;
- }
-
- if (!caught)
- throw new Exception("Scan did not fail");
-
- // try to batch scan the table
- try (BatchScanner bs = c.createBatchScanner(tableName,
Authorizations.EMPTY, 2)) {
- bs.setRanges(Collections.singleton(new Range()));
+ });
+ }
- caught = false;
- try {
- for (Entry<Key,Value> entry : bs) {
- entry.getKey();
- }
- } catch (Exception e) {
- caught = true;
+ // try to batch scan the table
+ try (BatchScanner bs = c.createBatchScanner(tableName,
Authorizations.EMPTY, 2)) {
+ bs.setRanges(Collections.singleton(new Range()));
+ assertThrows(Exception.class, () -> {
+ for (Entry<Key,Value> entry : bs) {
+ entry.getKey();
}
- }
-
- if (!caught)
- throw new Exception("batch scan did not fail");
-
- // remove the bad agg so accumulo can shutdown
- TableOperations to = c.tableOperations();
- for (Entry<String,String> e : to.getProperties(tableName)) {
- to.removeProperty(tableName, e.getKey());
- }
+ });
+ }
- sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+ // remove the bad agg so accumulo can shutdown
+ TableOperations to = c.tableOperations();
+ for (Entry<String,String> e : to.getProperties(tableName)) {
+ to.removeProperty(tableName, e.getKey());
}
+ sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+
// should be able to scan now
try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY))
{
for (Entry<Key,Value> entry : scanner) {
- entry.getKey();
+ assertNotNull(entry.getKey());
}
// set a nonexistent iterator, should cause scan to fail on server side
scanner.addScanIterator(new IteratorSetting(100, "bogus",
"com.bogus.iterator"));
- caught = false;
- try {
+ assertThrows(Exception.class, () -> {
for (Entry<Key,Value> entry : scanner) {
// should error
entry.getKey();
}
- } catch (Exception e) {
- caught = true;
- }
-
- if (!caught)
- throw new Exception("Scan did not fail");
+ });
Review comment:
Re-worked to separate the iterator() call from the next() call.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]