Skip to content

Commit faed3e4

Browse files
virajjasanipetersomogyi
authored andcommitted
HBASE-23024 Replace initcause with Constructor arg (#627)
Signed-off-by: Peter Somogyi <psomogyi@apache.org>
1 parent 4b3c42f commit faed3e4

16 files changed

Lines changed: 79 additions & 55 deletions

File tree

hbase-client/src/main/java/org/apache/hadoop/hbase/DroppedSnapshotException.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,14 @@ public DroppedSnapshotException() {
4040
public DroppedSnapshotException(String message) {
4141
super(message);
4242
}
43+
44+
/**
45+
* DroppedSnapshotException with cause
46+
*
47+
* @param message the message for this exception
48+
* @param cause the cause for this exception
49+
*/
50+
public DroppedSnapshotException(String message, Throwable cause) {
51+
super(message, cause);
52+
}
4353
}

hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosedException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ public ConnectionClosedException(String string) {
3333
super(string);
3434
}
3535

36+
/**
37+
* ConnectionClosedException with cause
38+
*
39+
* @param message the message for this exception
40+
* @param cause the cause for this exception
41+
*/
42+
public ConnectionClosedException(String message, Throwable cause) {
43+
super(message, cause);
44+
}
3645
}

hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ConnectionClosingException.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,15 @@ public ConnectionClosingException(String string) {
5353
super(string);
5454
}
5555

56+
/**
57+
* ConnectionClosingException with cause
58+
*
59+
* @param message the message for this exception
60+
* @param cause the cause for this exception
61+
*/
62+
public ConnectionClosingException(String message, Throwable cause) {
63+
super(message, cause);
64+
}
65+
5666
private static final long serialVersionUID = -8980028569652624236L;
5767
}

hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/BlockingRpcConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public Object run() throws IOException, InterruptedException {
410410
String msg = "Couldn't setup connection for "
411411
+ UserGroupInformation.getLoginUser().getUserName() + " to " + serverPrincipal;
412412
LOG.warn(msg, ex);
413-
throw (IOException) new IOException(msg).initCause(ex);
413+
throw new IOException(msg, ex);
414414
}
415415
} else {
416416
LOG.warn("Exception encountered while connecting to " + "the server : " + ex);

hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CallTimeoutException.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ public class CallTimeoutException extends HBaseIOException {
3030
public CallTimeoutException(final String msg) {
3131
super(msg);
3232
}
33+
34+
/**
35+
* CallTimeoutException with cause
36+
*
37+
* @param message the message for this exception
38+
* @param cause the cause for this exception
39+
*/
40+
public CallTimeoutException(final String message, final Throwable cause) {
41+
super(message, cause);
42+
}
3343
}

hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/IPCUtil.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ static IOException wrapException(InetSocketAddress addr, Throwable error) {
180180
return (IOException) new SocketTimeoutException(
181181
"Call to " + addr + " failed because " + error).initCause(error);
182182
} else if (error instanceof ConnectionClosingException) {
183-
return (IOException) new ConnectionClosingException(
184-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
183+
return new ConnectionClosingException("Call to " + addr + " failed on local exception: "
184+
+ error, error);
185185
} else if (error instanceof ServerTooBusyException) {
186186
// we already have address in the exception message
187187
return (IOException) error;
@@ -195,22 +195,22 @@ static IOException wrapException(InetSocketAddress addr, Throwable error) {
195195
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
196196
// just ignore, will just new a DoNotRetryIOException instead below
197197
}
198-
return (IOException) new DoNotRetryIOException(
199-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
198+
return new DoNotRetryIOException("Call to " + addr + " failed on local exception: "
199+
+ error, error);
200200
} else if (error instanceof ConnectionClosedException) {
201-
return (IOException) new ConnectionClosedException(
202-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
201+
return new ConnectionClosedException("Call to " + addr + " failed on local exception: "
202+
+ error, error);
203203
} else if (error instanceof CallTimeoutException) {
204-
return (IOException) new CallTimeoutException(
205-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
204+
return new CallTimeoutException("Call to " + addr + " failed on local exception: "
205+
+ error, error);
206206
} else if (error instanceof ClosedChannelException) {
207207
// ClosedChannelException does not have a constructor which takes a String but it is a
208208
// connection exception so we keep its original type
209209
return (IOException) error;
210210
} else if (error instanceof TimeoutException) {
211211
// TimeoutException is not an IOException, let's convert it to TimeoutIOException.
212-
return (IOException) new TimeoutIOException(
213-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
212+
return new TimeoutIOException("Call to " + addr + " failed on local exception: "
213+
+ error, error);
214214
} else {
215215
// try our best to keep the original exception type
216216
if (error instanceof IOException) {
@@ -224,8 +224,8 @@ static IOException wrapException(InetSocketAddress addr, Throwable error) {
224224
// just ignore, will just new an IOException instead below
225225
}
226226
}
227-
return (IOException) new HBaseIOException(
228-
"Call to " + addr + " failed on local exception: " + error).initCause(error);
227+
return new HBaseIOException("Call to " + addr + " failed on local exception: "
228+
+ error, error);
229229
}
230230
}
231231

hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,8 @@ public static Path validateRootPath(Path root) throws IOException {
309309
}
310310
return root;
311311
} catch (URISyntaxException e) {
312-
IOException io = new IOException("Root directory path is not a valid " +
313-
"URI -- check your " + HConstants.HBASE_DIR + " configuration");
314-
io.initCause(e);
315-
throw io;
312+
throw new IOException("Root directory path is not a valid " +
313+
"URI -- check your " + HConstants.HBASE_DIR + " configuration", e);
316314
}
317315
}
318316

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ private Path checkRootDir(final Path rd, final Configuration c, final FileSystem
278278
} catch (DeserializationException de) {
279279
LOG.error(HBaseMarkers.FATAL, "Please fix invalid configuration for "
280280
+ HConstants.HBASE_DIR, de);
281-
IOException ioe = new IOException();
282-
ioe.initCause(de);
283-
throw ioe;
281+
throw new IOException(de);
284282
} catch (IllegalArgumentException iae) {
285283
LOG.error(HBaseMarkers.FATAL, "Please fix invalid configuration for "
286284
+ HConstants.HBASE_DIR + " " + rd.toString(), iae);

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,8 +2838,7 @@ protected FlushResultImpl internalFlushCacheAndCommit(WAL wal, MonitoredTask sta
28382838
wal.abortCacheFlush(this.getRegionInfo().getEncodedNameAsBytes());
28392839
}
28402840
DroppedSnapshotException dse = new DroppedSnapshotException("region: " +
2841-
Bytes.toStringBinary(getRegionInfo().getRegionName()));
2842-
dse.initCause(t);
2841+
Bytes.toStringBinary(getRegionInfo().getRegionName()), t);
28432842
status.abort("Flush failed: " + StringUtils.stringifyException(t));
28442843

28452844
// Callers for flushcache() should catch DroppedSnapshotException and abort the region server.
@@ -5931,8 +5930,7 @@ protected RowLock getRowLockInternal(byte[] row, boolean readLock, final RowLock
59315930
// is reached, it will throw out an Error. This Error needs to be caught so it can
59325931
// go ahead to process the minibatch with lock acquired.
59335932
LOG.warn("Error to get row lock for " + Bytes.toStringBinary(row) + ", cause: " + error);
5934-
IOException ioe = new IOException();
5935-
ioe.initCause(error);
5933+
IOException ioe = new IOException(error);
59365934
TraceUtil.addTimelineAnnotation("Error getting row lock");
59375935
throw ioe;
59385936
} finally {

hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/SnapshotManifestV1.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ public SnapshotRegionManifest call() throws IOException {
149149
} catch (InterruptedException e) {
150150
throw new InterruptedIOException(e.getMessage());
151151
} catch (ExecutionException e) {
152-
IOException ex = new IOException();
153-
ex.initCause(e.getCause());
154-
throw ex;
152+
throw new IOException(e.getCause());
155153
}
156154
return regionsManifest;
157155
}

0 commit comments

Comments
 (0)