You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@slider.apache.org by "Steve Loughran (JIRA)" <ji...@apache.org> on 2016/07/15 09:43:20 UTC
[jira] [Commented] (SLIDER-1156) Code issue - API usage error
[ https://issues.apache.org/jira/browse/SLIDER-1156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15379123#comment-15379123 ]
Steve Loughran commented on SLIDER-1156:
----------------------------------------
looks like a real bug. We should build a queue of requests to delete, then execute them next. Easily done.
> Code issue - API usage error
> ----------------------------
>
> Key: SLIDER-1156
> URL: https://issues.apache.org/jira/browse/SLIDER-1156
> Project: Slider
> Issue Type: Bug
> Components: other
> Affects Versions: Slider 0.91
> Reporter: Gour Saha
> Assignee: Steve Loughran
> Fix For: Slider 1.0.0
>
>
> The following error report is provided by coverity scan report on below method in OutstandingRequestTracker.java -
> {code}
> 398 @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
> 399 public synchronized List<AbstractRMOperation> cancelOutstandingAARequests() {
> 400
> 401 log.debug("Looking for AA request to cancel");
> 402 List<AbstractRMOperation> operations = new ArrayList<>();
> 403
> 404 // first, all placed requests
> 1. return_collection_alias: Call to entrySet returns an Iterable equivalent to placedRequests.
> 2. enhanced_for: Starting an iteration on placedRequests.entrySet().
> 3. Iterating over another element of placedRequests.entrySet()
>
> CID 120071 (#1 of 1): Using invalid iterator (INVALIDATE_ITERATOR)
> 7. invalid_loop: Attempting to obtain another element from placedRequests.entrySet() after it's been modified.
> 405 for (Map.Entry<RoleHostnamePair, OutstandingRequest> entry : placedRequests.entrySet()) {
> 406 OutstandingRequest outstandingRequest = entry.getValue();
> 407 synchronized (outstandingRequest) {
> 4. Condition outstandingRequest.isAntiAffine(), taking true branch
> 408 if (outstandingRequest.isAntiAffine()) {
> 409 // time to escalate
> 410 operations.add(outstandingRequest.createCancelOperation());
> 5. modify_iterable: Call to remove modifies Iterable placedRequests which invalidates the iterator for the loop on placedRequests.entrySet().
> 411 placedRequests.remove(entry.getKey());
> 412 }
> 413 }
> 6. Jumping back to the beginning of the loop
> 414 }
> 415 // second, all open requests
> 416 ListIterator<OutstandingRequest> orit = openRequests.listIterator();
> 417 while (orit.hasNext()) {
> 418 OutstandingRequest outstandingRequest = orit.next();
> 419 synchronized (outstandingRequest) {
> 420 if (outstandingRequest.isAntiAffine()) {
> 421 // time to escalate
> 422 operations.add(outstandingRequest.createCancelOperation());
> 423 orit.remove();
> 424 }
> 425 }
> 426 }
> 427 log.info("Cancelling {} outstanding AA requests", operations.size());
> 428
> 429 return operations;
> 430 }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)