From b1ac8e9027738f16050829fa13f645bfbd1bfb47 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 19 Aug 2013 14:01:48 +0200 Subject: [PATCH] Switched all catch (Exception e) to catch (Throwable e) --- .../action/bulk/TransportShardBulkAction.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index b4a803e281a..eef5f634451 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -166,7 +166,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation } ops[requestIndex] = result.op; } - } catch (Exception e) { + } catch (Throwable e) { // rethrow the failure if we are going to retry on primary and let parent failure to handle it if (retryPrimaryException(e)) { // restore updated versions... @@ -191,7 +191,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation // add the response DeleteResponse deleteResponse = shardDeleteOperation(deleteRequest, indexShard).response(); responses[requestIndex] = new BulkItemResponse(item.id(), "delete", deleteResponse); - } catch (Exception e) { + } catch (Throwable e) { // rethrow the failure if we are going to retry on primary and let parent failure to handle it if (retryPrimaryException(e)) { // restore updated versions... @@ -275,12 +275,12 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation if (updateAttemptsCount >= updateRequest.retryOnConflict()) { // we can't try any more responses[requestIndex] = new BulkItemResponse(item.id(), "update", - new BulkItemResponse.Failure(updateRequest.index(), updateRequest.type(), updateRequest.id(), ExceptionsHelper.detailedMessage(t)));; + new BulkItemResponse.Failure(updateRequest.index(), updateRequest.type(), updateRequest.id(), ExceptionsHelper.detailedMessage(t))); + ; request.items()[requestIndex] = null; // do not send to replicas - } - } - else { + } + } else { // rethrow the failure if we are going to retry on primary and let parent failure to handle it if (retryPrimaryException(t)) { // restore updated versions... @@ -339,7 +339,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation if (request.refresh()) { try { indexShard.refresh(new Engine.Refresh(false)); - } catch (Exception e) { + } catch (Throwable e) { // ignore } } @@ -516,7 +516,6 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation } } - @Override protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) { IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId); final BulkShardRequest request = shardRequest.request; @@ -538,7 +537,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation Engine.Create create = indexShard.prepareCreate(sourceToParse).version(indexRequest.version()).origin(Engine.Operation.Origin.REPLICA); indexShard.create(create); } - } catch (Exception e) { + } catch (Throwable e) { // ignore, we are on backup } } else if (item.request() instanceof DeleteRequest) { @@ -546,7 +545,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation try { Engine.Delete delete = indexShard.prepareDelete(deleteRequest.type(), deleteRequest.id(), deleteRequest.version()).origin(Engine.Operation.Origin.REPLICA); indexShard.delete(delete); - } catch (Exception e) { + } catch (Throwable e) { // ignore, we are on backup } } @@ -555,7 +554,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation if (request.refresh()) { try { indexShard.refresh(new Engine.Refresh(false)); - } catch (Exception e) { + } catch (Throwable e) { // ignore } } @@ -585,7 +584,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation } } }); - } catch (Exception e) { + } catch (Throwable e) { logger.warn("failed to update master on updated mapping for index [{}], type [{}]", e, index, type); } }