You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vi...@apache.org on 2019/06/13 03:22:01 UTC
[fineract] branch develop updated: Fineract-759: Thread unsafe bug
in batch transactions
This is an automated email from the ASF dual-hosted git repository.
vishwasbabu pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 48687a3 Fineract-759: Thread unsafe bug in batch transactions
new 4bc82a2 Merge pull request #580 from mohitsinha/batchfix
48687a3 is described below
commit 48687a31034c6ed3ce375a394cc623fcb517a683
Author: Mohit Sinha <mo...@gmail.com>
AuthorDate: Wed Jun 12 14:05:44 2019 +0700
Fineract-759: Thread unsafe bug in batch transactions
---
.../apache/fineract/batch/service/BatchApiServiceImpl.java | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java
index 6e61ee4..2ca9950 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/batch/service/BatchApiServiceImpl.java
@@ -63,7 +63,6 @@ public class BatchApiServiceImpl implements BatchApiService {
private final CommandStrategyProvider strategyProvider;
private final ResolutionHelper resolutionHelper;
private final TransactionTemplate transactionTemplate;
- private List<BatchResponse> checkList = new ArrayList<>();
/**
* Constructs a 'BatchApiServiceImpl' with an argument of
@@ -95,7 +94,6 @@ public class BatchApiServiceImpl implements BatchApiService {
final List<BatchResponse> responseList = new ArrayList<>(requestList.size());
final List<BatchRequestNode> batchRequestNodes = this.resolutionHelper.getDependingRequests(requestList);
- checkList.clear();
if(batchRequestNodes.isEmpty()) {
final BatchResponse response = new BatchResponse();
ErrorInfo ex = ErrorHandler.handler(new ClientDetailsNotFoundException());
@@ -122,7 +120,6 @@ public class BatchApiServiceImpl implements BatchApiService {
}
});
- checkList = responseList;
return responseList;
}
@@ -183,14 +180,15 @@ public class BatchApiServiceImpl implements BatchApiService {
@Override
public List<BatchResponse> handleBatchRequestsWithEnclosingTransaction(final List<BatchRequest> requestList, final UriInfo uriInfo) {
-
+ List<BatchResponse> responseList = new ArrayList<>();
try {
return this.transactionTemplate.execute(new TransactionCallback<List<BatchResponse>>() {
@Override
public List<BatchResponse> doInTransaction(TransactionStatus status) {
try {
- return handleBatchRequests(requestList, uriInfo);
+ responseList.addAll(handleBatchRequests(requestList, uriInfo));
+ return responseList;
} catch (RuntimeException ex) {
ErrorInfo e = ErrorHandler.handler(ex);
@@ -212,14 +210,13 @@ public class BatchApiServiceImpl implements BatchApiService {
BatchResponse errResponse = new BatchResponse();
errResponse.setStatusCode(e.getStatusCode());
- for (BatchResponse res : checkList) {
+ for (BatchResponse res : responseList) {
if (!res.getStatusCode().equals(200)) {
errResponse.setBody("Transaction is being rolled back. First erroneous request: \n" + new Gson().toJson(res));
break;
}
}
- checkList.clear();
List<BatchResponse> errResponseList = new ArrayList<>();
errResponseList.add(errResponse);
@@ -229,13 +226,12 @@ public class BatchApiServiceImpl implements BatchApiService {
BatchResponse errResponse = new BatchResponse();
errResponse.setStatusCode(e.getStatusCode());
- for (BatchResponse res : checkList) {
+ for (BatchResponse res : responseList) {
if (!res.getStatusCode().equals(200)) {
errResponse.setBody("Transaction is being rolled back. First erroneous request: \n" + new Gson().toJson(res));
break;
}
}
- checkList.clear();
List<BatchResponse> errResponseList = new ArrayList<>();
errResponseList.add(errResponse);