You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2019/03/13 21:59:38 UTC
[accumulo] branch master updated: Use UncheckedIOException when
catching IOException (#1030)
This is an automated email from the ASF dual-hosted git repository.
mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 77eacde Use UncheckedIOException when catching IOException (#1030)
77eacde is described below
commit 77eacde342979d2b005d57f277894532a48af26b
Author: Mike Miller <mm...@apache.org>
AuthorDate: Wed Mar 13 17:59:33 2019 -0400
Use UncheckedIOException when catching IOException (#1030)
* Use UncheckedIOException instead of RuntimeException where appropriate
* Use AssertionError instead of RuntimeException one place in Master
---
.../main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java | 3 ++-
server/master/src/main/java/org/apache/accumulo/master/Master.java | 2 +-
.../java/org/apache/accumulo/tserver/log/RecoveryLogReader.java | 3 ++-
.../java/org/apache/accumulo/shell/commands/ClasspathCommand.java | 3 ++-
.../main/java/org/apache/accumulo/shell/commands/MergeCommand.java | 3 ++-
test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java | 3 ++-
.../java/org/apache/accumulo/test/performance/ContinuousOpts.java | 3 ++-
.../main/java/org/apache/accumulo/test/util/SerializationUtil.java | 7 ++++---
8 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
index 339f924..1085846 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.server.fs;
import static java.util.Objects.requireNonNull;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
@@ -278,7 +279,7 @@ public class VolumeManagerImpl implements VolumeManager {
return new NonConfiguredVolume(desiredFs);
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
}
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index 5d7fc6d..a22471e 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -768,7 +768,7 @@ public class Master
try {
info.write(out);
} catch (IOException ex) {
- throw new RuntimeException("Unlikely", ex);
+ throw new AssertionError("Unlikely", ex);
}
context.getZooReaderWriter().putPersistentData(path, out.getData(),
state.equals(MergeState.STARTED) ? ZooUtil.NodeExistsPolicy.FAIL
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/RecoveryLogReader.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/RecoveryLogReader.java
index fb8e0d8..c283895 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/RecoveryLogReader.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/RecoveryLogReader.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.tserver.log;
import java.io.EOFException;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.AbstractMap;
import java.util.Iterator;
import java.util.Map.Entry;
@@ -105,7 +106,7 @@ public class RecoveryLogReader implements CloseableIterator<Entry<LogFileKey,Log
int result = ((WritableComparable) key).compareTo(o.key);
return result;
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
}
}
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ClasspathCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ClasspathCommand.java
index e4bf9b6..9376024 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ClasspathCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ClasspathCommand.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.shell.commands;
import java.io.IOException;
+import java.io.UncheckedIOException;
import org.apache.accumulo.shell.Shell;
import org.apache.accumulo.shell.Shell.Command;
@@ -33,7 +34,7 @@ public class ClasspathCommand extends Command {
try {
reader.print(s);
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
}, true);
return 0;
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
index a51dbf9..e1a91a0 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.shell.commands;
import java.io.IOException;
+import java.io.UncheckedIOException;
import org.apache.accumulo.core.conf.ConfigurationTypeHelper;
import org.apache.accumulo.core.util.Merge;
@@ -72,7 +73,7 @@ public class MergeCommand extends Command {
try {
shellState.getReader().println(String.format(fmt, args));
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
index e9246f8..ff0dcb1 100644
--- a/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/InMemoryMapIT.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -341,7 +342,7 @@ public class InMemoryMapIT {
}
} catch (IOException ex) {
log.error("Error getting memkeys", ex);
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
return memKeys;
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/ContinuousOpts.java b/test/src/main/java/org/apache/accumulo/test/performance/ContinuousOpts.java
index 827c6ca..366335b 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/ContinuousOpts.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/ContinuousOpts.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.test.performance;
import java.io.IOException;
+import java.io.UncheckedIOException;
import org.apache.accumulo.core.Constants;
import org.apache.log4j.FileAppender;
@@ -42,7 +43,7 @@ public class ContinuousOpts {
logger.addAppender(new FileAppender(
new PatternLayout("%d{dd HH:mm:ss,SSS} [%-8c{2}] %-5p: %m%n"), debugLog, true));
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
}
return debugLog;
}
diff --git a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
index a3472ab..d68ad47 100644
--- a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
+++ b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java
@@ -26,6 +26,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Serializable;
+import java.io.UncheckedIOException;
import java.util.Base64;
import java.util.Objects;
@@ -107,7 +108,7 @@ public class SerializationUtil {
out = new DataOutputStream(outputStream);
obj.write(out);
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
} finally {
if (out != null)
try {
@@ -126,7 +127,7 @@ public class SerializationUtil {
in = new DataInputStream(inputStream);
writable.readFields(in);
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
} finally {
if (in != null)
try {
@@ -168,7 +169,7 @@ public class SerializationUtil {
out = new ObjectOutputStream(outputStream);
out.writeObject(obj);
} catch (IOException ex) {
- throw new RuntimeException(ex);
+ throw new UncheckedIOException(ex);
} finally {
if (out != null)
try {