You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@fineract.apache.org by Mohit Sinha <mo...@gmail.com> on 2019/06/12 08:39:13 UTC
Re: Need fix suggestions for possible thread unsafe bug for batch processing
I have fixed this https://github.com/apache/fineract/pull/580
https://issues.apache.org/jira/browse/FINERACT-759
Thanks
On Tue, May 28, 2019 at 5:52 PM Mohit Sinha <mo...@gmail.com> wrote:
> Hey all,
>
> First of all, apologies for missing out on mailing standards if any for
> this community.
>
> I have noticed some errors while doing batch processing in Mifos.
>
> [image: Screen Shot 2019-05-28 at 5.36.55 PM.png]
> I found out some reasons for this on this link
> https://stackoverflow.com/questions/53470042/java-util-concurrentmodificationexception-bug-when-performing-io-operations
>
> Hence, the object might change when it is in the middle of Gson
> serialization.
>
> After further studying the codebase, I found out some possible thread
> related bugs in *BatchApiServiceImpl.java. *
> It is a singleton with a variable that stores the state for a request.
>
> private List<BatchResponse> checkList = new ArrayList<>();
>
> On line number 125,
>
> checkList = responseList;
> return responseList;
>
> This line may cause the error.
>
> There are some possible fixes for this:
>
> 1. I can remove *BatchApiServiceImpl.java *from the Spring Context and
> create a new object for every request. This will handle the possible thread
> related bugs.
> 2. In *BatchApiResource.java *line 119
>
> if (enclosingTransaction) {
> result = service.handleBatchRequestsWithEnclosingTransaction(requestList, uriInfo);
> } else {
> result = service.handleBatchRequestsWithoutEnclosingTransaction(requestList, uriInfo);
> }
>
> return this.toApiJsonSerializer.serialize(result);
>
> I can clone the *result *array and then pass it for serialization.
> This will remove the error, but won't solve possible thread related bugs.
> 3. I can modify *checkList *logic and possibly remove it from *BatchApiServiceImpl.java
> *.
>
>
> I will need your suggestions and opinions on this.
>
> Thanks,
> Mohit
>
>
>
Re: Need fix suggestions for possible thread unsafe bug for batch processing
Posted by Vishwas Babu <vi...@confluxtechnologies.com>.
Thanks Mohit ! The fix looks good and has been merged
Regards,
Vishwas
On Wed, Jun 12, 2019 at 1:39 AM Mohit Sinha <mo...@gmail.com> wrote:
> I have fixed this https://github.com/apache/fineract/pull/580
>
> https://issues.apache.org/jira/browse/FINERACT-759
>
> Thanks
>
> On Tue, May 28, 2019 at 5:52 PM Mohit Sinha <mo...@gmail.com>
> wrote:
>
>> Hey all,
>>
>> First of all, apologies for missing out on mailing standards if any for
>> this community.
>>
>> I have noticed some errors while doing batch processing in Mifos.
>>
>> [image: Screen Shot 2019-05-28 at 5.36.55 PM.png]
>> I found out some reasons for this on this link
>> https://stackoverflow.com/questions/53470042/java-util-concurrentmodificationexception-bug-when-performing-io-operations
>>
>> Hence, the object might change when it is in the middle of Gson
>> serialization.
>>
>> After further studying the codebase, I found out some possible thread
>> related bugs in *BatchApiServiceImpl.java. *
>> It is a singleton with a variable that stores the state for a request.
>>
>> private List<BatchResponse> checkList = new ArrayList<>();
>>
>> On line number 125,
>>
>> checkList = responseList;
>> return responseList;
>>
>> This line may cause the error.
>>
>> There are some possible fixes for this:
>>
>> 1. I can remove *BatchApiServiceImpl.java *from the Spring Context
>> and create a new object for every request. This will handle the possible
>> thread related bugs.
>> 2. In *BatchApiResource.java *line 119
>>
>> if (enclosingTransaction) {
>> result = service.handleBatchRequestsWithEnclosingTransaction(requestList, uriInfo);
>> } else {
>> result = service.handleBatchRequestsWithoutEnclosingTransaction(requestList, uriInfo);
>> }
>>
>> return this.toApiJsonSerializer.serialize(result);
>>
>> I can clone the *result *array and then pass it for serialization.
>> This will remove the error, but won't solve possible thread related bugs.
>> 3. I can modify *checkList *logic and possibly remove it from *BatchApiServiceImpl.java
>> *.
>>
>>
>> I will need your suggestions and opinions on this.
>>
>> Thanks,
>> Mohit
>>
>>
>>