You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2019/09/17 12:04:17 UTC
[hbase] branch branch-1 updated: HBASE-23024 Replace initcause with
Constructor arg (#627)
This is an automated email from the ASF dual-hosted git repository.
psomogyi pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-1 by this push:
new 5c4d8e0 HBASE-23024 Replace initcause with Constructor arg (#627)
5c4d8e0 is described below
commit 5c4d8e036fd16774d75af9f5821f9249870ff22b
Author: Viraj Jasani <vi...@gmail.com>
AuthorDate: Tue Sep 17 17:09:26 2019 +0530
HBASE-23024 Replace initcause with Constructor arg (#627)
Signed-off-by: Peter Somogyi <ps...@apache.org>
---
.../hadoop/hbase/DroppedSnapshotException.java | 10 +++++++++
.../exceptions/ConnectionClosingException.java | 10 +++++++++
.../hadoop/hbase/ipc/BlockingRpcConnection.java | 2 +-
.../hadoop/hbase/ipc/CallTimeoutException.java | 10 +++++++++
.../java/org/apache/hadoop/hbase/ipc/IPCUtil.java | 12 +++++------
.../apache/hadoop/hbase/util/CommonFSUtils.java | 6 ++----
.../hadoop/hbase/master/MasterFileSystem.java | 4 +---
.../apache/hadoop/hbase/regionserver/HRegion.java | 6 ++----
.../hadoop/hbase/snapshot/SnapshotManifestV1.java | 4 +---
.../hadoop/hbase/snapshot/SnapshotManifestV2.java | 4 +---
.../hbase/snapshot/SnapshotReferenceUtil.java | 4 +---
.../java/org/apache/hadoop/hbase/util/FSUtils.java | 4 +---
.../apache/hadoop/hbase/util/JVMClusterUtil.java | 8 ++------
.../hadoop/hbase/util/ModifyRegionUtils.java | 4 +---
.../org/apache/hadoop/hbase/wal/WALSplitter.java | 24 +++++++++++++---------
15 files changed, 63 insertions(+), 49 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/DroppedSnapshotException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/DroppedSnapshotException.java
index c64bfd3..0511566 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/DroppedSnapshotException.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/DroppedSnapshotException.java
@@ -42,4 +42,14 @@ public class DroppedSnapshotException extends IOException {
public DroppedSnapshotException(String message) {
super(message);
}
+
+ /**
+ * DroppedSnapshotException with cause
+ *
+ * @param message the message for this exception
+ * @param cause the cause for this exception
+ */
+ public DroppedSnapshotException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosingException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosingException.java
index 49134f1..56aeff2 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosingException.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosingException.java
@@ -55,5 +55,15 @@ public class ConnectionClosingException extends IOException {
super(string);
}
+ /**
+ * ConnectionClosingException with cause
+ *
+ * @param message the message for this exception
+ * @param cause the cause for this exception
+ */
+ public ConnectionClosingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
private static final long serialVersionUID = -8980028569652624236L;
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java
index d5cf6a2..faf42e0 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java
@@ -392,7 +392,7 @@ class BlockingRpcConnection extends RpcConnection implements Runnable {
String msg = "Couldn't setup connection for " +
UserGroupInformation.getLoginUser().getUserName() + " to " + serverPrincipal;
LOG.warn(msg, ex);
- throw (IOException) new IOException(msg).initCause(ex);
+ throw new IOException(msg, ex);
}
} else {
LOG.warn("Exception encountered while connecting to " + "the server : " + ex);
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CallTimeoutException.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CallTimeoutException.java
index a81e5d1..f5e6074 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CallTimeoutException.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CallTimeoutException.java
@@ -32,4 +32,14 @@ public class CallTimeoutException extends IOException {
public CallTimeoutException(final String msg) {
super(msg);
}
+
+ /**
+ * CallTimeoutException with cause
+ *
+ * @param message the message for this exception
+ * @param cause the cause for this exception
+ */
+ public CallTimeoutException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
index 9a4a5c6..b5cb76d 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java
@@ -168,17 +168,17 @@ class IPCUtil {
return (SocketTimeoutException) new SocketTimeoutException(
"Call to " + addr + " failed because " + exception).initCause(exception);
} else if (exception instanceof ConnectionClosingException) {
- return (ConnectionClosingException) new ConnectionClosingException(
- "Call to " + addr + " failed on local exception: " + exception).initCause(exception);
+ return new ConnectionClosingException("Call to " + addr + " failed on local exception: "
+ + exception, exception);
} else if (exception instanceof ServerTooBusyException) {
// we already have address in the exception message
return (IOException) exception;
} else if (exception instanceof DoNotRetryIOException) {
- return (IOException) new DoNotRetryIOException(
- "Call to " + addr + " failed on local exception: " + exception).initCause(exception);
+ return new DoNotRetryIOException(
+ "Call to " + addr + " failed on local exception: " + exception, exception);
} else {
- return (IOException) new IOException(
- "Call to " + addr + " failed on local exception: " + exception).initCause(exception);
+ return new IOException(
+ "Call to " + addr + " failed on local exception: " + exception, exception);
}
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
index 02f516f..b52d3dc 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java
@@ -307,10 +307,8 @@ public abstract class CommonFSUtils {
}
return root;
} catch (URISyntaxException e) {
- IOException io = new IOException("Root directory path is not a valid " +
- "URI -- check your " + HConstants.HBASE_DIR + " configuration");
- io.initCause(e);
- throw io;
+ throw new IOException("Root directory path is not a valid " +
+ "URI -- check your " + HConstants.HBASE_DIR + " configuration", e);
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
index 29aa708..6ca0ad5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
@@ -515,9 +515,7 @@ public class MasterFileSystem {
}
} catch (DeserializationException de) {
LOG.fatal("Please fix invalid configuration for " + dirConfKey, de);
- IOException ioe = new IOException();
- ioe.initCause(de);
- throw ioe;
+ throw new IOException(de);
} catch (IllegalArgumentException iae) {
LOG.fatal("Please fix invalid configuration for "
+ dirConfKey + " " + rd.toString(), iae);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 1157eba..14f41b6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -2692,8 +2692,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
wal.abortCacheFlush(this.getRegionInfo().getEncodedNameAsBytes());
}
DroppedSnapshotException dse = new DroppedSnapshotException("region: " +
- Bytes.toStringBinary(getRegionInfo().getRegionName()));
- dse.initCause(t);
+ Bytes.toStringBinary(getRegionInfo().getRegionName()), t);
status.abort("Flush failed: " + StringUtils.stringifyException(t));
// Callers for flushcache() should catch DroppedSnapshotException and abort the region server.
@@ -5690,8 +5689,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// is reached, it will throw out an Error. This Error needs to be caught so it can
// go ahead to process the minibatch with lock acquired.
LOG.warn("Error to get row lock for " + Bytes.toStringBinary(row) + ", cause: " + error);
- IOException ioe = new IOException();
- ioe.initCause(error);
+ IOException ioe = new IOException(error);
if (traceScope != null) {
traceScope.getSpan().addTimelineAnnotation("Error getting row lock");
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV1.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV1.java
index 74aaa4c..e9ba07c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV1.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV1.java
@@ -144,9 +144,7 @@ public final class SnapshotManifestV1 {
} catch (InterruptedException e) {
throw new InterruptedIOException(e.getMessage());
} catch (ExecutionException e) {
- IOException ex = new IOException();
- ex.initCause(e.getCause());
- throw ex;
+ throw new IOException(e.getCause());
}
return regionsManifest;
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV2.java
index 433c003..a29b6a4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV2.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV2.java
@@ -173,9 +173,7 @@ public final class SnapshotManifestV2 {
if(t instanceof InvalidProtocolBufferException) {
throw (InvalidProtocolBufferException)t;
} else {
- IOException ex = new IOException("ExecutionException");
- ex.initCause(e.getCause());
- throw ex;
+ throw new IOException("ExecutionException", e.getCause());
}
}
return regionsManifest;
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotReferenceUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotReferenceUtil.java
index 56699d6..22cef7e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotReferenceUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotReferenceUtil.java
@@ -228,9 +228,7 @@ public final class SnapshotReferenceUtil {
if (e.getCause() instanceof CorruptedSnapshotException) {
throw new CorruptedSnapshotException(e.getCause().getMessage(), snapshotDesc);
} else {
- IOException ex = new IOException();
- ex.initCause(e.getCause());
- throw ex;
+ throw new IOException(e.getCause());
}
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index da672c4..3a04b4c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -260,9 +260,7 @@ public abstract class FSUtils extends CommonFSUtils {
} catch (Exception e) {
LOG.error("file system close failed: ", e);
}
- IOException io = new IOException("File system is not available");
- io.initCause(exception);
- throw io;
+ throw new IOException("File system is not available", exception);
}
/**
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
index 79865bb..23c4f3c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
@@ -95,9 +95,7 @@ public class JVMClusterUtil {
hrsc.toString() + ((target.getCause() != null)?
target.getCause().getMessage(): ""), target);
} catch (Exception e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
+ throw new IOException(e);
}
return new JVMClusterUtil.RegionServerThread(server, index);
}
@@ -144,9 +142,7 @@ public class JVMClusterUtil {
hmc.toString() + ((target.getCause() != null)?
target.getCause().getMessage(): ""), target);
} catch (Exception e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
+ throw new IOException(e);
}
return new JVMClusterUtil.MasterThread(server, index);
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
index 474e698..a8cc87b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/ModifyRegionUtils.java
@@ -246,9 +246,7 @@ public abstract class ModifyRegionUtils {
} catch (InterruptedException e) {
throw new InterruptedIOException(e.getMessage());
} catch (ExecutionException e) {
- IOException ex = new IOException();
- ex.initCause(e.getCause());
- throw ex;
+ throw new IOException(e.getCause());
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
index 471c5f6..7d9314b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
@@ -814,11 +814,8 @@ public class WALSplitter {
if (!skipErrors || e instanceof InterruptedIOException) {
throw e; // Don't mark the file corrupted if interrupted, or not skipErrors
}
- CorruptedLogFileException t =
- new CorruptedLogFileException("skipErrors=true Could not open wal " +
- path + " ignoring");
- t.initCause(e);
- throw t;
+ throw new CorruptedLogFileException("skipErrors=true Could not open wal "
+ + path + " ignoring", e);
}
return in;
}
@@ -844,11 +841,8 @@ public class WALSplitter {
if (!skipErrors) {
throw e;
}
- CorruptedLogFileException t =
- new CorruptedLogFileException("skipErrors=true Ignoring exception" +
- " while parsing wal " + path + ". Marking as corrupted");
- t.initCause(e);
- throw t;
+ throw new CorruptedLogFileException("skipErrors=true Ignoring exception"
+ + " while parsing wal " + path + ". Marking as corrupted", e);
}
}
@@ -2416,6 +2410,16 @@ public class WALSplitter {
CorruptedLogFileException(String s) {
super(s);
}
+
+ /**
+ * CorruptedLogFileException with cause
+ *
+ * @param message the message for this exception
+ * @param cause the cause for this exception
+ */
+ CorruptedLogFileException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
/** A struct used by getMutationsFromWALEntry */