Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/21/11 16:57:14 (13 years ago)
Author:
ascheibe
Message:

#1672 don't crash if there are no child hive tasks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveTasks/OptimizerHiveTask.cs

    r7219 r7222  
    140140            }
    141141          }
    142         } finally { childHiveTasksLock.ExitWriteLock(); }
     142        }
     143        finally { childHiveTasksLock.ExitWriteLock(); }
    143144      }
    144145    }
     
    155156            }
    156157          }
    157         } finally { childHiveTasksLock.ExitWriteLock(); }
     158        }
     159        finally { childHiveTasksLock.ExitWriteLock(); }
    158160      }
    159161    }
     
    165167            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
    166168          }
    167         } finally { childHiveTasksLock.ExitWriteLock(); }
     169        }
     170        finally { childHiveTasksLock.ExitWriteLock(); }
    168171      }
    169172    }
     
    175178            this.childHiveTasks.Remove(this.GetChildByOptimizer(item.Value));
    176179          }
    177         } finally { childHiveTasksLock.ExitWriteLock(); }
     180        }
     181        finally { childHiveTasksLock.ExitWriteLock(); }
    178182      }
    179183    }
     
    197201      }
    198202
    199       childHiveTasksLock.EnterReadLock();
    200       OptimizerHiveTask child = (OptimizerHiveTask)this.ChildHiveTasks.Single(j => j.Task.Id == childTaskId);
    201       try {
    202         if (!optimizerTask.ComputeInParallel) {
     203      IEnumerable<HiveTask> childs = this.ChildHiveTasks.Where(j => j.Task.Id == childTaskId);
     204      //TODO: in very rare cases childs is empty. This shouldn't be the case and should be further investigated.
     205      if (childs.Count() > 0) {
     206        OptimizerHiveTask child = childs.First() as OptimizerHiveTask;
     207
     208        if (child != null && !optimizerTask.ComputeInParallel) {
    203209          child.syncTasksWithOptimizers = false;
    204210          child.ItemTask = optimizerTask;
    205211          child.syncTasksWithOptimizers = true;
    206212        }
    207       } finally { childHiveTasksLock.ExitReadLock(); }
     213      }
     214
    208215      syncTasksWithOptimizers = true;
    209216    }
     
    267274          child.SetIndexInParentOptimizerList(this);
    268275        }
    269       } finally { childHiveTasksLock.ExitReadLock(); }
     276      }
     277      finally { childHiveTasksLock.ExitReadLock(); }
    270278    }
    271279
     
    337345        }
    338346        return null;
    339       } finally { childHiveTasksLock.ExitReadLock(); }
     347      }
     348      finally { childHiveTasksLock.ExitReadLock(); }
    340349    }
    341350
     
    348357        }
    349358        return null;
    350       } finally { childHiveTasksLock.ExitReadLock(); }
     359      }
     360      finally { childHiveTasksLock.ExitReadLock(); }
    351361    }
    352362
Note: See TracChangeset for help on using the changeset viewer.