[ 
https://issues.apache.org/jira/browse/AMBARI-17820?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jaimin D Jetly updated AMBARI-17820:
------------------------------------
    Description: 
Patch includes following change:
{code}
sourceIds.forEach(function(item, index) {
         if (!dataIds.contains(item)) {
-          source.removeAt(index);
+          var sourceItem = source.findProperty('id',item);
+          source.removeObject(sourceItem);
         }
       });
{code}

The issue was because sourceIds array being iterated was assumed to have same 
length as source array whose elements are being conditionally removed.
The bug was that when condition was satisfied and an element was removed, 
source array became smaller and its elements were shifted left due to element 
removal. This made possibility that on last iteration of the loop if the 
condition to remove element is again satisfied then source array will not have 
element on the index. So source.removeAt(index); will throw no element at index 
exception

  was:
Patch includes following change:
{code}
-          source.removeAt(index);
+          var sourceItem = source.findProperty('id',item);
+          source.removeObject(sourceItem);
{code}

The isse


> UI sometimes stucks while deleting service due to JS error
> ----------------------------------------------------------
>
>                 Key: AMBARI-17820
>                 URL: https://issues.apache.org/jira/browse/AMBARI-17820
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-web
>    Affects Versions: 2.4.0
>            Reporter: Jaimin D Jetly
>            Assignee: Jaimin D Jetly
>            Priority: Critical
>             Fix For: 2.4.0
>
>         Attachments: AMBARI-17820.1.patch
>
>
> Patch includes following change:
> {code}
> sourceIds.forEach(function(item, index) {
>          if (!dataIds.contains(item)) {
> -          source.removeAt(index);
> +          var sourceItem = source.findProperty('id',item);
> +          source.removeObject(sourceItem);
>          }
>        });
> {code}
> The issue was because sourceIds array being iterated was assumed to have same 
> length as source array whose elements are being conditionally removed.
> The bug was that when condition was satisfied and an element was removed, 
> source array became smaller and its elements were shifted left due to element 
> removal. This made possibility that on last iteration of the loop if the 
> condition to remove element is again satisfied then source array will not 
> have element on the index. So source.removeAt(index); will throw no element 
> at index exception



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to