Program: 137560
Project: 137560
Buggy source:
@Override public void doSave(IProgressMonitor monitor){
  ReturnCode rc=canSave();
  if (!rc.isOk()) {
    return;
  }
  super.doSave(monitor);
  boolean needReloadJUDIJar=false;
  if (!checkJavaUDIBeforeSave()) {
    ((IndicatorEditor)this.getEditor()).setSaveActionButtonState(false);
    String message=DefaultMessagesImpl.getString("String_Node_Str");
    MessageUI.openWarning(message);
    return;
  }
  if (!checkWhithspace()) {
    MessageUI.openError(DefaultMessagesImpl.getString("String_Node_Str"));
    return;
  }
  rc=checkBeforeSave();
  if (rc.isOk()) {
    if (definition instanceof UDIndicatorDefinition) {
      UDIndicatorDefinition def=(UDIndicatorDefinition)definition;
      EList<TdExpression> viewValidRowsExpression=def.getViewValidRowsExpression();
      viewValidRowsExpression.clear();
      viewValidRowsExpression=saveFromTempMapToDefinition(viewValidRowsExpression,tempViewValidRowsExpressionMap);
      EList<TdExpression> viewInvalidRowsExpression=def.getViewInvalidRowsExpression();
      viewInvalidRowsExpression.clear();
      viewInvalidRowsExpression=saveFromTempMapToDefinition(viewInvalidRowsExpression,tempViewInvalidRowsExpressionMap);
      EList<TdExpression> viewValidValuesExpression=def.getViewValidValuesExpression();
      viewValidValuesExpression.clear();
      viewValidValuesExpression=saveFromTempMapToDefinition(viewValidValuesExpression,tempViewValidValuesExpressionMap);
      EList<TdExpression> viewInvalidValuesExpression=def.getViewInvalidValuesExpression();
      viewInvalidValuesExpression.clear();
      viewInvalidValuesExpression=saveFromTempMapToDefinition(viewInvalidValuesExpression,tempViewInvalidValuesExpressionMap);
      EList<TdExpression> viewRowsExpression=def.getViewRowsExpression();
      viewRowsExpression.clear();
      viewRowsExpression=saveFromTempMapToDefinition(viewRowsExpression,tempViewRowsExpressionMap);
      if (category != null) {
        UDIHelper.setUDICategory(definition,category);
      }
    }
    EList<TdExpression> expressions=definition.getSqlGenericExpression();
    expressions.clear();
    Iterator<CCombo> it=tempExpressionMap.keySet().iterator();
    CCombo javaUIDCombo=null;
    while (it.hasNext()) {
      CCombo cb=it.next();
      if (cb.getText().equals(PatternLanguageType.JAVA.getName())) {
        javaUIDCombo=cb;
      }
 else {
        TdExpression exp=tempExpressionMap.get(cb);
        if (exp.getBody() != null && !PluginConstant.EMPTY_STRING.equals(exp.getBody())) {
          TdExpression cloneExpression=cloneExpression(exp);
          expressions.add(cloneExpression);
        }
      }
    }
    EList<TaggedValue> tvs=definition.getTaggedValue();
    if (javaUIDCombo != null) {
      boolean isNewTaggedValue=true;
      for (      TaggedValue tv : tvs) {
        if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
          String newTagValue=((Text)javaUIDCombo.getData(TaggedValueHelper.CLASS_NAME_TEXT)).getText();
          needReloadJUDIJar=!StringUtils.equals(tv.getValue(),newTagValue);
          tv.setValue(newTagValue);
          isNewTaggedValue=false;
          continue;
        }
        if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
          String newTagValue=((Text)javaUIDCombo.getData(TaggedValueHelper.JAR_FILE_PATH)).getText();
          needReloadJUDIJar=!StringUtils.equals(tv.getValue(),newTagValue);
          tv.setValue(newTagValue);
        }
      }
      if (isNewTaggedValue) {
        TaggedValue classNameTV=TaggedValueHelper.createTaggedValue(TaggedValueHelper.CLASS_NAME_TEXT,((Text)javaUIDCombo.getData(TaggedValueHelper.CLASS_NAME_TEXT)).getText());
        TaggedValue jarPathTV=TaggedValueHelper.createTaggedValue(TaggedValueHelper.JAR_FILE_PATH,((Text)javaUIDCombo.getData(TaggedValueHelper.JAR_FILE_PATH)).getText());
        definition.getTaggedValue().add(classNameTV);
        definition.getTaggedValue().add(jarPathTV);
      }
    }
 else {
      TaggedValue tvCN=null;
      TaggedValue tvJARP=null;
      for (      TaggedValue tv : tvs) {
        if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
          tvCN=tv;
          continue;
        }
        if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
          tvJARP=tv;
        }
      }
      if (tvCN != null) {
        tvs.remove(tvCN);
      }
      if (tvJARP != null) {
        tvs.remove(tvJARP);
      }
    }
    if (hasAggregateExpression) {
      EList<TdExpression> aggregate1argFunctions=definition.getAggregate1argFunctions();
      aggregate1argFunctions.clear();
      for (      AggregateDateExpression ade : afExpressionMapTemp.values()) {
        TdExpression expression=ade.getAggregateExpression();
        if (expression.getBody() != null && !PluginConstant.EMPTY_STRING.equals(expression.getBody())) {
          aggregate1argFunctions.add(expression);
        }
      }
    }
    if (hasDateExpression) {
      EList<TdExpression> date1argFunctions=definition.getDate1argFunctions();
      date1argFunctions.clear();
      for (      AggregateDateExpression ade : afExpressionMapTemp.values()) {
        TdExpression expression=ade.getDateExpression();
        if (expression.getBody() != null && !PluginConstant.EMPTY_STRING.equals(expression.getBody())) {
          date1argFunctions.add(expression);
        }
      }
    }
    if (hasCharactersMapping) {
      EList<CharactersMapping> charactersMappings=definition.getCharactersMapping();
      charactersMappings.clear();
      for (      CharactersMapping cm : charactersMappingMapTemp.values()) {
        String c=cm.getCharactersToReplace();
        String r=cm.getReplacementCharacters();
        if (checkMappingString(c,r)) {
          charactersMappings.add(cm);
        }
 else {
          MessageUI.openError("String_Node_Str" + cm.getLanguage() + "String_Node_Str");
          return;
        }
      }
    }
    saveDefinitionParameters(definition);
    rc=UDIHelper.validate(definition);
  }
  if (this.definitionItem != null) {
    this.definitionItem.setIndicatorDefinition(definition);
  }
  ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(definitionItem,true);
  this.isDirty=false;
  if (!rc.isOk()) {
    this.isDirty=true;
    MessageDialog.openError(null,"String_Node_Str",rc.getMessage());
  }
 else   if (UDIHelper.isJUDIValid(definition) && needReloadJUDIJar) {
    UDIHelper.clearJAVAUDIMAPByIndicatorDefinition(definition);
  }
}

Fixed version (ground truth):
@Override public void doSave(IProgressMonitor monitor){
  ReturnCode rc=canSave();
  if (!rc.isOk()) {
    return;
  }
  super.doSave(monitor);
  boolean needReloadJUDIJar=false;
  if (!checkJavaUDIBeforeSave()) {
    ((IndicatorEditor)this.getEditor()).setSaveActionButtonState(false);
    String message=DefaultMessagesImpl.getString("String_Node_Str");
    MessageUI.openWarning(message);
    return;
  }
  if (!checkWhithspace()) {
    MessageUI.openError(DefaultMessagesImpl.getString("String_Node_Str"));
    return;
  }
  rc=checkBeforeSave();
  if (rc.isOk()) {
    if (definition instanceof UDIndicatorDefinition) {
      UDIndicatorDefinition def=(UDIndicatorDefinition)definition;
      EList<TdExpression> viewValidRowsExpression=def.getViewValidRowsExpression();
      viewValidRowsExpression.clear();
      viewValidRowsExpression=saveFromTempMapToDefinition(viewValidRowsExpression,tempViewValidRowsExpressionMap);
      EList<TdExpression> viewInvalidRowsExpression=def.getViewInvalidRowsExpression();
      viewInvalidRowsExpression.clear();
      viewInvalidRowsExpression=saveFromTempMapToDefinition(viewInvalidRowsExpression,tempViewInvalidRowsExpressionMap);
      EList<TdExpression> viewValidValuesExpression=def.getViewValidValuesExpression();
      viewValidValuesExpression.clear();
      viewValidValuesExpression=saveFromTempMapToDefinition(viewValidValuesExpression,tempViewValidValuesExpressionMap);
      EList<TdExpression> viewInvalidValuesExpression=def.getViewInvalidValuesExpression();
      viewInvalidValuesExpression.clear();
      viewInvalidValuesExpression=saveFromTempMapToDefinition(viewInvalidValuesExpression,tempViewInvalidValuesExpressionMap);
      EList<TdExpression> viewRowsExpression=def.getViewRowsExpression();
      viewRowsExpression.clear();
      viewRowsExpression=saveFromTempMapToDefinition(viewRowsExpression,tempViewRowsExpressionMap);
      if (category != null) {
        UDIHelper.setUDICategory(definition,category);
      }
    }
    EList<TdExpression> expressions=definition.getSqlGenericExpression();
    expressions.clear();
    Iterator<CCombo> it=tempExpressionMap.keySet().iterator();
    CCombo javaUIDCombo=null;
    while (it.hasNext()) {
      CCombo cb=it.next();
      if (cb.getText().equals(PatternLanguageType.JAVA.getName())) {
        javaUIDCombo=cb;
      }
 else {
        TdExpression exp=tempExpressionMap.get(cb);
        if (exp.getBody() != null && !PluginConstant.EMPTY_STRING.equals(exp.getBody())) {
          TdExpression cloneExpression=cloneExpression(exp);
          expressions.add(cloneExpression);
        }
      }
    }
    EList<TaggedValue> tvs=definition.getTaggedValue();
    if (javaUIDCombo != null) {
      boolean isNewTaggedValue=true;
      for (      TaggedValue tv : tvs) {
        if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
          String newTagValue=((Text)javaUIDCombo.getData(TaggedValueHelper.CLASS_NAME_TEXT)).getText();
          needReloadJUDIJar|=!StringUtils.equals(tv.getValue(),newTagValue);
          tv.setValue(newTagValue);
          isNewTaggedValue=false;
          continue;
        }
        if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
          String newTagValue=((Text)javaUIDCombo.getData(TaggedValueHelper.JAR_FILE_PATH)).getText();
          needReloadJUDIJar|=!StringUtils.equals(tv.getValue(),newTagValue);
          tv.setValue(newTagValue);
        }
      }
      if (isNewTaggedValue) {
        TaggedValue classNameTV=TaggedValueHelper.createTaggedValue(TaggedValueHelper.CLASS_NAME_TEXT,((Text)javaUIDCombo.getData(TaggedValueHelper.CLASS_NAME_TEXT)).getText());
        TaggedValue jarPathTV=TaggedValueHelper.createTaggedValue(TaggedValueHelper.JAR_FILE_PATH,((Text)javaUIDCombo.getData(TaggedValueHelper.JAR_FILE_PATH)).getText());
        definition.getTaggedValue().add(classNameTV);
        definition.getTaggedValue().add(jarPathTV);
      }
    }
 else {
      TaggedValue tvCN=null;
      TaggedValue tvJARP=null;
      for (      TaggedValue tv : tvs) {
        if (tv.getTag().equals(TaggedValueHelper.CLASS_NAME_TEXT)) {
          tvCN=tv;
          continue;
        }
        if (tv.getTag().equals(TaggedValueHelper.JAR_FILE_PATH)) {
          tvJARP=tv;
        }
      }
      if (tvCN != null) {
        tvs.remove(tvCN);
      }
      if (tvJARP != null) {
        tvs.remove(tvJARP);
      }
    }
    if (hasAggregateExpression) {
      EList<TdExpression> aggregate1argFunctions=definition.getAggregate1argFunctions();
      aggregate1argFunctions.clear();
      for (      AggregateDateExpression ade : afExpressionMapTemp.values()) {
        TdExpression expression=ade.getAggregateExpression();
        if (expression.getBody() != null && !PluginConstant.EMPTY_STRING.equals(expression.getBody())) {
          aggregate1argFunctions.add(expression);
        }
      }
    }
    if (hasDateExpression) {
      EList<TdExpression> date1argFunctions=definition.getDate1argFunctions();
      date1argFunctions.clear();
      for (      AggregateDateExpression ade : afExpressionMapTemp.values()) {
        TdExpression expression=ade.getDateExpression();
        if (expression.getBody() != null && !PluginConstant.EMPTY_STRING.equals(expression.getBody())) {
          date1argFunctions.add(expression);
        }
      }
    }
    if (hasCharactersMapping) {
      EList<CharactersMapping> charactersMappings=definition.getCharactersMapping();
      charactersMappings.clear();
      for (      CharactersMapping cm : charactersMappingMapTemp.values()) {
        String c=cm.getCharactersToReplace();
        String r=cm.getReplacementCharacters();
        if (checkMappingString(c,r)) {
          charactersMappings.add(cm);
        }
 else {
          MessageUI.openError("String_Node_Str" + cm.getLanguage() + "String_Node_Str");
          return;
        }
      }
    }
    saveDefinitionParameters(definition);
    rc=UDIHelper.validate(definition);
  }
  if (this.definitionItem != null) {
    this.definitionItem.setIndicatorDefinition(definition);
  }
  ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(definitionItem,true);
  this.isDirty=false;
  if (!rc.isOk()) {
    this.isDirty=true;
    MessageDialog.openError(null,"String_Node_Str",rc.getMessage());
  }
 else   if (UDIHelper.isJUDIValid(definition) && needReloadJUDIJar) {
    UDIHelper.clearJAVAUDIMAPByIndicatorDefinition(definition);
  }
}