Program: 148225
Project: 148225
Buggy source:
private void parses(boolean importFromArchieve,String zipFilePath,IProgressMonitor monitor){
  int total=500, zipCount=200, readCount=100;
  int step=1, interval=1;
  monitor.beginTask("String_Node_Str",total);
  if (importFromArchieve) {
    checkUpExchangeImport(true);
    try {
      Util.unZipFile(zipFilePath,importFolder,zipCount,monitor);
    }
 catch (    Exception e) {
      log.error(e.getMessage(),e);
    }
  }
  monitor.worked(zipCount);
  monitor.setTaskName("String_Node_Str");
  InputStreamReader reader=null;
  try {
    reader=new InputStreamReader(new FileInputStream(importFolder + "String_Node_Str"),"String_Node_Str");
    final Exports exports=(Exports)Unmarshaller.unmarshal(Exports.class,reader);
    String[] orgSchemas=exports.getSchemas();
    int idx=0;
    if (orgSchemas != null) {
      for (      String orgSchema : orgSchemas) {
        String orgSchemaCpy=new String(orgSchema);
        for (        Map.Entry<String,String> pair : ICoreConstants.rolesConvert.oldRoleToNewRoleMap.entrySet()) {
          orgSchemaCpy=orgSchemaCpy.replaceAll(pair.getKey().toString(),pair.getValue().toString());
        }
        if (!orgSchemaCpy.equals(orgSchema)) {
          orgSchemas[idx]=orgSchemaCpy;
        }
        idx++;
      }
    }
    try {
      LocalTreeObjectRepository.getInstance().makeUpDocWithImportCategory(orgSchemas,serverRoot);
    }
 catch (    Exception e) {
    }
    if (exports.getAutoIncrement() != null) {
      try {
        port.getAutoIncrement(new WSAutoIncrement(exports.getAutoIncrement()));
      }
 catch (      Exception e) {
      }
    }
    final TreeParent reserverRoot=new TreeParent(serverRoot.getDisplayName(),null,TreeObject._SERVER_,serverRoot.getWsKey(),serverRoot.getWsObject());
    reserverRoot.setUser(serverRoot.getUser());
    TreeParent clusters=new TreeParent(EXtentisObjects.DataCluster.getDisplayName(),reserverRoot,TreeObject.DATA_CLUSTER,null,null);
    TreeParent models=new TreeParent(EXtentisObjects.DataMODEL.getDisplayName(),reserverRoot,TreeObject.DATA_MODEL,null,null);
    TreeParent menus=new TreeParent(EXtentisObjects.Menu.getDisplayName(),reserverRoot,TreeObject.MENU,null,null);
    TreeParent roles=new TreeParent(EXtentisObjects.Role.getDisplayName(),reserverRoot,TreeObject.ROLE,null,null);
    TreeParent eventManager=new TreeParent(EXtentisObjects.EventManagement.getDisplayName(),reserverRoot,TreeObject.EVENT_MANAGEMENT,null,null);
    TreeParent routingrules=new TreeParent(EXtentisObjects.RoutingRule.getDisplayName(),reserverRoot,TreeObject.ROUTING_RULE,null,null);
    TreeParent storeprocedures=new TreeParent(EXtentisObjects.StoredProcedure.getDisplayName(),reserverRoot,TreeObject.STORED_PROCEDURE,null,null);
    TreeParent syncplans=new TreeParent(EXtentisObjects.SynchronizationPlan.getDisplayName(),reserverRoot,TreeObject.SYNCHRONIZATIONPLAN,null,null);
    TreeParent transformers=new TreeParent(EXtentisObjects.Transformer.getDisplayName(),reserverRoot,TreeObject.TRANSFORMER,null,null);
    TreeParent pictures=new TreeParent(EXtentisObjects.PICTURESRESOURCE.getDisplayName(),reserverRoot,TreeObject.PICTURES_RESOURCE,null,null);
    TreeParent workflow=new TreeParent(EXtentisObjects.Workflow.getDisplayName(),reserverRoot,TreeObject.WORKFLOW,null,null);
    TreeParent universes=new TreeParent(EXtentisObjects.Universe.getDisplayName(),reserverRoot,TreeObject.UNIVERSE,null,null);
    TreeParent views=new TreeParent(EXtentisObjects.View.getDisplayName(),reserverRoot,TreeObject.VIEW,null,null);
    reserverRoot.addChild(clusters);
    reserverRoot.addChild(models);
    reserverRoot.addChild(menus);
    reserverRoot.addChild(roles);
    reserverRoot.addChild(storeprocedures);
    reserverRoot.addChild(syncplans);
    eventManager.addChild(transformers);
    eventManager.addChild(routingrules);
    reserverRoot.addChild(eventManager);
    reserverRoot.addChild(pictures);
    reserverRoot.addChild(workflow);
    reserverRoot.addChild(universes);
    reserverRoot.addChild(views);
    monitor.worked(readCount);
    float val=(total - zipCount - readCount) / exports.getItems().length;
    if (val > 0) {
      interval=1;
      step=Math.round(val);
    }
 else {
      step=1;
      interval=Math.round(exports.getItems().length / (total - zipCount - readCount) + 0.5f);
    }
    monitor.setTaskName("String_Node_Str");
    int tmp=1;
    for (    TreeObject obj : exports.getItems()) {
      obj.setServerRoot(reserverRoot);
switch (obj.getType()) {
case TreeObject.DATA_CLUSTER:
        clusters.addChild(obj);
      break;
case TreeObject.DATA_MODEL:
    models.addChild(obj);
  break;
case TreeObject.MENU:
menus.addChild(obj);
break;
case TreeObject.ROLE:
roles.addChild(obj);
break;
case TreeObject.ROUTING_RULE:
routingrules.addChild(obj);
break;
case TreeObject.STORED_PROCEDURE:
storeprocedures.addChild(obj);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
syncplans.addChild(obj);
break;
case TreeObject.TRANSFORMER:
transformers.addChild(obj);
break;
case TreeObject.PICTURES_RESOURCE:
pictures.addChild(obj);
break;
case TreeObject.WORKFLOW_PROCESS:
workflow.addChild(obj);
break;
case TreeObject.UNIVERSE:
universes.addChild(obj);
break;
case TreeObject.VIEW:
views.addChild(obj);
break;
default :
if (obj.getItems() != null && obj.getItems().length > 0) {
for (int i=0; i < obj.getItems().length; i++) {
if (obj.getItems()[i].split("String_Node_Str")[1] != null) dataClusterContent.put(obj.getItems()[i].split("String_Node_Str")[1],obj.getItems());
}
}
}
if (interval == 1) {
monitor.worked(step);
}
 else {
if (tmp >= interval) {
monitor.worked(step);
tmp=1;
}
 else {
tmp++;
}
}
}
Display.getDefault().syncExec(new Runnable(){
public void run(){
treeViewer.setRoot(reserverRoot);
treeViewer.getViewer().setInput(view.getSite());
treeViewer.setCheckItems(Arrays.asList(exports.getItems()));
GridData gd=(GridData)treeViewer.getViewer().getControl().getLayoutData();
gd.heightHint=300;
treeViewer.getViewer().getControl().getParent().layout(true);
treeViewer.getViewer().getControl().getShell().layout(true);
}
}
);
try {
LocalTreeObjectRepository.getInstance().setOriginalXobjectsToImport(treeViewer.getCheckNodes());
}
 catch (Exception e) {
}
}
 catch (Exception e) {
log.error(e.getMessage(),e);
}
 finally {
try {
if (reader != null) reader.close();
}
 catch (Exception e) {
}
monitor.done();
}
}

Fixed version (ground truth):
private void parses(boolean importFromArchieve,String zipFilePath,IProgressMonitor monitor){
  int total=500, zipCount=200, readCount=100;
  int step=1, interval=1;
  monitor.beginTask("String_Node_Str",total);
  if (importFromArchieve) {
    checkUpExchangeImport(true);
    try {
      Util.unZipFile(zipFilePath,importFolder,zipCount,monitor);
    }
 catch (    Exception e) {
      log.error(e.getMessage(),e);
    }
  }
  monitor.worked(zipCount);
  monitor.setTaskName("String_Node_Str");
  InputStreamReader reader=null;
  try {
    reader=new InputStreamReader(new FileInputStream(importFolder + "String_Node_Str"),"String_Node_Str");
    final Exports exports=(Exports)Unmarshaller.unmarshal(Exports.class,reader);
    String[] orgSchemas=exports.getSchemas();
    int idx=0;
    if (orgSchemas != null) {
      for (      String orgSchema : orgSchemas) {
        String orgSchemaCpy=new String(orgSchema);
        for (        Map.Entry<String,String> pair : ICoreConstants.rolesConvert.oldRoleToNewRoleMap.entrySet()) {
          orgSchemaCpy=orgSchemaCpy.replaceAll(pair.getKey().toString(),pair.getValue().toString());
        }
        if (!orgSchemaCpy.equals(orgSchema)) {
          orgSchemas[idx]=orgSchemaCpy;
        }
        idx++;
      }
    }
    try {
      LocalTreeObjectRepository.getInstance().makeUpDocWithImportCategory(orgSchemas,serverRoot);
    }
 catch (    Exception e) {
    }
    if (exports.getAutoIncrement() != null) {
      try {
        port.getAutoIncrement(new WSAutoIncrement(exports.getAutoIncrement()));
      }
 catch (      Exception e) {
      }
    }
    final TreeParent reserverRoot=new TreeParent(serverRoot.getDisplayName(),null,TreeObject._SERVER_,serverRoot.getWsKey(),serverRoot.getWsObject());
    reserverRoot.setUser(serverRoot.getUser());
    TreeParent clusters=new TreeParent(EXtentisObjects.DataCluster.getDisplayName(),reserverRoot,TreeObject.DATA_CLUSTER,null,null);
    TreeParent models=new TreeParent(EXtentisObjects.DataMODEL.getDisplayName(),reserverRoot,TreeObject.DATA_MODEL,null,null);
    TreeParent menus=new TreeParent(EXtentisObjects.Menu.getDisplayName(),reserverRoot,TreeObject.MENU,null,null);
    TreeParent roles=new TreeParent(EXtentisObjects.Role.getDisplayName(),reserverRoot,TreeObject.ROLE,null,null);
    TreeParent eventManager=new TreeParent(EXtentisObjects.EventManagement.getDisplayName(),reserverRoot,TreeObject.EVENT_MANAGEMENT,null,null);
    TreeParent routingrules=new TreeParent(EXtentisObjects.RoutingRule.getDisplayName(),reserverRoot,TreeObject.ROUTING_RULE,null,null);
    TreeParent storeprocedures=new TreeParent(EXtentisObjects.StoredProcedure.getDisplayName(),reserverRoot,TreeObject.STORED_PROCEDURE,null,null);
    TreeParent syncplans=new TreeParent(EXtentisObjects.SynchronizationPlan.getDisplayName(),reserverRoot,TreeObject.SYNCHRONIZATIONPLAN,null,null);
    TreeParent transformers=new TreeParent(EXtentisObjects.Transformer.getDisplayName(),reserverRoot,TreeObject.TRANSFORMER,null,null);
    TreeParent pictures=new TreeParent(EXtentisObjects.PICTURESRESOURCE.getDisplayName(),reserverRoot,TreeObject.PICTURES_RESOURCE,null,null);
    TreeParent workflow=new TreeParent(EXtentisObjects.Workflow.getDisplayName(),reserverRoot,TreeObject.WORKFLOW,null,null);
    TreeParent universes=new TreeParent(EXtentisObjects.Universe.getDisplayName(),reserverRoot,TreeObject.UNIVERSE,null,null);
    TreeParent views=new TreeParent(EXtentisObjects.View.getDisplayName(),reserverRoot,TreeObject.VIEW,null,null);
    reserverRoot.addChild(clusters);
    reserverRoot.addChild(models);
    reserverRoot.addChild(menus);
    reserverRoot.addChild(roles);
    reserverRoot.addChild(storeprocedures);
    reserverRoot.addChild(syncplans);
    eventManager.addChild(transformers);
    eventManager.addChild(routingrules);
    reserverRoot.addChild(eventManager);
    reserverRoot.addChild(pictures);
    reserverRoot.addChild(workflow);
    reserverRoot.addChild(universes);
    reserverRoot.addChild(views);
    monitor.worked(readCount);
    float val=(total - zipCount - readCount) / exports.getItems().length;
    if (val > 0) {
      interval=1;
      step=Math.round(val);
    }
 else {
      step=1;
      interval=Math.round(exports.getItems().length / (total - zipCount - readCount) + 0.5f);
    }
    monitor.setTaskName("String_Node_Str");
    int tmp=1;
    for (    TreeObject obj : exports.getItems()) {
      obj.setServerRoot(reserverRoot);
switch (obj.getType()) {
case TreeObject.DATA_CLUSTER:
        clusters.addChild(obj);
      break;
case TreeObject.DATA_MODEL:
    models.addChild(obj);
  break;
case TreeObject.MENU:
menus.addChild(obj);
break;
case TreeObject.ROLE:
roles.addChild(obj);
break;
case TreeObject.ROUTING_RULE:
routingrules.addChild(obj);
break;
case TreeObject.STORED_PROCEDURE:
storeprocedures.addChild(obj);
break;
case TreeObject.SYNCHRONIZATIONPLAN:
syncplans.addChild(obj);
break;
case TreeObject.TRANSFORMER:
transformers.addChild(obj);
break;
case TreeObject.PICTURES_RESOURCE:
pictures.addChild(obj);
break;
case TreeObject.WORKFLOW_PROCESS:
workflow.addChild(obj);
break;
case TreeObject.UNIVERSE:
universes.addChild(obj);
break;
case TreeObject.VIEW:
views.addChild(obj);
break;
default :
if (obj.getItems() != null && obj.getItems().length > 0) {
for (int i=0; i < obj.getItems().length; i++) {
if (obj.getItems()[i].split("String_Node_Str")[1] != null) dataClusterContent.put(obj.getItems()[i].split("String_Node_Str")[1],obj.getItems());
}
}
}
if (interval == 1) {
monitor.worked(step);
}
 else {
if (tmp >= interval) {
monitor.worked(step);
tmp=1;
}
 else {
tmp++;
}
}
}
Display.getDefault().syncExec(new Runnable(){
public void run(){
treeViewer.setRoot(reserverRoot);
treeViewer.getViewer().setInput(view.getSite());
treeViewer.setCheckItems(Arrays.asList(exports.getItems()));
GridData gd=(GridData)treeViewer.getViewer().getControl().getLayoutData();
gd.heightHint=300;
treeViewer.getViewer().getControl().getParent().layout(true);
treeViewer.getViewer().getControl().getShell().layout(true);
try {
LocalTreeObjectRepository.getInstance().setOriginalXobjectsToImport(treeViewer.getCheckNodes());
}
 catch (Exception e) {
}
}
}
);
}
 catch (Exception e) {
log.error(e.getMessage(),e);
}
 finally {
try {
if (reader != null) reader.close();
}
 catch (Exception e) {
}
monitor.done();
}
}