Program: 121592
Project: 121592
Buggy source:
/** 
 * Main Fields addControls.
 */
@Override protected void addFieldsListeners(){
  fileFieldJSON.addSelectionListener(new SelectionListener(){
    public void widgetSelected(    SelectionEvent event){
      if (fileFieldJSON.getResult() == null) {
        return;
      }
      String text=fileFieldJSON.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      File file=new File(text);
      if (file.exists()) {
        if (file.exists()) {
          String tempxml=null;
          if (JSONFileStep1Form.this.wizard.getTempJsonPath() == null || JSONFileStep1Form.this.wizard.getTempJsonPath().length() == 0) {
            tempxml=JSONUtil.changeJsonToXml(text);
            JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
          }
 else {
            tempxml=JSONFileStep1Form.this.wizard.getTempJsonPath();
          }
          valid=treePopulator.populateTree(tempxml,treeNode);
        }
        checkFieldsValue();
      }
    }
    public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  fileFieldJSON.addModifyListener(new ModifyListener(){
    public void modifyText(    final ModifyEvent e){
      String text=fileFieldJSON.getText();
      File temp=new File(text);
      if (!temp.exists()) {
        return;
      }
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),connectionItem.getConnection().getContextName());
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
        getConnection().getLoop().clear();
        xsdPathChanged=true;
      }
 else {
        xsdPathChanged=false;
      }
      getConnection().setJSONFilePath(PathUtils.getPortablePath(fileFieldJSON.getText()));
      JSONWizard wizard=((JSONWizard)getPage().getWizard());
      wizard.setTreeRootNode(treeNode);
      BufferedReader in=null;
      File file=null;
      if (tempJSONXsdPath != null && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0 && !isModifing) {
        file=new File(tempJSONXsdPath);
        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 e3) {
            ExceptionHandler.process(e3);
          }
        }
      }
 else {
        file=new File(text);
      }
      setFileContent(file);
      try {
        Charset guessedCharset=CharsetToolkit.guessEncoding(file,4096);
        String str;
        in=new BufferedReader(new InputStreamReader(new FileInputStream(file),guessedCharset.displayName()));
        while ((str=in.readLine()) != null) {
          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);
            }
          }
        }
      }
 catch (      Exception ex) {
        String fileStr=text;
        String msgError="String_Node_Str" + "String_Node_Str" + fileStr.replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
        if (ex instanceof FileNotFoundException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (ex instanceof EOFException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (ex instanceof IOException) {
          msgError=msgError + "String_Node_Str";
        }
 else {
          msgError=msgError + "String_Node_Str";
        }
        if (!isReadOnly()) {
          updateStatus(IStatus.ERROR,msgError);
        }
      }
 finally {
        try {
          if (in != null) {
            in.close();
          }
        }
 catch (        Exception ex2) {
          ExceptionHandler.process(ex2);
        }
      }
      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(){
    public void modifyText(    final ModifyEvent e){
      getConnection().setEncoding(encodingCombo.getText());
      checkFieldsValue();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Main Fields addControls.
 */
@Override protected void addFieldsListeners(){
  fileFieldJSON.addSelectionListener(new SelectionListener(){
    public void widgetSelected(    SelectionEvent event){
      if (fileFieldJSON.getResult() == null) {
        return;
      }
      String text=fileFieldJSON.getText();
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),true);
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      File file=new File(text);
      if (file.exists()) {
        if (file.exists()) {
          String tempxml=JSONUtil.changeJsonToXml(text);
          JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
          valid=treePopulator.populateTree(tempxml,treeNode);
        }
        checkFieldsValue();
      }
    }
    public void widgetDefaultSelected(    SelectionEvent e){
    }
  }
);
  fileFieldJSON.addModifyListener(new ModifyListener(){
    public void modifyText(    final ModifyEvent e){
      String text=fileFieldJSON.getText();
      File temp=new File(text);
      if (!temp.exists()) {
        return;
      }
      if (isContextMode()) {
        ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(),connectionItem.getConnection().getContextName());
        text=TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType,text));
      }
      if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
        getConnection().getLoop().clear();
        xsdPathChanged=true;
      }
 else {
        xsdPathChanged=false;
      }
      getConnection().setJSONFilePath(PathUtils.getPortablePath(fileFieldJSON.getText()));
      JSONWizard wizard=((JSONWizard)getPage().getWizard());
      wizard.setTreeRootNode(treeNode);
      BufferedReader in=null;
      File file=null;
      if (tempJSONXsdPath != null && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0 && !isModifing) {
        file=new File(tempJSONXsdPath);
        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 e3) {
            ExceptionHandler.process(e3);
          }
        }
      }
 else {
        file=new File(text);
      }
      setFileContent(file);
      try {
        Charset guessedCharset=CharsetToolkit.guessEncoding(file,4096);
        String str;
        in=new BufferedReader(new InputStreamReader(new FileInputStream(file),guessedCharset.displayName()));
        while ((str=in.readLine()) != null) {
          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);
            }
          }
        }
      }
 catch (      Exception ex) {
        String fileStr=text;
        String msgError="String_Node_Str" + "String_Node_Str" + fileStr.replace("String_Node_Str","String_Node_Str") + "String_Node_Str";
        if (ex instanceof FileNotFoundException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (ex instanceof EOFException) {
          msgError=msgError + "String_Node_Str";
        }
 else         if (ex instanceof IOException) {
          msgError=msgError + "String_Node_Str";
        }
 else {
          msgError=msgError + "String_Node_Str";
        }
        if (!isReadOnly()) {
          updateStatus(IStatus.ERROR,msgError);
        }
      }
 finally {
        try {
          if (in != null) {
            in.close();
          }
        }
 catch (        Exception ex2) {
          ExceptionHandler.process(ex2);
        }
      }
      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(){
    public void modifyText(    final ModifyEvent e){
      getConnection().setEncoding(encodingCombo.getText());
      checkFieldsValue();
    }
  }
);
}