Program: 121590
Project: 121590
Buggy source:
@Override protected void addFieldsListeners(){
  jsonFilePath.addSelectionListener(new SelectionListener(){
    @Override public void widgetSelected(    SelectionEvent event){
      if (jsonFilePath.getResult() == null) {
        return;
      }
      String text=jsonFilePath.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath=JSONUtil.changeJsonToXml(text);
      }
      File file=new File(JSONFileOutputStep1Form.this.tempPath);
      if (file.exists()) {
        List<ATreeNode> treeNodes=new ArrayList<ATreeNode>();
        valid=treePopulator.populateTree(JSONFileOutputStep1Form.this.tempPath,treeNode);
        if (treeNodes.size() > 0) {
          treeNode=treeNodes.get(0);
        }
        updateConnection(text);
      }
    }
    @Override public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  jsonFilePath.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent event){
      String text=jsonFilePath.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
        getConnection().getLoop().clear();
        getConnection().getRoot().clear();
        getConnection().getGroup().clear();
        xsdPathChanged=true;
      }
 else {
        xsdPathChanged=false;
      }
      getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
      StringBuilder fileContent=new StringBuilder();
      BufferedReader in=null;
      File file=null;
      if (tempJSONPath != null && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0 && !isModifing) {
        file=new File(tempJSONPath);
        if (!file.exists()) {
          try {
            file.createNewFile();
          }
 catch (          IOException e2) {
            ExceptionHandler.process(e2);
          }
          FileOutputStream outStream;
          try {
            outStream=new FileOutputStream(file);
            outStream.write(getConnection().getFileContent());
            outStream.close();
          }
 catch (          FileNotFoundException e1) {
            ExceptionHandler.process(e1);
          }
catch (          IOException e) {
            ExceptionHandler.process(e);
          }
        }
      }
 else {
        file=new File(text);
      }
      String str;
      try {
        Charset guessCharset=CharsetToolkit.guessEncoding(file,4096);
        in=new BufferedReader(new InputStreamReader(new FileInputStream(file),guessCharset.displayName()));
        while ((str=in.readLine()) != null) {
          fileContent.append(str + "String_Node_Str");
          if (str.contains("String_Node_Str")) {
            String regex="String_Node_Str";
            Perl5Compiler compiler=new Perl5Compiler();
            Perl5Matcher matcher=new Perl5Matcher();
            Pattern pattern=null;
            try {
              pattern=compiler.compile(regex);
              if (matcher.contains(str,pattern)) {
                MatchResult matchResult=matcher.getMatch();
                if (matchResult != null) {
                  encoding=matchResult.group(1);
                }
              }
            }
 catch (            MalformedPatternException malE) {
              ExceptionHandler.process(malE);
            }
          }
        }
        fileContentText.setText(new String(fileContent));
      }
 catch (      Exception e) {
        String msgError="String_Node_Str" + "String_Node_Str" + jsonFilePath.getText().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
        if (e instanceof FileNotFoundException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (e instanceof EOFException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (e instanceof IOException) {
          msgError=msgError + "String_Node_Str";
        }
 else {
          msgError=msgError + "String_Node_Str";
        }
        fileContentText.setText(msgError);
        if (!isReadOnly()) {
          updateStatus(IStatus.ERROR,msgError);
        }
      }
 finally {
        try {
          if (in != null) {
            in.close();
          }
        }
 catch (        Exception exception) {
          ExceptionHandler.process(exception);
        }
      }
      if (getConnection().getEncoding() == null || "String_Node_Str".equals(getConnection().getEncoding())) {
        getConnection().setEncoding(encoding);
        if (encoding != null && !"String_Node_Str".equals(encoding)) {
          encodingCombo.setText(encoding);
        }
 else {
          encodingCombo.setText("String_Node_Str");
        }
      }
      checkFieldsValue();
      isModifing=true;
    }
  }
);
  encodingCombo.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      getConnection().setEncoding(encodingCombo.getText());
      checkFieldsValue();
    }
  }
);
  commonNodesLimitation.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      String str=commonNodesLimitation.getText();
      if ((!str.matches("String_Node_Str")) || (Integer.valueOf(str) < 0)) {
        commonNodesLimitation.setText(String.valueOf(treePopulator.getLimit()));
      }
 else {
        treePopulator.setLimit(Integer.valueOf(str));
      }
      if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath=JSONUtil.changeJsonToXml(jsonFilePath.getText());
      }
      File file=new File(JSONFileOutputStep1Form.this.tempPath);
      if (file.exists()) {
        valid=treePopulator.populateTree(JSONFileOutputStep1Form.this.tempPath,treeNode);
      }
      checkFieldsValue();
    }
  }
);
  commonNodesLimitation.addFocusListener(new FocusListener(){
    @Override public void focusGained(    FocusEvent e){
    }
    @Override public void focusLost(    FocusEvent e){
      commonNodesLimitation.setText(String.valueOf(TreePopulator.getLimit()));
    }
  }
);
  outputFilePath.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      getConnection().setOutputFilePath(PathUtils.getPortablePath(outputFilePath.getText()));
      checkFieldsValue();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void addFieldsListeners(){
  jsonFilePath.addSelectionListener(new SelectionListener(){
    @Override public void widgetSelected(    SelectionEvent event){
      if (jsonFilePath.getResult() == null) {
        return;
      }
      String text=jsonFilePath.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath=JSONUtil.changeJsonToXml(text);
      }
      File file=new File(text);
      if (file.exists()) {
        List<ATreeNode> treeNodes=new ArrayList<ATreeNode>();
        valid=treePopulator.populateTree(JSONUtil.changeJsonToXml(text),treeNode);
        if (treeNodes.size() > 0) {
          treeNode=treeNodes.get(0);
        }
        updateConnection(text);
      }
    }
    @Override public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  jsonFilePath.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent event){
      String text=jsonFilePath.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
        getConnection().getLoop().clear();
        getConnection().getRoot().clear();
        getConnection().getGroup().clear();
        xsdPathChanged=true;
      }
 else {
        xsdPathChanged=false;
      }
      getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonFilePath.getText()));
      StringBuilder fileContent=new StringBuilder();
      BufferedReader in=null;
      File file=null;
      if (tempJSONPath != null && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0 && !isModifing) {
        file=new File(tempJSONPath);
        if (!file.exists()) {
          try {
            file.createNewFile();
          }
 catch (          IOException e2) {
            ExceptionHandler.process(e2);
          }
          FileOutputStream outStream;
          try {
            outStream=new FileOutputStream(file);
            outStream.write(getConnection().getFileContent());
            outStream.close();
          }
 catch (          FileNotFoundException e1) {
            ExceptionHandler.process(e1);
          }
catch (          IOException e) {
            ExceptionHandler.process(e);
          }
        }
      }
 else {
        file=new File(text);
      }
      String str;
      try {
        Charset guessCharset=CharsetToolkit.guessEncoding(file,4096);
        in=new BufferedReader(new InputStreamReader(new FileInputStream(file),guessCharset.displayName()));
        while ((str=in.readLine()) != null) {
          fileContent.append(str + "String_Node_Str");
          if (str.contains("String_Node_Str")) {
            String regex="String_Node_Str";
            Perl5Compiler compiler=new Perl5Compiler();
            Perl5Matcher matcher=new Perl5Matcher();
            Pattern pattern=null;
            try {
              pattern=compiler.compile(regex);
              if (matcher.contains(str,pattern)) {
                MatchResult matchResult=matcher.getMatch();
                if (matchResult != null) {
                  encoding=matchResult.group(1);
                }
              }
            }
 catch (            MalformedPatternException malE) {
              ExceptionHandler.process(malE);
            }
          }
        }
        fileContentText.setText(new String(fileContent));
      }
 catch (      Exception e) {
        String msgError="String_Node_Str" + "String_Node_Str" + jsonFilePath.getText().replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
        if (e instanceof FileNotFoundException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (e instanceof EOFException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (e instanceof IOException) {
          msgError=msgError + "String_Node_Str";
        }
 else {
          msgError=msgError + "String_Node_Str";
        }
        fileContentText.setText(msgError);
        if (!isReadOnly()) {
          updateStatus(IStatus.ERROR,msgError);
        }
      }
 finally {
        try {
          if (in != null) {
            in.close();
          }
        }
 catch (        Exception exception) {
          ExceptionHandler.process(exception);
        }
      }
      if (getConnection().getEncoding() == null || "String_Node_Str".equals(getConnection().getEncoding())) {
        getConnection().setEncoding(encoding);
        if (encoding != null && !"String_Node_Str".equals(encoding)) {
          encodingCombo.setText(encoding);
        }
 else {
          encodingCombo.setText("String_Node_Str");
        }
      }
      checkFieldsValue();
      isModifing=true;
    }
  }
);
  encodingCombo.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      getConnection().setEncoding(encodingCombo.getText());
      checkFieldsValue();
    }
  }
);
  commonNodesLimitation.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      String str=commonNodesLimitation.getText();
      if ((!str.matches("String_Node_Str")) || (Integer.valueOf(str) < 0)) {
        commonNodesLimitation.setText(String.valueOf(treePopulator.getLimit()));
      }
 else {
        treePopulator.setLimit(Integer.valueOf(str));
      }
      if (JSONFileOutputStep1Form.this.tempPath == null) {
        JSONFileOutputStep1Form.this.tempPath=JSONUtil.changeJsonToXml(jsonFilePath.getText());
      }
      File file=new File(JSONFileOutputStep1Form.this.tempPath);
      if (file.exists()) {
        valid=treePopulator.populateTree(JSONFileOutputStep1Form.this.tempPath,treeNode);
      }
      checkFieldsValue();
    }
  }
);
  commonNodesLimitation.addFocusListener(new FocusListener(){
    @Override public void focusGained(    FocusEvent e){
    }
    @Override public void focusLost(    FocusEvent e){
      commonNodesLimitation.setText(String.valueOf(TreePopulator.getLimit()));
    }
  }
);
  outputFilePath.addModifyListener(new ModifyListener(){
    @Override public void modifyText(    ModifyEvent e){
      getConnection().setOutputFilePath(PathUtils.getPortablePath(outputFilePath.getText()));
      checkFieldsValue();
    }
  }
);
}