Skip to content

Commit

Permalink
IGNITE-14823 Exception abbrevation (#11113)
Browse files Browse the repository at this point in the history
  • Loading branch information
nizhikov authored Dec 20, 2023
1 parent a0b9af0 commit fe11df1
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1367,8 +1367,8 @@ Expression handleMethodCheckedExceptions(Expression callExpr) {
Statement st = Expressions.statement(Expressions.assign(methodCall, callExpr));
// Catch Block, wrap checked exception in unchecked exception
ParameterExpression e = Expressions.parameter(0, Exception.class, "e");
Expression uncheckedException = Expressions.new_(RuntimeException.class, e);
CatchBlock cb = Expressions.catch_(e, Expressions.throw_(uncheckedException));
Expression uncheckedEx = Expressions.new_(RuntimeException.class, e);
CatchBlock cb = Expressions.catch_(e, Expressions.throw_(uncheckedEx));
list.add(Expressions.tryCatch(st, cb));
return methodCall;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/checkstyle/src/main/resources/abbrevations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ destination,dest
directory,dir
event,evt
events,evts
#exception,e,e2,ex
exception,e,e2,ex
#execute,exec
#frequency,freq
#future,fut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2221,14 +2221,14 @@ public void testMultithreadingException() throws Exception {

f.get();

boolean exceptionFound = false;
boolean exFound = false;

for (SQLException e : exs) {
if (e != null && e.getMessage().contains("Concurrent access to JDBC connection is not allowed"))
exceptionFound = true;
exFound = true;
}

assertTrue("Concurrent access to JDBC connection is not allowed", exceptionFound);
assertTrue("Concurrent access to JDBC connection is not allowed", exFound);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,14 +694,14 @@ else if (log.isDebugEnabled())
}

if (!clsRequestExceptions.isEmpty()) {
IgniteException exception = clsRequestExceptions.remove(0);
IgniteException ex = clsRequestExceptions.remove(0);

for (Exception e : clsRequestExceptions)
exception.addSuppressed(e);
ex.addSuppressed(e);

LT.warn(log, exception.getMessage(), exception);
LT.warn(log, ex.getMessage(), ex);

throw exception;
throw ex;
}
else {
ClassNotFoundException cnfe = new P2PClassNotFoundException("Failed to peer load class [" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2875,14 +2875,14 @@ public synchronized void submit(GridFutureAdapter notificationFut, Runnable cmd)
body0();
}
catch (Throwable t) {
boolean isInterruptedException = X.hasCause(t, InterruptedException.class)
boolean isInterruptedEx = X.hasCause(t, InterruptedException.class)
|| X.hasCause(t, IgniteInterruptedException.class)
|| X.hasCause(t, IgniteInterruptedCheckedException.class);

if (!isInterruptedException)
if (!isInterruptedEx)
U.error(log, "Exception in discovery notifier worker thread.", t);

if (!isInterruptedException || !isCancelled.get()) {
if (!isInterruptedEx || !isCancelled.get()) {
FailureType type = t instanceof OutOfMemoryError ? CRITICAL_ERROR : SYSTEM_WORKER_TERMINATION;

ctx.failure().process(new FailureContext(type, t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2838,7 +2838,7 @@ private void afterRowFound(@Nullable CacheDataRow row, KeyCacheObject key) throw

/** {@inheritDoc} */
@Override public void destroy() throws IgniteCheckedException {
AtomicReference<IgniteCheckedException> exception = new AtomicReference<>();
AtomicReference<IgniteCheckedException> exRef = new AtomicReference<>();

dataTree.destroy(row -> {
try {
Expand All @@ -2847,17 +2847,17 @@ private void afterRowFound(@Nullable CacheDataRow row, KeyCacheObject key) throw
catch (IgniteCheckedException e) {
U.error(log, "Failed to remove row [link=" + row.link() + "]");

IgniteCheckedException ex = exception.get();
IgniteCheckedException ex = exRef.get();

if (ex == null)
exception.set(e);
exRef.set(e);
else
ex.addSuppressed(e);
}
}, false);

if (exception.get() != null)
throw new IgniteCheckedException("Failed to destroy store", exception.get());
if (exRef.get() != null)
throw new IgniteCheckedException("Failed to destroy store", exRef.get());
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2051,9 +2051,9 @@ private RuntimeException cacheException(Exception e) {
GridFutureAdapter<Void> restartFut = this.restartFut.get();

if (X.hasCause(e, IgniteCacheRestartingException.class)) {
IgniteCacheRestartingException restartingException = X.cause(e, IgniteCacheRestartingException.class);
IgniteCacheRestartingException restartingEx = X.cause(e, IgniteCacheRestartingException.class);

if (restartingException.restartFuture() == null) {
if (restartingEx.restartFuture() == null) {
if (restartFut == null)
restartFut = suspend();

Expand All @@ -2062,7 +2062,7 @@ private RuntimeException cacheException(Exception e) {
throw new IgniteCacheRestartingException(new IgniteFutureImpl<>(restartFut, exec()), cacheName);
}
else
throw restartingException;
throw restartingEx;
}

if (restartFut != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2970,11 +2970,11 @@ private void processMergedMessage(final ClusterNode node, final GridDhtPartition
* @param msg Single message received from the client which didn't find original ExchangeFuture.
*/
public void forceClientReconnect(ClusterNode node, GridDhtPartitionsSingleMessage msg) {
Exception reconnectException = new IgniteNeedReconnectException(node, null);
Exception reconnectEx = new IgniteNeedReconnectException(node, null);

exchangeGlobalExceptions.put(node.id(), reconnectException);
exchangeGlobalExceptions.put(node.id(), reconnectEx);

onDone(null, reconnectException);
onDone(null, reconnectEx);

GridDhtPartitionsFullMessage fullMsg = createPartitionsMessage(true, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1288,15 +1288,15 @@ private IgniteFuture<Void> loadCacheAsync0(BinaryRawReaderEx reader, boolean loc
if (e.getCause() instanceof EntryProcessorException)
return (Exception)e.getCause();

TransactionDeadlockException deadlockException = X.cause(e, TransactionDeadlockException.class);
TransactionDeadlockException deadlockEx = X.cause(e, TransactionDeadlockException.class);

if (deadlockException != null)
return deadlockException;
if (deadlockEx != null)
return deadlockEx;

TransactionTimeoutException timeoutException = X.cause(e, TransactionTimeoutException.class);
TransactionTimeoutException timeoutEx = X.cause(e, TransactionTimeoutException.class);

if (timeoutException != null)
return timeoutException;
if (timeoutEx != null)
return timeoutEx;

return super.convertException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,9 @@ public static Object readInvocationResult(PlatformContext ctx, BinaryRawReaderEx
return deserialize ? reader.readObject() : reader.readObjectDetached();
else {
// 3. Read whether exception is in form of object or string.
boolean hasException = reader.readBoolean();
boolean hasEx = reader.readBoolean();

if (hasException) {
if (hasEx) {
// 4. Full exception.
Object nativeErr = reader.readObjectDetached();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public static boolean isClientNodeTopologyException(Throwable t, ClusterNode nod
* was made while only inverse connections are allowed.
*/
public static boolean isAttemptToEstablishDirectConnectionWhenOnlyInverseIsAllowed(Throwable t) {
IgniteSpiException igniteSpiException = X.cause(t, IgniteSpiException.class);
IgniteSpiException igniteSpiEx = X.cause(t, IgniteSpiException.class);

return igniteSpiException != null && igniteSpiException.getMessage() != null
&& igniteSpiException.getMessage().contains(
return igniteSpiEx != null && igniteSpiEx.getMessage() != null
&& igniteSpiEx.getMessage().contains(
"because it is started in 'forceClientToServerConnections' mode; inverse connection will be requested");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void test() throws Exception {

final AtomicInteger cntFails = new AtomicInteger();

final AtomicInteger exceptionFails = new AtomicInteger();
final AtomicInteger exFails = new AtomicInteger();

final String cacheName = "TEST_CACHE";

Expand All @@ -69,7 +69,7 @@ public void test() throws Exception {
stopLatch.countDown();
}
catch (Exception e) {
exceptionFails.incrementAndGet();
exFails.incrementAndGet();
}
}
});
Expand All @@ -87,7 +87,7 @@ public void test() throws Exception {
stopLatch.countDown();
}
catch (Exception e) {
exceptionFails.incrementAndGet();
exFails.incrementAndGet();
}
}
});
Expand All @@ -103,7 +103,7 @@ public void test() throws Exception {

stopLatch.await();

if (cntFails.get() != 0 || exceptionFails.get() != 0)
fail("Cache return null in " + cntFails.get() + " of 3 cases. Total exception: " + exceptionFails.get());
if (cntFails.get() != 0 || exFails.get() != 0)
fail("Cache return null in " + cntFails.get() + " of 3 cases. Total exception: " + exFails.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ public void testReentrantLockFailsWhenServersLeft(final boolean fair) throws Exc
// Signal the server to go down.
ignite.semaphore("sync", 0, true, true).release();

boolean isExceptionThrown = false;
boolean isExThrown = false;

try {
// Wait for the server to go down.
Expand All @@ -780,10 +780,10 @@ public void testReentrantLockFailsWhenServersLeft(final boolean fair) throws Exc
fail("Interrupted exception not expected here.");
}
catch (IgniteException ignored) {
isExceptionThrown = true;
isExThrown = true;
}
finally {
assertTrue(isExceptionThrown);
assertTrue(isExThrown);

assertFalse(l.isHeldByCurrentThread());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ private void testLockInterruptiblyMultinode(final boolean fair) throws Exception

final AtomicBoolean done = new AtomicBoolean(false);

final AtomicBoolean exceptionThrown = new AtomicBoolean(false);
final AtomicBoolean exThrown = new AtomicBoolean(false);

final IgniteCountDownLatch latch = ignite.countDownLatch("latch", threadCnt, false, true);

Expand All @@ -946,7 +946,7 @@ private void testLockInterruptiblyMultinode(final boolean fair) throws Exception
l.lockInterruptibly();
}
catch (IgniteInterruptedException ignored) {
exceptionThrown.set(true);
exThrown.set(true);
}
finally {
done.set(true);
Expand Down Expand Up @@ -980,7 +980,7 @@ private void testLockInterruptiblyMultinode(final boolean fair) throws Exception
throw new RuntimeException(e);
}

assertTrue(exceptionThrown.get());
assertTrue(exThrown.get());

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void testBltChangeTopVerRemoveOnlineNodeFails() throws Exception {

ignite.cluster().setBaselineTopology(baselineNodes(ignite.cluster().forServers().nodes()));

boolean expectedExceptionThrown = false;
boolean expectedExThrown = false;

try {
ignite.cluster().setBaselineTopology(singleNodeTopVer);
Expand All @@ -194,10 +194,10 @@ public void testBltChangeTopVerRemoveOnlineNodeFails() throws Exception {
assertTrue(errMsg.startsWith("Removing online nodes"));
assertTrue(errMsg.contains("[OnlineConsID]"));

expectedExceptionThrown = true;
expectedExThrown = true;
}

assertTrue(expectedExceptionThrown);
assertTrue(expectedExThrown);
}

/**
Expand All @@ -212,7 +212,7 @@ public void testOnlineNodesCannotBeRemovedFromBaselineTopology() throws Exceptio
nodeC.cluster().baselineAutoAdjustEnabled(false);
nodeC.cluster().state(ClusterState.ACTIVE);

boolean expectedExceptionIsThrown = false;
boolean expectedExIsThrown = false;

try {
nodeC.cluster().setBaselineTopology(Arrays.asList((BaselineNode)nodeA.cluster().localNode(),
Expand All @@ -223,10 +223,10 @@ public void testOnlineNodesCannotBeRemovedFromBaselineTopology() throws Exceptio
assertTrue(errMsg.startsWith("Removing online nodes"));
assertTrue(errMsg.contains("[OnlineConsID]"));

expectedExceptionIsThrown = true;
expectedExIsThrown = true;
}

assertTrue(expectedExceptionIsThrown);
assertTrue(expectedExIsThrown);
}

/**
Expand Down Expand Up @@ -257,13 +257,13 @@ public void testNodeFailsToJoinWithIncompatiblePreviousBaselineTopology() throws
startGridWithConsistentId("A");
startGridWithConsistentId("B");

boolean expectedExceptionThrown = false;
boolean expectedExThrown = false;

try {
startGridWithConsistentId("C");
}
catch (IgniteCheckedException e) {
expectedExceptionThrown = true;
expectedExThrown = true;

if (e.getCause() != null && e.getCause().getCause() != null) {
Throwable rootCause = e.getCause().getCause();
Expand All @@ -275,7 +275,7 @@ public void testNodeFailsToJoinWithIncompatiblePreviousBaselineTopology() throws
throw e;
}

assertTrue("Expected exception wasn't thrown.", expectedExceptionThrown);
assertTrue("Expected exception wasn't thrown.", expectedExThrown);
}

/**
Expand All @@ -302,13 +302,13 @@ public void testIncompatibleBltNodeIsProhibitedToJoinCluster() throws Exception
startGridWithConsistentId("A");
startGridWithConsistentId("B");

boolean expectedExceptionThrown = false;
boolean expectedExThrown = false;

try {
startGridWithConsistentId("C");
}
catch (IgniteCheckedException e) {
expectedExceptionThrown = true;
expectedExThrown = true;

if (e.getCause() != null && e.getCause().getCause() != null) {
Throwable rootCause = e.getCause().getCause();
Expand All @@ -320,7 +320,7 @@ public void testIncompatibleBltNodeIsProhibitedToJoinCluster() throws Exception
throw e;
}

assertTrue("Expected exception wasn't thrown.", expectedExceptionThrown);
assertTrue("Expected exception wasn't thrown.", expectedExThrown);
}

/**
Expand Down Expand Up @@ -1010,13 +1010,13 @@ public void testNodeWithBltIsProhibitedToJoinNewCluster() throws Exception {

verifyBaselineTopologyOnNodes(nullVerifier, new Ignite[] {nodeA, nodeB});

boolean expectedExceptionThrown = false;
boolean expectedExThrown = false;

try {
startGridWithConsistentId("C");
}
catch (IgniteCheckedException e) {
expectedExceptionThrown = true;
expectedExThrown = true;

if (e.getCause() != null && e.getCause().getCause() != null) {
Throwable rootCause = e.getCause().getCause();
Expand All @@ -1028,7 +1028,7 @@ public void testNodeWithBltIsProhibitedToJoinNewCluster() throws Exception {
throw e;
}

assertTrue("Expected exception wasn't thrown.", expectedExceptionThrown);
assertTrue("Expected exception wasn't thrown.", expectedExThrown);
}

/**
Expand Down
Loading

0 comments on commit fe11df1

Please sign in to comment.