Skip to content

Commit

Permalink
ignite-774: rethrow all errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutakGG committed Apr 23, 2015
1 parent 75425c6 commit bc89338
Show file tree
Hide file tree
Showing 62 changed files with 284 additions and 38 deletions.
Expand Up @@ -102,7 +102,7 @@ public Object gridify(ProceedingJoinPoint joinPnt) throws Throwable {
// If task name was specified.
return ignite.compute().withTimeout(ann.timeout()).execute(ann.taskName(), arg);
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : ((MethodSignature) joinPnt.getSignature()).getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -113,7 +113,7 @@ public Object gridify(ProceedingJoinPoint joinPnt) throws Throwable {
return execute(ignite.compute(), joinPnt.getSignature().getDeclaringType(), arg, nodeFilter,
ann.threshold(), ann.splitSize(), ann.timeout());
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : ((MethodSignature) joinPnt.getSignature()).getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -113,7 +113,7 @@ public Object gridify(ProceedingJoinPoint joinPnt) throws Throwable {
return execute(mtd, ignite.compute(), joinPnt.getSignature().getDeclaringType(), arg, nodeFilter,
ann.threshold(), ann.splitSize(), ann.timeout());
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : ((MethodSignature) joinPnt.getSignature()).getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -108,7 +108,7 @@ public class GridifySetToSetSpringAspect extends GridifySetToSetAbstractAspect i
return execute(ignite.compute(), invoc.getMethod().getDeclaringClass(), arg, nodeFilter,
ann.threshold(), ann.splitSize(), ann.timeout());
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : invoc.getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -108,7 +108,7 @@ public class GridifySetToValueSpringAspect extends GridifySetToValueAbstractAspe
return execute(mtd, ignite.compute(), invoc.getMethod().getDeclaringClass(), arg, nodeFilter,
ann.threshold(), ann.splitSize(), ann.timeout());
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : invoc.getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -96,7 +96,7 @@ public class GridifySpringAspect implements MethodInterceptor {
// If task name was specified.
return ignite.compute().withTimeout(ann.timeout()).execute(ann.taskName(), arg);
}
catch (Throwable e) {
catch (Exception e) {
for (Class<?> ex : invoc.getMethod().getExceptionTypes()) {
// Descend all levels down.
Throwable cause = e.getCause();
Expand Down
Expand Up @@ -113,6 +113,9 @@ public class CachingProvider implements javax.cache.spi.CachingProvider {

fut.onDone(e);

if (e instanceof Error)
throw (Error)e;

throw CU.convertToCacheException(U.cast(e));
}
}
Expand Down
Expand Up @@ -138,7 +138,8 @@ public CacheQueryExecutedEvent(
/**
* Gets query type.
*
* @return Query type. Can be {@code "SQL"}, {@code "TEXT"}, {@code "SCAN"} or {@code "SPI"}.
* @return Query type. Can be {@code "SQL"}, {@code "SQL_FIELDS"}, {@code "FULL_TEXT"}, {@code "SCAN"},
* {@code "CONTINUOUS"} or {@code "SPI"}.
*/
public String queryType() {
return qryType;
Expand Down
Expand Up @@ -164,7 +164,8 @@ public CacheQueryReadEvent(
/**
* Gets query type.
*
* @return Query type. Can be {@code "SQL"}, {@code "TEXT"}, {@code "SCAN"} or {@code "SPI"}.
* @return Query type. Can be {@code "SQL"}, {@code "SQL_FIELDS"}, {@code "FULL_TEXT"}, {@code "SCAN"},
* {@code "CONTINUOUS"} or {@code "SPI"}.
*/
public String queryType() {
return qryType;
Expand Down
Expand Up @@ -512,6 +512,9 @@ private void notifyLifecycleBeansEx(LifecycleEventType evt) {
catch (Throwable e) {
U.error(log, "Failed to notify lifecycle bean (safely ignored) [evt=" + evt +
", gridName=" + gridName + ']', e);

if (e instanceof Error)
throw (Error)e;
}
}

Expand Down Expand Up @@ -822,7 +825,9 @@ else if (X.hasCause(e, InterruptedException.class, IgniteInterruptedCheckedExcep

stop(true);

if (e instanceof IgniteCheckedException)
if (e instanceof Error)
throw e;
else if (e instanceof IgniteCheckedException)
throw (IgniteCheckedException)e;
else
throw new IgniteCheckedException(e);
Expand Down Expand Up @@ -1624,7 +1629,7 @@ else if (s.contains("clojure")) {

return "Scala ver. " + props.getProperty("version.number", "<unknown>");
}
catch (Throwable ignore) {
catch (Exception ignore) {
return "Scala ver. <unknown>";
}
}
Expand Down Expand Up @@ -1703,6 +1708,9 @@ else if (state == STARTING)
errOnStop = true;

U.error(log, "Failed to pre-stop processor: " + comp, e);

if (e instanceof Error)
throw e;
}
}

Expand Down Expand Up @@ -1787,6 +1795,9 @@ else if (state == STARTING)
errOnStop = true;

U.error(log, "Failed to stop component (ignoring): " + comp, e);

if (e instanceof Error)
throw (Error)e;
}
}

Expand Down
Expand Up @@ -1465,6 +1465,9 @@ private void start0(GridStartContext startCtx) throws IgniteCheckedException {
catch (Throwable e) {
unregisterFactoryMBean();

if (e instanceof Error)
throw e;

throw new IgniteCheckedException("Unexpected exception when starting grid.", e);
}
finally {
Expand Down Expand Up @@ -1981,6 +1984,9 @@ private synchronized void stop0(boolean cancel) {
}
catch (Throwable e) {
U.error(log, "Failed to properly stop grid instance due to undeclared exception.", e);

if (e instanceof Error)
throw e;
}
finally {
state = grid0.context().segmented() ? STOPPED_ON_SEGMENTATION : STOPPED;
Expand Down
Expand Up @@ -435,7 +435,7 @@ private boolean isLocallyExcluded(String name) {
}
// Catch Throwable to secure against any errors resulted from
// corrupted class definitions or other user errors.
catch (Throwable e) {
catch (Exception e) {
throw new ClassNotFoundException("Failed to load class due to unexpected error: " + name, e);
}

Expand Down
Expand Up @@ -1640,6 +1640,9 @@ private String quietNode(ClusterNode node) {
}
catch (Throwable t) {
U.error(log, "Unexpected exception in discovery worker thread (ignored).", t);

if (t instanceof Error)
throw (Error)t;
}
}
}
Expand Down
Expand Up @@ -740,6 +740,9 @@ private void notifyListeners(@Nullable Collection<GridLocalEventListener> set, E
}
catch (Throwable e) {
U.error(log, "Unexpected exception in listener notification for event: " + evt, e);

if (e instanceof Error)
throw (Error)e;
}
}
}
Expand Down Expand Up @@ -1077,6 +1080,9 @@ private class RequestListener implements GridMessageListener {
evts = Collections.emptyList();

ex = e;

if (e instanceof Error)
throw (Error)e;
}

// Response message.
Expand Down
Expand Up @@ -98,6 +98,9 @@ public int loadAllThreshold() {
catch (Throwable e) {
fut.onError(key, e);

if (e instanceof Error)
throw e;

throw e;
}
}
Expand Down Expand Up @@ -173,6 +176,9 @@ public void loadAll(Collection<? extends K> keys, final IgniteBiInClosure<K, V>
catch (Throwable e) {
span.onError(needLoad, e);

if (e instanceof Error)
throw e;

throw e;
}
}
Expand Down
Expand Up @@ -289,6 +289,9 @@ private void onMessage0(final UUID nodeId, final GridCacheMessage cacheMsg,
"[senderId=" + nodeId + ", err=" + X.cause(e, ClassNotFoundException.class).getMessage() + ']');
else
U.error(log, "Failed to process message [senderId=" + nodeId + ']', e);

if (e instanceof Error)
throw (Error)e;
}
finally {
if (depEnabled)
Expand Down Expand Up @@ -326,6 +329,9 @@ private void processMessage(UUID nodeId, GridCacheMessage msg,
}
catch (Throwable e) {
U.error(log, "Failed processing message [senderId=" + nodeId + ", msg=" + msg + ']', e);

if (e instanceof Error)
throw e;
}
finally {
// Reset thread local context.
Expand Down
Expand Up @@ -659,6 +659,9 @@ else if (op == READ) {
// as there is no way to rollback at this point.
err = new IgniteTxHeuristicCheckedException("Commit produced a runtime exception " +
"(all transaction entries will be invalidated): " + CU.txString(this), ex);

if (ex instanceof Error)
throw (Error)ex;
}
}
}
Expand Down
Expand Up @@ -673,6 +673,9 @@ public IgniteInternalFuture<IgniteInternalTx> prepareAsync(
catch (Throwable ex) {
U.error(log, "Failed to send finish response to node (transaction was " +
(commit ? "committed" : "rolledback") + ") [node=" + nearNodeId + ", res=" + res + ']', ex);

if (ex instanceof Error)
throw (Error)ex;
}
}
else {
Expand Down
Expand Up @@ -631,6 +631,9 @@ public void init() throws IgniteInterruptedCheckedException {

onDone(e);

if (e instanceof Error)
throw (Error)e;

return;
}

Expand Down
Expand Up @@ -231,6 +231,9 @@ public void onResult(UUID nodeId, GridNearTxFinishResponse res) {
}
catch (Throwable t) {
U.error(log, "Failed to invalidate entry.", t);

if (t instanceof Error)
throw (Error)t;
}
}
}
Expand Down
Expand Up @@ -191,6 +191,9 @@ protected void removeQueryFuture(long reqId) {
U.error(log(), "Failed to run query.", e);

sendQueryResponse(sndId, new GridCacheQueryResponse(cctx.cacheId(), req.id(), e.getCause()), 0);

if (e instanceof Error)
throw (Error)e;
}
finally {
threads.remove(req.id());
Expand Down
Expand Up @@ -91,6 +91,9 @@ private class LocalQueryRunnable<K, V, R> implements GridPlainRunnable {
}
catch (Throwable e) {
onDone(e);

if (e instanceof Error)
throw (Error)e;
}
}

Expand Down
Expand Up @@ -405,6 +405,9 @@ public void onPage(@Nullable UUID nodeId, @Nullable Collection<?> data, @Nullabl
}
catch (Throwable e) {
onPageError(nodeId, e);

if (e instanceof Error)
throw (Error)e;
}
}

Expand Down
Expand Up @@ -1187,6 +1187,9 @@ protected void runFieldsQuery(GridCacheQueryInfo qryInfo) {
U.error(log, "Failed to run fields query [qry=" + qryInfo + ", node=" + cctx.nodeId() + "]", e);

onFieldsPageReady(qryInfo.local(), qryInfo, null, null, null, true, e);

if (e instanceof Error)
throw (Error)e;
}
finally {
if (rmvRes)
Expand Down Expand Up @@ -1439,6 +1442,9 @@ protected void runQuery(GridCacheQueryInfo qryInfo) {
U.error(log, "Failed to run query [qry=" + qryInfo + ", node=" + cctx.nodeId() + "]", e);

onPageReady(loc, qryInfo, null, true, e);

if (e instanceof Error)
throw (Error)e;
}
finally {
if (rmvIter)
Expand Down Expand Up @@ -1530,6 +1536,9 @@ private QueryResult<K, V> queryResult(Map<Long, GridFutureAdapter<QueryResult<K,
}
catch (Throwable e) {
fut.onDone(e);

if (e instanceof Error)
throw (Error)e;
}
}

Expand Down
Expand Up @@ -156,6 +156,9 @@ private JdbcDriverMetadataJob(@Nullable String cacheName) {
catch (IgniteCheckedException e) {
throw new IgniteException(e);
}

if (t instanceof Error)
throw (Error)t;
}

byte[] packet = new byte[data.length + 1];
Expand Down
Expand Up @@ -378,8 +378,8 @@ protected final void awaitSignal() throws InterruptedException {
* @return Flag indicating whether near cache should be updated.
*/
protected boolean updateNearCache(
GridCacheContext<?, ?> cacheCtx,
KeyCacheObject key,
GridCacheContext<?, ?> cacheCtx,
KeyCacheObject key,
AffinityTopologyVersion topVer
) {
return false;
Expand Down Expand Up @@ -472,6 +472,9 @@ protected void uncommit() {
catch (Throwable t) {
U.error(log, "Failed to invalidate transaction entries while reverting a commit.", t);

if (t instanceof Error)
throw (Error)t;

break;
}
}
Expand Down

0 comments on commit bc89338

Please sign in to comment.