nus-yam/ex-repair huggingface dataset:
Program: 20105
Project: 20105
Buggy source:
/** 
 * Compute one stage in the FFT butterfly. The name "butterfly" appears because this method computes elements in pairs, and a flowgraph of the computation (output "0" comes from input "0" and "1" and output "1" comes from input "0" and "1") resembles a butterfly.
 * @param from the input sequence at each stage
 * @param to the output sequence
 * @param NPoint the total number of points
 * @param currentStage the "distance" between elements in the butterfly
 */
private void butterflyStage(Complex[] from,Complex[] to,int NPoint,int currentStage){
}

Fixed version (ground truth):
/** 
 * Compute one stage in the FFT butterfly. The name "butterfly" appears because this method computes elements in pairs, and a flowgraph of the computation (output "0" comes from input "0" and "1" and output "1" comes from input "0" and "1") resembles a butterfly.
 * @param from the input sequence at each stage
 * @param to the output sequence
 * @param NPoint the total number of points
 * @param currentStage the "distance" between elements in the butterfly
 */
private void butterflyStage(Complex[] from,Complex[] to,int NPoint,int currentStage){
  int ndx1From;
  int ndx2From;
  int ndx1To;
  int ndx2To;
  int ndxWk=0;
  Complex wkTimesF2=new Complex();
  if (currentStage > 0) {
    for (int s=0; s < currentStage; s++) {
      ndx1From=s;
      ndx2From=s + currentStage;
      ndx1To=s;
      ndx2To=s + (NPoint >> 1);
      while (ndxWk < (NPoint >> 1)) {
        wkTimesF2.multiplyComplex(Wk[ndxWk],from[ndx2From]);
        to[ndx1To].addComplex(from[ndx1From],wkTimesF2);
        to[ndx2To].subtractComplex(from[ndx1From],wkTimesF2);
        ndx1From+=(2 * currentStage);
        ndx2From+=(2 * currentStage);
        ndx1To+=currentStage;
        ndx2To+=currentStage;
        ndxWk+=currentStage;
      }
    }
    butterflyStage(to,from,NPoint,currentStage >> 1);
  }
  return;
}
Program: 20106
Project: 20106
Buggy source:
/** 
 * Constructs a default Spectrum Analyzer.
 */
public SpectrumAnalyzer(float[] input,float[] output){
  computeLog2N(NPoint);
  createWk(NPoint,false);
  Complex[] inputSeq=new Complex[NPoint];
  if (NPoint < windowSize) {
    for (int i=0; i < NPoint; i++) {
      inputSeq[i]=new Complex((double)input[i]);
    }
    for (int i=NPoint; i < windowSize; i++) {
      inputSeq[i % NPoint].addComplex(inputSeq[i % NPoint],new Complex((double)input[i]));
    }
  }
 else {
    for (int i=0; i < windowSize; i++) {
      inputSeq[i]=new Complex((double)input[i]);
    }
    for (int i=windowSize; i < NPoint; i++) {
      inputSeq[i]=new Complex();
    }
  }
  double[] outputSpectrum=new double[NPoint];
  recurseFFT(inputSeq,outputSpectrum,NPoint,false);
}

Fixed version (ground truth):
/** 
 * Constructs a default Spectrum Analyzer.
 */
public SpectrumAnalyzer(float[] input,float[] output){
  getSphinxProperties();
  computeLog2N(NPoint);
  createWk(NPoint,false);
  Complex[] inputSeq=new Complex[NPoint];
  if (NPoint < windowSize) {
    for (int i=0; i < NPoint; i++) {
      inputSeq[i]=new Complex((double)input[i]);
    }
    for (int i=NPoint; i < windowSize; i++) {
      inputSeq[i % NPoint].addComplex(inputSeq[i % NPoint],new Complex((double)input[i]));
    }
  }
 else {
    for (int i=0; i < windowSize; i++) {
      inputSeq[i]=new Complex((double)input[i]);
    }
    for (int i=windowSize; i < NPoint; i++) {
      inputSeq[i]=new Complex();
    }
  }
  double[] outputSpectrum=new double[NPoint];
  recurseFFT(inputSeq,outputSpectrum,NPoint,false);
}
Program: 20107
Project: 20107
Buggy source:
private void scanForAssets(){
  int colorCount=0;
  int assetCount=0;
  if (this.selectedFile != null && this.selectedFile.getCanonicalPath() != null) {
    File assetRoot=new File(this.selectedFile.getCanonicalPath());
    final FilenameFilter systemFileNameFiler=new FilenameFilter(){
      @Override public boolean accept(      File file,      String s){
        return !s.startsWith("String_Node_Str");
      }
    }
;
    File[] colorDirs=assetRoot.listFiles(systemFileNameFiler);
    if (colorDirs != null) {
      for (      File file : colorDirs) {
        if (file.isDirectory()) {
          colorCount++;
        }
      }
      if (colorDirs.length >= 1) {
        File exColorDir=colorDirs[0];
        File[] densities=exColorDir.listFiles(systemFileNameFiler);
        if (densities != null && densities.length >= 1) {
          File exDensity=densities[0];
          File[] assets=exDensity.listFiles(systemFileNameFiler);
          for (          File asset : assets) {
            if (!asset.isDirectory()) {
              String extension=asset.getName().substring(asset.getName().lastIndexOf("String_Node_Str") + 1);
              if (extension.equalsIgnoreCase("String_Node_Str")) {
                assetCount++;
              }
            }
          }
        }
      }
    }
  }
  foundColorsText.setText(colorCount + "String_Node_Str");
  foundAssetsText.setText(assetCount + "String_Node_Str");
}

Fixed version (ground truth):
private void scanForAssets(){
  int colorCount=0;
  int assetCount=0;
  if (this.selectedFile != null && this.selectedFile.getCanonicalPath() != null) {
    File assetRoot=new File(this.selectedFile.getCanonicalPath());
    final FilenameFilter systemFileNameFiler=new FilenameFilter(){
      @Override public boolean accept(      File file,      String s){
        return !s.startsWith("String_Node_Str");
      }
    }
;
    File[] colorDirs=assetRoot.listFiles(systemFileNameFiler);
    if (colorDirs != null) {
      for (      File file : colorDirs) {
        if (file.isDirectory()) {
          colorCount++;
        }
      }
      if (colorDirs.length >= 1) {
        File exColorDir=colorDirs[0];
        File[] densities=exColorDir.listFiles(systemFileNameFiler);
        if (densities != null && densities.length >= 1) {
          File exDensity=densities[0];
          File[] assets=exDensity.listFiles(systemFileNameFiler);
          if (assets != null) {
            for (            File asset : assets) {
              if (!asset.isDirectory()) {
                String extension=asset.getName().substring(asset.getName().lastIndexOf("String_Node_Str") + 1);
                if (extension.equalsIgnoreCase("String_Node_Str")) {
                  assetCount++;
                }
              }
            }
          }
        }
      }
    }
  }
  foundColorsText.setText(colorCount + "String_Node_Str");
  foundAssetsText.setText(assetCount + "String_Node_Str");
}
Program: 20108
Project: 20108
Buggy source:
@Nullable @Override public JComponent createComponent(){
  persistedFile=SettingsHelper.getAssetPathString();
  if (persistedFile != null) {
    VirtualFile loadedFile=VirtualFileManager.getInstance().findFileByUrl(persistedFile);
    if (loadedFile != null) {
      textFieldHome.setText(loadedFile.getCanonicalPath());
      selectedFile=loadedFile;
    }
    openBrowser.setVisible(false);
  }
  FileChooserDescriptor workingDirectoryChooserDescriptor=FileChooserDescriptorFactory.createSingleFolderDescriptor();
  String title="String_Node_Str";
  workingDirectoryChooserDescriptor.setTitle(title);
  textFieldHome.addBrowseFolderListener(title,null,null,workingDirectoryChooserDescriptor);
  textFieldHome.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor){
    @Override protected void onFileChosen(    @NotNull VirtualFile chosenFile){
      super.onFileChosen(chosenFile);
      selectionPerformed=true;
      selectedFile=chosenFile;
      scanForAssets();
    }
  }
);
  openBrowser.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      super.mouseClicked(e);
      BrowserUtil.browse(ANDROID_ICONS_URL);
    }
  }
);
  scanForAssets();
  return panel;
}

Fixed version (ground truth):
@Nullable @Override public JComponent createComponent(){
  persistedFile=SettingsHelper.getAssetPathString();
  if (persistedFile != null) {
    VirtualFile loadedFile=VirtualFileManager.getInstance().findFileByUrl(persistedFile);
    if (loadedFile != null) {
      textFieldHome.setText(loadedFile.getCanonicalPath());
      selectedFile=loadedFile;
    }
    openBrowser.setVisible(false);
  }
  FileChooserDescriptor workingDirectoryChooserDescriptor=FileChooserDescriptorFactory.createSingleFolderDescriptor();
  String title="String_Node_Str";
  workingDirectoryChooserDescriptor.setTitle(title);
  textFieldHome.addBrowseFolderListener(title,null,null,workingDirectoryChooserDescriptor);
  textFieldHome.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor){
    @Override protected void onFileChoosen(    @NotNull VirtualFile chosenFile){
      super.onFileChoosen(chosenFile);
      selectionPerformed=true;
      selectedFile=chosenFile;
      scanForAssets();
    }
  }
);
  openBrowser.addMouseListener(new MouseAdapter(){
    @Override public void mouseClicked(    MouseEvent e){
      super.mouseClicked(e);
      BrowserUtil.browse(ANDROID_ICONS_URL);
    }
  }
);
  scanForAssets();
  return panel;
}
Program: 20111
Project: 20111
Buggy source:
@Override public void dropFiles(java.util.List<VirtualFile> virtualFiles){
  if (virtualFiles != null) {
    if (virtualFiles.size() == 1) {
      VirtualFile chosenFile=virtualFiles.get(0);
      assetBrowser.setText(chosenFile.getCanonicalPath());
      selectedImage=chosenFile;
      isNinePatch=chosenFile.getName().endsWith("String_Node_Str");
      updateImage();
      fillImageInformation();
    }
  }
}

Fixed version (ground truth):
@Override public void dropFiles(java.util.List<VirtualFile> virtualFiles){
  if (virtualFiles != null) {
    if (virtualFiles.size() == 1) {
      VirtualFile chosenFile=virtualFiles.get(0);
      assetBrowser.setText(chosenFile.getCanonicalPath());
      updateImageInformation(chosenFile);
    }
  }
}
Program: 20112
Project: 20112
Buggy source:
public static void initResourceBrowser(final Project project,Module module,final String title,final TextFieldWithBrowseButton browser){
  final VirtualFile resRoot=SettingsHelper.getResRootForProject(project);
  if (resRoot == null) {
    getResRootFile(project,module,new ResourcesDialog.ResourceSelectionListener(){
      @Override public void onResourceSelected(      VirtualFile resDir){
        browser.setText(resDir.getCanonicalPath());
        SettingsHelper.saveResRootForProject(project,resDir.getUrl());
      }
    }
);
  }
 else {
    browser.setText(resRoot.getCanonicalPath());
  }
  FileChooserDescriptor workingDirectoryChooserDescriptor=FileChooserDescriptorFactory.createSingleFolderDescriptor();
  workingDirectoryChooserDescriptor.setTitle(title);
  browser.addBrowseFolderListener(title,null,project,workingDirectoryChooserDescriptor);
  browser.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor){
    @Override protected void onFileChosen(    @NotNull VirtualFile chosenFile){
      super.onFileChosen(chosenFile);
      SettingsHelper.saveResRootForProject(project,chosenFile.getUrl());
    }
  }
);
}

Fixed version (ground truth):
public static void initResourceBrowser(final Project project,Module module,final String title,final TextFieldWithBrowseButton browser){
  final VirtualFile resRoot=SettingsHelper.getResRootForProject(project);
  if (resRoot == null) {
    getResRootFile(project,module,new ResourcesDialog.ResourceSelectionListener(){
      @Override public void onResourceSelected(      VirtualFile resDir){
        browser.setText(resDir.getCanonicalPath());
        SettingsHelper.saveResRootForProject(project,resDir.getUrl());
      }
    }
);
  }
 else {
    browser.setText(resRoot.getCanonicalPath());
  }
  FileChooserDescriptor workingDirectoryChooserDescriptor=FileChooserDescriptorFactory.createSingleFolderDescriptor();
  workingDirectoryChooserDescriptor.setTitle(title);
  browser.addBrowseFolderListener(title,null,project,workingDirectoryChooserDescriptor);
  browser.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor){
    @Override protected void onFileChoosen(    @NotNull VirtualFile chosenFile){
      super.onFileChoosen(chosenFile);
      SettingsHelper.saveResRootForProject(project,chosenFile.getUrl());
    }
  }
);
}
Program: 20113
Project: 20113
Buggy source:
@Nullable @Override protected ValidationInfo doValidate(){
  if (StringUtils.isEmpty(resRoot.getText().trim())) {
    return new ValidationInfo("String_Node_Str",resRoot);
  }
  if (StringUtils.isEmpty(resExportName.getText().trim())) {
    return new ValidationInfo("String_Node_Str",resExportName);
  }
 else   if (resExportName.getText().matches("String_Node_Str")) {
    return new ValidationInfo("String_Node_Str",resExportName);
  }
  return null;
}

Fixed version (ground truth):
@Nullable @Override protected ValidationInfo doValidate(){
  if (StringUtils.isEmpty(resRoot.getText().trim())) {
    return new ValidationInfo("String_Node_Str",resRoot);
  }
  if (StringUtils.isEmpty(resExportName.getText().trim())) {
    return new ValidationInfo("String_Node_Str",resExportName);
  }
 else   if (!resExportName.getText().matches("String_Node_Str")) {
    return new ValidationInfo("String_Node_Str",resExportName);
  }
  return null;
}
Program: 20114
Project: 20114
Buggy source:
private void fillImageInformation(){
  if (selectedImage != null) {
    String canonicalPath=selectedImage.getCanonicalPath();
    if (canonicalPath != null) {
      File file=new File(canonicalPath);
      try {
        BufferedImage image=ImageIO.read(file);
        if (image != null) {
          int imageWidth=image.getWidth();
          int imageHeight=image.getHeight();
          targetHeight.setText(String.valueOf(imageHeight));
          targetWidth.setText(String.valueOf(imageWidth));
          resExportName.setText(selectedImage.getName());
          updateScaleFactors();
          updateNewSizes();
        }
      }
 catch (      IOException ignored) {
      }
    }
  }
}

Fixed version (ground truth):
private void fillImageInformation(){
  if (selectedImage != null) {
    String canonicalPath=selectedImage.getCanonicalPath();
    if (canonicalPath != null) {
      File file=new File(canonicalPath);
      try {
        BufferedImage image=ImageIO.read(file);
        if (image != null) {
          imageWidth=image.getWidth();
          imageHeight=image.getHeight();
          targetHeight.setText(String.valueOf(imageHeight));
          targetWidth.setText(String.valueOf(imageWidth));
          resExportName.setText(selectedImage.getName());
          updateScaleFactors();
          updateNewSizes();
        }
      }
 catch (      IOException ignored) {
      }
    }
  }
}
Program: 20116
Project: 20116
Buggy source:
/** 
 * Method used to extract log entry from card
 * @param pLogEntry log entry position
 */
protected List<EmvTransactionRecord> extractLogEntry(final byte[] pLogEntry) throws CommunicationException {
  List<EmvTransactionRecord> listRecord=new ArrayList<EmvTransactionRecord>();
  if (pLogEntry != null) {
    List<TagAndLength> tals=getLogFormat();
    for (int rec=1; rec <= pLogEntry[1]; rec++) {
      byte[] response=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,rec,pLogEntry[0] << 3 | 4,0).toBytes());
      if (ResponseUtils.isSucceed(response)) {
        EmvTransactionRecord record=new EmvTransactionRecord();
        record.parse(response,tals);
        if (record.getAmount() == null || record.getAmount() == 0) {
          continue;
        }
        if (record != null) {
          if (record.getCurrency() == null) {
            record.setCurrency(CurrencyEnum.XXX);
          }
          listRecord.add(record);
        }
      }
 else       if (SwEnum.getSW(response) == SwEnum.SW_6A83) {
        break;
      }
    }
  }
  return listRecord;
}

Fixed version (ground truth):
/** 
 * Method used to extract log entry from card
 * @param pLogEntry log entry position
 */
protected List<EmvTransactionRecord> extractLogEntry(final byte[] pLogEntry) throws CommunicationException {
  List<EmvTransactionRecord> listRecord=new ArrayList<EmvTransactionRecord>();
  if (pLogEntry != null) {
    List<TagAndLength> tals=getLogFormat();
    for (int rec=1; rec <= pLogEntry[1]; rec++) {
      byte[] response=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,rec,pLogEntry[0] << 3 | 4,0).toBytes());
      if (ResponseUtils.isSucceed(response)) {
        EmvTransactionRecord record=new EmvTransactionRecord();
        record.parse(response,tals);
        if (record.getAmount() >= 1500000000) {
          record.setAmount(record.getAmount() - 1500000000);
        }
        if (record.getAmount() == null || record.getAmount() == 0) {
          continue;
        }
        if (record != null) {
          if (record.getCurrency() == null) {
            record.setCurrency(CurrencyEnum.XXX);
          }
          listRecord.add(record);
        }
      }
 else {
        break;
      }
    }
  }
  return listRecord;
}
Program: 20117
Project: 20117
Buggy source:
/** 
 * Read EMV card with Payment System Environment or Proximity Payment System Environment
 * @return Read card
 */
protected EmvCard readWithPSE() throws CommunicationException {
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  EmvCard card=null;
  byte[] data=selectPaymentEnvironment();
  if (ResponseUtils.isSucceed(data)) {
    data=parseFCIProprietaryTemplate(data);
    if (ResponseUtils.isSucceed(data)) {
      String label=extractApplicationLabel(data);
      card=extractPublicData(TlvUtil.getValue(data,EmvTags.AID_CARD),label);
    }
  }
 else   if (LOGGER.isDebugEnabled()) {
    LOGGER.debug((contactLess ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
  }
  return card;
}

Fixed version (ground truth):
/** 
 * Read EMV card with Payment System Environment or Proximity Payment System Environment
 * @return Read card
 */
protected EmvCard readWithPSE() throws CommunicationException {
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("String_Node_Str");
  }
  EmvCard card=null;
  byte[] data=selectPaymentEnvironment();
  if (ResponseUtils.isSucceed(data)) {
    data=parseFCIProprietaryTemplate(data);
    if (ResponseUtils.isSucceed(data)) {
      String label=extractApplicationLabel(data);
      card=extractPublicData(getAid(data),label);
    }
  }
 else   if (LOGGER.isDebugEnabled()) {
    LOGGER.debug((contactLess ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str");
  }
  return card;
}
Program: 20118
Project: 20118
Buggy source:
@Test public void testGetLogEntry() throws Exception {
  byte[] selectResponse=BytesUtils.fromString("String_Node_Str");
  System.out.println(TlvUtil.prettyPrintAPDUResponse(selectResponse));
  byte[] data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  selectResponse=BytesUtils.fromString("String_Node_Str");
  data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  Assertions.assertThat(BytesUtils.bytesToString(data)).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testGetLogEntry() throws Exception {
  byte[] selectResponse=BytesUtils.fromString("String_Node_Str");
  byte[] data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  selectResponse=BytesUtils.fromString("String_Node_Str");
  data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  Assertions.assertThat(BytesUtils.bytesToString(data)).isEqualTo("String_Node_Str");
}
Program: 20119
Project: 20119
Buggy source:
/** 
 * Method to get the annotation set from the current class
 * @return An annotation set which contain all annotation data
 */
private Collection<AnnotationData> getAnnotationSet(final List<TagAndLength> pTags){
  Collection<AnnotationData> ret=null;
  if (pTags != null) {
    Map<ITag,AnnotationData> data=AnnotationUtils.getInstance().getMap().get(getClass().getName());
    ret=new ArrayList<AnnotationData>(data.size());
    for (    TagAndLength tal : pTags) {
      AnnotationData ann=data.get(tal.getTag());
      ann.setSize(tal.getLength() * BitUtils.BYTE_SIZE);
      ret.add(ann);
    }
  }
 else {
    ret=AnnotationUtils.getInstance().getMapSet().get(getClass().getName());
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method to get the annotation set from the current class
 * @return An annotation set which contain all annotation data
 */
private Collection<AnnotationData> getAnnotationSet(final List<TagAndLength> pTags){
  Collection<AnnotationData> ret=null;
  if (pTags != null) {
    Map<ITag,AnnotationData> data=AnnotationUtils.getInstance().getMap().get(getClass().getName());
    ret=new ArrayList<AnnotationData>(data.size());
    for (    TagAndLength tal : pTags) {
      AnnotationData ann=data.get(tal.getTag());
      if (ann != null) {
        ann.setSize(tal.getLength() * BitUtils.BYTE_SIZE);
        ret.add(ann);
      }
    }
  }
 else {
    ret=AnnotationUtils.getInstance().getMapSet().get(getClass().getName());
  }
  return ret;
}
Program: 20120
Project: 20120
Buggy source:
/** 
 * Extract track 2 data (card number + expire date)
 * @param pData data
 */
protected EmvCard extractTrack2Data(final byte[] pData){
  EmvCard card=null;
  byte[] track2=TlvUtil.getValue(pData,EmvTags.TRACK_2_EQV_DATA);
  if (track2 != null) {
    card=new EmvCard();
    BitUtils bit=new BitUtils(track2);
    card.setCardNumber(bit.getNextHexaString(64));
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
    try {
      String date=bit.getNextHexaString(5 * 4);
      if (date.length() > 5) {
        date=date.substring(0,5);
      }
      card.setExpireDate(DateUtils.truncate(sdf.parse(date),Calendar.MONTH));
    }
 catch (    ParseException e) {
      LOGGER.error("String_Node_Str");
    }
    byte[] cardHolderByte=TlvUtil.getValue(pData,EmvTags.CARDHOLDER_NAME);
    if (cardHolderByte != null) {
      card.setHolderName(new String(cardHolderByte).trim());
    }
  }
  return card;
}

Fixed version (ground truth):
/** 
 * Extract track 2 data (card number + expire date)
 * @param pData data
 */
protected EmvCard extractTrack2Data(final byte[] pData){
  EmvCard card=null;
  byte[] track2=TlvUtil.getValue(pData,EmvTags.TRACK_2_EQV_DATA,EmvTags.TRACK2_DATA);
  if (track2 != null) {
    card=new EmvCard();
    BitUtils bit=new BitUtils(track2);
    card.setCardNumber(bit.getNextHexaString(64));
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str",Locale.getDefault());
    try {
      String date=bit.getNextHexaString(5 * 4);
      if (date.length() > 5) {
        date=date.substring(0,5);
      }
      card.setExpireDate(DateUtils.truncate(sdf.parse(date),Calendar.MONTH));
    }
 catch (    ParseException e) {
      LOGGER.error("String_Node_Str");
    }
    byte[] cardHolderByte=TlvUtil.getValue(pData,EmvTags.CARDHOLDER_NAME);
    if (cardHolderByte != null) {
      card.setHolderName(new String(cardHolderByte).trim());
    }
  }
  return card;
}
Program: 20121
Project: 20121
Buggy source:
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    card=extractTrack2Data(pGpo);
    if (card == null) {
      data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
    }
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (ResponseUtils.isEquals(data,SwEnum.SW_6C)) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
  return card;
}

Fixed version (ground truth):
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    card=extractTrack2Data(pGpo);
    if (card == null) {
      data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
    }
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (ResponseUtils.isEquals(info,SwEnum.SW_6C)) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
  return card;
}
Program: 20122
Project: 20122
Buggy source:
/** 
 * Method used to extract Log Entry from Select response
 * @param pSelectResponse select response
 * @return byte array
 */
protected byte[] getLogEntry(final byte[] pSelectResponse){
  byte[] ret=TlvUtil.getValue(pSelectResponse,EmvTags.LOG_ENTRY);
  if (ret == null) {
    ret=TlvUtil.getValue(pSelectResponse,EmvTags.VISA_LOG_ENTRY);
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to extract Log Entry from Select response
 * @param pSelectResponse select response
 * @return byte array
 */
protected byte[] getLogEntry(final byte[] pSelectResponse){
  return TlvUtil.getValue(pSelectResponse,EmvTags.LOG_ENTRY,EmvTags.VISA_LOG_ENTRY);
}
Program: 20123
Project: 20123
Buggy source:
/** 
 * Method used to get Tag value
 * @param pData data
 * @param pTag tag to find
 * @return tag value or null
 */
public static byte[] getValue(final byte[] pData,final ITag pTag){
  byte[] ret=null;
  if (pData != null) {
    ByteArrayInputStream stream=new ByteArrayInputStream(pData);
    while (stream.available() > 0) {
      TLV tlv=TlvUtil.getNextTLV(stream);
      if (tlv.getTag() == pTag) {
        return tlv.getValueBytes();
      }
 else       if (tlv.getTag().isConstructed()) {
        ret=TlvUtil.getValue(tlv.getValueBytes(),pTag);
        if (ret != null) {
          break;
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to get Tag value
 * @param pData data
 * @param pTag tag to find
 * @return tag value or null
 */
public static byte[] getValue(final byte[] pData,final ITag... pTag){
  byte[] ret=null;
  if (pData != null) {
    ByteArrayInputStream stream=new ByteArrayInputStream(pData);
    while (stream.available() > 0) {
      TLV tlv=TlvUtil.getNextTLV(stream);
      if (ArrayUtils.contains(pTag,tlv.getTag())) {
        return tlv.getValueBytes();
      }
 else       if (tlv.getTag().isConstructed()) {
        ret=TlvUtil.getValue(tlv.getValueBytes(),pTag);
        if (ret != null) {
          break;
        }
      }
    }
  }
  return ret;
}
Program: 20124
Project: 20124
Buggy source:
@Test public void testGetLogEntry() throws Exception {
  byte[] selectResponse=BytesUtils.fromString("String_Node_Str");
  byte[] data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  Assertions.assertThat(BytesUtils.bytesToString(data)).isEqualTo("String_Node_Str");
  selectResponse=BytesUtils.fromString("String_Node_Str");
  data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  Assertions.assertThat(BytesUtils.bytesToString(data)).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testGetLogEntry() throws Exception {
  byte[] selectResponse=BytesUtils.fromString("String_Node_Str");
  System.out.println(TlvUtil.prettyPrintAPDUResponse(selectResponse));
  byte[] data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  selectResponse=BytesUtils.fromString("String_Node_Str");
  data=Whitebox.invokeMethod(new EmvParser(null,true),EmvParser.class,"String_Node_Str",selectResponse);
  Assertions.assertThat(BytesUtils.bytesToString(data)).isEqualTo("String_Node_Str");
}
Program: 20125
Project: 20125
Buggy source:
@Override public byte[] transceive(final byte[] pCommand){
  String response=null;
  LOGGER.debug("String_Node_Str" + BytesUtils.bytesToString(pCommand));
switch (step++) {
case 0:
    response="String_Node_Str";
  break;
case 1:
response="String_Node_Str";
break;
case 2:
response="String_Node_Str";
break;
case 3:
response="String_Node_Str";
break;
case 4:
response="String_Node_Str";
break;
case 5:
response="String_Node_Str";
break;
default :
response="String_Node_Str";
}
if (BytesUtils.bytesToStringNoSpace(pCommand).equals("String_Node_Str")) {
response="String_Node_Str";
}
LOGGER.debug("String_Node_Str" + response);
byte[] ret=BytesUtils.fromString(response);
try {
LOGGER.debug(TlvUtil.prettyPrintAPDUResponse(ret));
}
 catch (Exception e) {
}
return ret;
}

Fixed version (ground truth):
@Override public byte[] transceive(final byte[] pCommand){
  String response=null;
  LOGGER.debug("String_Node_Str" + BytesUtils.bytesToString(pCommand));
switch (step++) {
case 0:
    response="String_Node_Str";
  break;
case 1:
response="String_Node_Str";
break;
case 2:
response="String_Node_Str";
break;
case 3:
response="String_Node_Str";
break;
case 4:
response="String_Node_Str";
break;
default :
response="String_Node_Str";
}
if (BytesUtils.bytesToStringNoSpace(pCommand).equals("String_Node_Str")) {
response="String_Node_Str";
}
LOGGER.debug("String_Node_Str" + response);
byte[] ret=BytesUtils.fromString(response);
try {
LOGGER.debug(TlvUtil.prettyPrintAPDUResponse(ret));
}
 catch (Exception e) {
}
return ret;
}
Program: 20126
Project: 20126
Buggy source:
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (ResponseUtils.isEquals(data,SwEnum.SW_6C)) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
 else {
    card=extractTrack2Data(pGpo);
  }
  return card;
}

Fixed version (ground truth):
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    card=extractTrack2Data(pGpo);
    if (card == null) {
      data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
    }
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (ResponseUtils.isEquals(data,SwEnum.SW_6C)) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
  return card;
}
Program: 20127
Project: 20127
Buggy source:
/** 
 * Method used to get the number of pin try left
 * @return the number of pin try left
 * @throws CommunicationException
 */
protected int getLeftPinTry() throws CommunicationException {
  int ret=UNKNOW;
  if (LOGGER.isDebugEnabled()) {
    LOGGER.info("String_Node_Str");
  }
  byte[] data=provider.transceive(new CommandApdu(CommandEnum.GET_DATA,0x9F,0x17,0).toBytes());
  if (data != null) {
    byte[] val=TlvUtil.getValue(data,EmvTags.PIN_TRY_COUNTER);
    if (val != null) {
      ret=BytesUtils.byteArrayToInt(val);
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to get the number of pin try left
 * @return the number of pin try left
 * @throws CommunicationException
 */
protected int getLeftPinTry() throws CommunicationException {
  int ret=UNKNOW;
  if (LOGGER.isDebugEnabled()) {
    LOGGER.info("String_Node_Str");
  }
  byte[] data=provider.transceive(new CommandApdu(CommandEnum.GET_DATA,0x9F,0x17,0).toBytes());
  if (ResponseUtils.isSucceed(data)) {
    byte[] val=TlvUtil.getValue(data,EmvTags.PIN_TRY_COUNTER);
    if (val != null) {
      ret=BytesUtils.byteArrayToInt(val);
    }
  }
  return ret;
}
Program: 20128
Project: 20128
Buggy source:
/** 
 * Method used to parse FCI Proprietary Template
 * @param pData data to parse
 * @return
 * @throws CommunicationException
 */
protected byte[] parseFCIProprietaryTemplate(final byte[] pData) throws CommunicationException {
  byte[] data=TlvUtil.getValue(pData,EmvTags.SFI);
  if (data != null) {
    int sfi=BytesUtils.byteArrayToInt(data);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.info("String_Node_Str" + sfi);
    }
    data=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,sfi << 3 | 4,0).toBytes());
    if (data[data.length - 2] == (byte)0x6C) {
      data=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,sfi << 3 | 4,data[data.length - 1]).toBytes());
    }
    return data;
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.info("String_Node_Str");
  }
  return pData;
}

Fixed version (ground truth):
/** 
 * Method used to parse FCI Proprietary Template
 * @param pData data to parse
 * @return
 * @throws CommunicationException
 */
protected byte[] parseFCIProprietaryTemplate(final byte[] pData) throws CommunicationException {
  byte[] data=TlvUtil.getValue(pData,EmvTags.SFI);
  if (data != null) {
    int sfi=BytesUtils.byteArrayToInt(data);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.info("String_Node_Str" + sfi);
    }
    data=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,sfi << 3 | 4,0).toBytes());
    if (ResponseUtils.isEquals(data,SwEnum.SW_6C)) {
      data=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,sfi,sfi << 3 | 4,data[data.length - 1]).toBytes());
    }
    return data;
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.info("String_Node_Str");
  }
  return pData;
}
Program: 20129
Project: 20129
Buggy source:
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (info[info.length - 2] == (byte)0x6C) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
 else {
    card=extractTrack2Data(pGpo);
  }
  return card;
}

Fixed version (ground truth):
/** 
 * Method used to extract commons card data
 * @param pCard Card data
 * @param pGpo global processing options response
 */
protected EmvCard extractCommonsCardData(final byte[] pGpo) throws CommunicationException {
  EmvCard card=null;
  byte data[]=TlvUtil.getValue(pGpo,EmvTags.RESPONSE_MESSAGE_TEMPLATE_1);
  if (data != null) {
    data=ArrayUtils.subarray(data,2,data.length);
  }
 else {
    data=TlvUtil.getValue(pGpo,EmvTags.APPLICATION_FILE_LOCATOR);
  }
  if (data != null) {
    List<Afl> listAfl=extractAfl(data);
    for (    Afl afl : listAfl) {
      for (int index=afl.getFirstRecord(); index <= afl.getLastRecord(); index++) {
        byte[] info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,0).toBytes());
        if (ResponseUtils.isEquals(data,SwEnum.SW_6C)) {
          info=provider.transceive(new CommandApdu(CommandEnum.READ_RECORD,index,afl.getSfi() << 3 | 4,info[info.length - 1]).toBytes());
        }
        if (ResponseUtils.isSucceed(info)) {
          card=extractTrack2Data(info);
          if (card != null) {
            break;
          }
        }
      }
      if (card != null) {
        break;
      }
    }
  }
 else {
    card=extractTrack2Data(pGpo);
  }
  return card;
}
Program: 20130
Project: 20130
Buggy source:
/** 
 * Method used to check if the last command return SW1SW2 == 9000
 * @param pByte response to the last command
 * @return true if the status is 9000 false otherwise
 */
public static boolean isSucceed(final byte[] pByte){
  SwEnum val=SwEnum.getSW(pByte);
  if (LOGGER.isDebugEnabled() && pByte != null) {
    LOGGER.debug("String_Node_Str" + BytesUtils.bytesToStringNoSpace(Arrays.copyOfRange(pByte,pByte.length - 2,pByte.length)) + "String_Node_Str"+ (val != null ? val.getDetail() : "String_Node_Str"));
  }
  return val != null && val == SwEnum.SW_9000;
}

Fixed version (ground truth):
/** 
 * Method used to check if the last command return SW1SW2 == 9000
 * @param pByte response to the last command
 * @return true if the status is 9000 false otherwise
 */
public static boolean isSucceed(final byte[] pByte){
  return isEquals(pByte,SwEnum.SW_9000);
}
Program: 20131
Project: 20131
Buggy source:
@Test public void testgetLeftPinTry() throws Exception {
  ProviderSelectPaymentEnvTest prov=new ProviderSelectPaymentEnvTest();
  prov.setExpectedData("String_Node_Str");
  prov.setReturnedData("String_Node_Str");
  int val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(3);
  prov.setExpectedData("String_Node_Str");
  prov.setReturnedData("String_Node_Str");
  val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(EmvParser.UNKNOW);
  prov.setReturnedData(null);
  val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(EmvParser.UNKNOW);
}

Fixed version (ground truth):
@Test public void testgetLeftPinTry() throws Exception {
  ProviderSelectPaymentEnvTest prov=new ProviderSelectPaymentEnvTest();
  prov.setExpectedData("String_Node_Str");
  prov.setReturnedData("String_Node_Str");
  int val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(3);
  prov.setExpectedData("String_Node_Str");
  prov.setReturnedData("String_Node_Str");
  val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(EmvParser.UNKNOW);
  prov.setReturnedData(null);
  val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(EmvParser.UNKNOW);
  prov.setReturnedData("String_Node_Str");
  val=Whitebox.invokeMethod(new EmvParser(prov,true),EmvParser.class,"String_Node_Str");
  Assertions.assertThat(val).isEqualTo(EmvParser.UNKNOW);
}
Program: 20132
Project: 20132
Buggy source:
@Test public void test() throws Exception {
  Assertions.assertThat(SwEnum.SW_61.getDetail()).isEqualTo("String_Node_Str");
  Assertions.assertThat(SwEnum.SW_61.getStatus()).isEqualTo(new byte[]{0x61});
}

Fixed version (ground truth):
@Test public void test() throws Exception {
  Assertions.assertThat(SwEnum.SW_61.getDetail()).isEqualTo("String_Node_Str");
  Assertions.assertThat(SwEnum.SW_61.getStatus()).isEqualTo(new byte[]{0x61});
  Assertions.assertThat(SwEnum.getSW(new byte[]{0x6C,67})).isEqualTo(SwEnum.SW_6C);
  Assertions.assertThat(SwEnum.getSW(new byte[]{0x6C,12})).isEqualTo(SwEnum.SW_6C);
  Assertions.assertThat(SwEnum.getSW(new byte[]{0x6C,00})).isEqualTo(SwEnum.SW_6C00);
}
Program: 20133
Project: 20133
Buggy source:
/** 
 * Method used to get the field atrDescription
 * @return the atrDescription
 */
public List<String> getAtrDescription(){
  return atrDescription;
}

Fixed version (ground truth):
/** 
 * Method used to get the field atrDescription
 * @return the atrDescription
 */
public Collection<String> getAtrDescription(){
  return atrDescription;
}
Program: 20134
Project: 20134
Buggy source:
/** 
 * Setter for the field atrDescription
 * @param atrDescription the atrDescription to set
 */
public void setAtrDescription(final List<String> atrDescription){
  this.atrDescription=atrDescription;
}

Fixed version (ground truth):
/** 
 * Setter for the field atrDescription
 * @param atrDescription the atrDescription to set
 */
public void setAtrDescription(final Collection<String> atrDescription){
  this.atrDescription=atrDescription;
}
Program: 20135
Project: 20135
Buggy source:
/** 
 * Method used to parse EMV card
 */
public EMVCard parse(final byte[] pSelectResponse,final IProvider pProvider) throws CommunicationException {
  EMVCard card=null;
  byte[] logEntry=TLVUtil.getValue(pSelectResponse,EMVTags.LOG_ENTRY);
  byte[] pdol=TLVUtil.getValue(pSelectResponse,EMVTags.PDOL);
  byte[] gpo=getGetProcessingOptions(pdol,pProvider);
  if (!ResponseUtils.isSucceed(gpo)) {
    gpo=getGetProcessingOptions(null,pProvider);
  }
  card=extractCommonsCardData(gpo);
  card.setListPayment(extractLogEntry(logEntry));
  return card;
}

Fixed version (ground truth):
/** 
 * Method used to parse EMV card
 */
public EMVCard parse(final byte[] pSelectResponse,final IProvider pProvider) throws CommunicationException {
  EMVCard card=null;
  byte[] logEntry=TLVUtil.getValue(pSelectResponse,EMVTags.LOG_ENTRY);
  byte[] pdol=TLVUtil.getValue(pSelectResponse,EMVTags.PDOL);
  byte[] gpo=getGetProcessingOptions(pdol,pProvider);
  if (!ResponseUtils.isSucceed(gpo)) {
    gpo=getGetProcessingOptions(null,pProvider);
  }
  card=extractCommonsCardData(gpo);
  if (card != null) {
    card.setListPayment(extractLogEntry(logEntry));
  }
  return card;
}
Program: 20136
Project: 20136
Buggy source:
public static byte[] constructValue(final TagAndLength pTagAndLength){
  byte ret[]=new byte[pTagAndLength.getLength()];
  byte val[]=null;
  if (pTagAndLength.getTag() == EMVTags.TERMINAL_TRANSACTION_QUALIFIERS) {
    TerminalTransactionQualifiers terminalQual=new TerminalTransactionQualifiers();
    terminalQual.setContactlessEMVmodeSupported(true);
    ret=terminalQual.getBytes();
  }
 else   if (pTagAndLength.getTag() == EMVTags.TERMINAL_COUNTRY_CODE) {
    val=BytesUtils.toByteArray(CountryCodeEnum.FR.getNumeric());
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_CURRENCY_CODE) {
    val=BytesUtils.toByteArray(CurrencyEnum.EUR.getISOCodeNumeric());
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_DATE) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    val=BytesUtils.fromString(sdf.format(new Date()));
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_TYPE) {
    val=BytesUtils.fromString("String_Node_Str");
  }
 else   if (pTagAndLength.getTag() == EMVTags.AMOUNT_AUTHORISED_NUMERIC) {
    val=BytesUtils.fromString("String_Node_Str");
  }
  if (val != null) {
    System.arraycopy(val,Math.max(0,val.length - ret.length),ret,Math.max(ret.length - val.length,0),Math.min(val.length,ret.length));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Method used to construct value from tag and length
 * @param pTagAndLength tag and length value
 * @return tag value in byte
 */
public static byte[] constructValue(final TagAndLength pTagAndLength){
  byte ret[]=new byte[pTagAndLength.getLength()];
  byte val[]=null;
  if (pTagAndLength.getTag() == EMVTags.TERMINAL_TRANSACTION_QUALIFIERS) {
    TerminalTransactionQualifiers terminalQual=new TerminalTransactionQualifiers();
    terminalQual.setContactlessEMVmodeSupported(true);
    ret=terminalQual.getBytes();
  }
 else   if (pTagAndLength.getTag() == EMVTags.TERMINAL_COUNTRY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CountryCodeEnum.FR.getNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_CURRENCY_CODE) {
    val=BytesUtils.fromString(StringUtils.leftPad(String.valueOf(CurrencyEnum.EUR.getISOCodeNumeric()),4,"String_Node_Str"));
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_DATE) {
    SimpleDateFormat sdf=new SimpleDateFormat("String_Node_Str");
    val=BytesUtils.fromString(sdf.format(new Date()));
  }
 else   if (pTagAndLength.getTag() == EMVTags.TRANSACTION_TYPE) {
    val=BytesUtils.fromString("String_Node_Str");
  }
 else   if (pTagAndLength.getTag() == EMVTags.AMOUNT_AUTHORISED_NUMERIC) {
    val=BytesUtils.fromString("String_Node_Str");
  }
  if (val != null) {
    System.arraycopy(val,Math.max(0,val.length - ret.length),ret,Math.max(ret.length - val.length,0),Math.min(val.length,ret.length));
  }
  return ret;
}