nus-yam/ex-repair huggingface dataset:
Program: 48109
Project: 48109
Buggy source:
public void setLogo(String logo){
  this.logoFile=logo;
  logger.debug("String_Node_Str" + logoFile);
  if (logoFile != null && !logoFile.isEmpty()) {
    try {
      InputStream logoStream=FileUtils.resolveResourceAsStream(AddonSpecification.class,logoFile);
      this.logoBytes=FileUtils.toByteArray(logoStream);
    }
 catch (    FileNotFoundException e) {
      logger.error("String_Node_Str",e);
    }
catch (    IOException e) {
      logger.error("String_Node_Str",e);
    }
catch (    NullPointerException e) {
      logger.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
public void setLogo(String logo){
  this.logo=logo;
  logger.debug("String_Node_Str" + logo);
}
Program: 48110
Project: 48110
Buggy source:
@XmlElement(name="String_Node_Str") public String getLogo(){
  return logoFile;
}

Fixed version (ground truth):
public String getLogo(){
  return logo;
}
Program: 48111
Project: 48111
Buggy source:
@XmlElement(name="String_Node_Str") public Configuration getConfigDescription(){
  return configDescription;
}

Fixed version (ground truth):
public Configuration getConfigDescription(){
  return configDescription;
}
Program: 48112
Project: 48112
Buggy source:
public AppPluginSpecification searchByResourceName(String resourceName){
  for (  AppPluginSpecification desc : appPluginActions) {
    if (resourceName.equals(desc.getResourceName())) {
      return desc;
    }
  }
  return null;
}

Fixed version (ground truth):
public AppPluginSpecification searchByResourceName(String resourceName){
  for (  AppPluginSpecification desc : bindingActions) {
    if (resourceName.equals(desc.getResourceName())) {
      return desc;
    }
  }
  return null;
}
Program: 48113
Project: 48113
Buggy source:
@XmlElement(name="String_Node_Str") public String getId(){
  return id;
}

Fixed version (ground truth):
public String getId(){
  return id;
}
Program: 48114
Project: 48114
Buggy source:
@XmlElementWrapper(name="String_Node_Str") @XmlElement(name="String_Node_Str") public ArrayList<AppExtensionSpecification> getApplicationActions(){
  return appExtensionActions;
}

Fixed version (ground truth):
public ArrayList<AppExtensionSpecification> getApplicationActions(){
  return applicationActions;
}
Program: 48115
Project: 48115
Buggy source:
@XmlElementWrapper(name="String_Node_Str") @XmlElement(name="String_Node_Str") public ArrayList<AppPluginSpecification> getBindingActions(){
  return appPluginActions;
}

Fixed version (ground truth):
public ArrayList<AppPluginSpecification> getBindingActions(){
  return bindingActions;
}
Program: 48116
Project: 48116
Buggy source:
public void setConfigDescription(Configuration configDescription){
  this.configDescription=configDescription;
}

Fixed version (ground truth):
public void setConfigDescription(Configuration configDescriptionNew){
  this.configDescription=configDescription;
}
Program: 48117
Project: 48117
Buggy source:
public AppExtensionSpecification searchByActionId(String id){
  for (  AppExtensionSpecification desc : appExtensionActions) {
    if (desc.getId().equals(id)) {
      return desc;
    }
  }
  return null;
}

Fixed version (ground truth):
public AppExtensionSpecification searchByActionId(String id){
  for (  AppExtensionSpecification desc : applicationActions) {
    if (desc.getId().equals(id)) {
      return desc;
    }
  }
  return null;
}
Program: 48118
Project: 48118
Buggy source:
@XmlElementWrapper(name="String_Node_Str") @XmlElement(name="String_Node_Str") public ArrayList<ProtocolPluginSpecification> getSalActions(){
  return salActions;
}

Fixed version (ground truth):
public ArrayList<ProtocolPluginSpecification> getSalActions(){
  return salActions;
}
Program: 48119
Project: 48119
Buggy source:
@XmlElement(name="String_Node_Str") public String getLicense(){
  return license;
}

Fixed version (ground truth):
public String getLicense(){
  return license;
}
Program: 48120
Project: 48120
Buggy source:
@XmlElementWrapper(name="String_Node_Str") @XmlElement(name="String_Node_Str") public ArrayList<ProtocolPluginSpecification> getIfdActions(){
  return ifdActions;
}

Fixed version (ground truth):
public ArrayList<ProtocolPluginSpecification> getIfdActions(){
  return ifdActions;
}
Program: 48121
Project: 48121
Buggy source:
public byte[] getLogoBytes(){
  return logoBytes;
}

Fixed version (ground truth):
/** 
 * Get a byte array containing the logo. <br /> Note: This method creates always a new input stream and does not store the byte array internally.
 * @return A byte array containing the logo bytes or null if no logo is present or an error occurred.
 */
public byte[] getLogoBytes(){
  if (logo != null && !logo.isEmpty()) {
    try {
      InputStream logoStream=FileUtils.resolveResourceAsStream(AddonSpecification.class,logo);
      return FileUtils.toByteArray(logoStream);
    }
 catch (    FileNotFoundException e) {
      logger.error("String_Node_Str",e);
      return null;
    }
catch (    IOException|NullPointerException e) {
      logger.error("String_Node_Str",e);
      return null;
    }
  }
  return null;
}
Program: 48122
Project: 48122
Buggy source:
@XmlElement(name="String_Node_Str") public Configuration getConfigDescription(){
  return configDescription;
}

Fixed version (ground truth):
public Configuration getConfigDescription(){
  return configDescription;
}
Program: 48123
Project: 48123
Buggy source:
@XmlElement(name="String_Node_Str",required=false,defaultValue="String_Node_Str") public Boolean isLoadOnStartup(){
  if (loadOnStartup == null) {
    return false;
  }
  return loadOnStartup;
}

Fixed version (ground truth):
public Boolean isLoadOnStartup(){
  if (loadOnStartup == null) {
    return false;
  }
  return loadOnStartup;
}
Program: 48124
Project: 48124
Buggy source:
@XmlElement(name="String_Node_Str") public String getId(){
  return id;
}

Fixed version (ground truth):
public String getId(){
  return id;
}
Program: 48125
Project: 48125
Buggy source:
@XmlElement(name="String_Node_Str") public String getClassName(){
  return className;
}

Fixed version (ground truth):
public String getClassName(){
  return className;
}
Program: 48126
Project: 48126
Buggy source:
@XmlElement(name="String_Node_Str") public List<LocalizedString> getLocalizedName(){
  return localizedName;
}

Fixed version (ground truth):
public List<LocalizedString> getLocalizedName(){
  return localizedName;
}
Program: 48127
Project: 48127
Buggy source:
@XmlElement(name="String_Node_Str") public Configuration getConfigDescription(){
  return configDescription;
}

Fixed version (ground truth):
public Configuration getConfigDescription(){
  return configDescription;
}
Program: 48128
Project: 48128
Buggy source:
@XmlElement(name="String_Node_Str",required=false,defaultValue="String_Node_Str") public Boolean isLoadOnStartup(){
  if (loadOnStartup == null) {
    return false;
  }
  return loadOnStartup;
}

Fixed version (ground truth):
public Boolean isLoadOnStartup(){
  if (loadOnStartup == null) {
    return false;
  }
  return loadOnStartup;
}
Program: 48129
Project: 48129
Buggy source:
@XmlElement(name="String_Node_Str") public String getResourceName(){
  return resourceName;
}

Fixed version (ground truth):
public String getResourceName(){
  return resourceName;
}
Program: 48130
Project: 48130
Buggy source:
@XmlElement(name="String_Node_Str") public String getClassName(){
  return className;
}

Fixed version (ground truth):
public String getClassName(){
  return className;
}
Program: 48131
Project: 48131
Buggy source:
@XmlElement(name="String_Node_Str") public List<LocalizedString> getLocalizedDescription(){
  return localizedDescription;
}

Fixed version (ground truth):
public List<LocalizedString> getLocalizedDescription(){
  return localizedDescription;
}
Program: 48132
Project: 48132
Buggy source:
/** 
 * Check if the two given URLs comply the Same-Origin-Policy.
 * @param url1 the first URL
 * @param url2 the second URL
 * @return {@code true} if the Same-Origin-Policy has been complied with, {@code false} otherwise
 */
public static boolean checkSameOriginPolicy(URL url1,URL url2){
  logger.debug("String_Node_Str",url1,url2);
  String endpointProtocol=url1.getProtocol();
  String subjectProtocol=url2.getProtocol();
  if (!endpointProtocol.equals(subjectProtocol)) {
    logger.error("String_Node_Str");
    return false;
  }
  String endpointHost=url1.getHost();
  String subjectHost=url2.getHost();
  if (!endpointHost.equals(subjectHost)) {
    logger.error("String_Node_Str");
    return false;
  }
  int endpointPort=url1.getPort();
  if (endpointPort == -1) {
    endpointPort=url1.getDefaultPort();
  }
  int subjectPort=url2.getPort();
  if (subjectPort == -1) {
    subjectPort=url2.getDefaultPort();
  }
  if (!(endpointPort == subjectPort)) {
    logger.error("String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check if the two given URLs comply the Same-Origin-Policy.
 * @param url1 the first URL
 * @param url2 the second URL
 * @return {@code true} if the Same-Origin-Policy has been complied with, {@code false} otherwise
 */
public static boolean checkSameOriginPolicy(URL url1,URL url2){
  logger.debug("String_Node_Str",url1,url2);
  String endpointProtocol=url1.getProtocol();
  String subjectProtocol=url2.getProtocol();
  if (!endpointProtocol.equalsIgnoreCase(subjectProtocol)) {
    logger.error("String_Node_Str");
    return false;
  }
  String endpointHost=url1.getHost();
  String subjectHost=url2.getHost();
  if (!endpointHost.equalsIgnoreCase(subjectHost)) {
    logger.error("String_Node_Str");
    return false;
  }
  int endpointPort=url1.getPort();
  if (endpointPort == -1) {
    endpointPort=url1.getDefaultPort();
  }
  int subjectPort=url2.getPort();
  if (subjectPort == -1) {
    subjectPort=url2.getDefaultPort();
  }
  if (!(endpointPort == subjectPort)) {
    logger.error("String_Node_Str");
    return false;
  }
  return true;
}
Program: 48134
Project: 48134
Buggy source:
/** 
 * Returns a list of ConnectionHandles.
 * @return List of ConnectionHandles
 */
public List<ConnectionHandleType> getConnectionHandles(){
  ConnectionHandleType handle=new ConnectionHandleType();
  Set<CardStateEntry> entries=states.getMatchingEntries(handle);
  ArrayList<ConnectionHandleType> result=new ArrayList<ConnectionHandleType>(entries.size());
  for (  CardStateEntry entry : entries) {
    result.add(entry.handleCopy());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns a list of ConnectionHandles.
 * @return List of ConnectionHandles
 */
public List<ConnectionHandleType> getConnectionHandles(){
  ConnectionHandleType handle=new ConnectionHandleType();
  Set<CardStateEntry> entries=states.getMatchingEntries(handle);
  ArrayList<ConnectionHandleType> result=new ArrayList<>(entries.size());
  for (  CardStateEntry entry : entries) {
    result.add(entry.handleCopy());
  }
  return result;
}
Program: 48138
Project: 48138
Buggy source:
private I18n(String component){
  Locale userLocale=Locale.getDefault();
  String lang=userLocale.getLanguage();
  String country=userLocale.getCountry();
  Properties defaults=loadFile(component,"String_Node_Str");
  if (!lang.isEmpty()) {
    Properties target=loadFile(component,lang);
    defaults=mergeProperties(defaults,target);
  }
  if (!lang.isEmpty() && !country.isEmpty()) {
    Properties target=loadFile(component,lang + "String_Node_Str" + country);
    defaults=mergeProperties(defaults,target);
  }
  this.component=component;
  this.translation=defaults;
  this.translatedFiles=new TreeMap<String,URL>();
}

Fixed version (ground truth):
private I18n(String component){
  Locale userLocale=getLocale();
  String lang=userLocale.getLanguage();
  String country=userLocale.getCountry();
  Properties defaults=loadFile(component,"String_Node_Str");
  if (!lang.isEmpty()) {
    Properties target=loadFile(component,lang);
    defaults=mergeProperties(defaults,target);
  }
  if (!lang.isEmpty() && !country.isEmpty()) {
    Properties target=loadFile(component,lang + "String_Node_Str" + country);
    defaults=mergeProperties(defaults,target);
  }
  this.component=component;
  this.translation=defaults;
  this.translatedFiles=new TreeMap<String,URL>();
}
Program: 48139
Project: 48139
Buggy source:
private void prepareStructure(PasswordAttributesType attributes,byte[] cmdTemplate) throws IFDException {
  byte[] pinTemplate;
  try {
    pinTemplate=PINUtils.createPinMask(attributes);
  }
 catch (  UtilException e) {
    IFDException ex=new IFDException(e);
    throw ex;
  }
  byte[] template=cmdTemplate;
  if (pinTemplate.length > 0) {
    template=ByteUtils.concatenate(cmdTemplate,(byte)pinTemplate.length);
    template=ByteUtils.concatenate(template,pinTemplate);
  }
  setData(template);
  boolean nibbleHandling=pwdType == PasswordTypeType.BCD || pwdType == PasswordTypeType.ISO_9564_1;
  boolean isoPin=pwdType == PasswordTypeType.ISO_9564_1;
  int pinLenIdx=template.length;
  int pinPos=isoPin ? pinLenIdx + 1 : pinLenIdx;
  byte bmSysUnits=1;
  byte bmPinPos=(byte)(isoPin ? 1 : 0);
  byte bmJustify=0;
  byte bmPinType=0;
  if (nibbleHandling) {
    bmPinType=1;
  }
 else   if (pwdType == PasswordTypeType.ASCII_NUMERIC) {
    bmPinType=2;
  }
  this.bmFormatString=(byte)((bmSysUnits << 7) | (bmPinPos << 3) | (bmJustify << 2)| bmPinType);
  byte bmPinManagement=(byte)(isoPin ? 4 : 0);
  byte pinSize=(byte)(isoPin ? storedLen - 1 : storedLen);
  this.bmPINBlockString=(byte)((bmPinManagement << 4) | pinSize);
  byte bmPinLengthUnit=0;
  byte bmPinBytePos=(byte)(isoPin ? 4 : 0);
  bmPINLengthFormat=(byte)((bmPinLengthUnit << 4) | bmPinBytePos);
  setMinPINSize((byte)minLen);
  setMaxPINSize((byte)maxLen);
}

Fixed version (ground truth):
private void prepareStructure(PasswordAttributesType attributes,byte[] cmdTemplate) throws IFDException {
  byte[] pinTemplate;
  try {
    pinTemplate=PINUtils.createPinMask(attributes);
  }
 catch (  UtilException e) {
    IFDException ex=new IFDException(e);
    throw ex;
  }
  byte[] template=cmdTemplate;
  if (pinTemplate.length > 0) {
    template=ByteUtils.concatenate(cmdTemplate,(byte)pinTemplate.length);
    template=ByteUtils.concatenate(template,pinTemplate);
  }
  setData(template);
  boolean nibbleHandling=pwdType == PasswordTypeType.BCD || pwdType == PasswordTypeType.ISO_9564_1;
  boolean isoPin=pwdType == PasswordTypeType.ISO_9564_1;
  int pinLenIdx=template.length;
  int pinPos=isoPin ? pinLenIdx + 1 : pinLenIdx;
  byte bmSysUnits=1;
  byte bmPinPos=(byte)(isoPin ? 1 : 0);
  byte bmJustify=0;
  byte bmPinType=0;
  if (nibbleHandling) {
    bmPinType=1;
  }
 else   if (pwdType == PasswordTypeType.ASCII_NUMERIC || pwdType == PasswordTypeType.UTF_8) {
    bmPinType=2;
  }
  this.bmFormatString=(byte)((bmSysUnits << 7) | (bmPinPos << 3) | (bmJustify << 2)| bmPinType);
  byte bmPinManagement=(byte)(isoPin ? 4 : 0);
  byte pinSize=(byte)(isoPin ? storedLen - 1 : storedLen);
  this.bmPINBlockString=(byte)((bmPinManagement << 4) | pinSize);
  byte bmPinLengthUnit=0;
  byte bmPinBytePos=(byte)(isoPin ? 4 : 0);
  bmPINLengthFormat=(byte)((bmPinLengthUnit << 4) | bmPinBytePos);
  setMinPINSize((byte)minLen);
  setMaxPINSize((byte)maxLen);
}
Program: 48140
Project: 48140
Buggy source:
public byte[] toBytes(){
  ByteArrayOutputStream o=new ByteArrayOutputStream(42);
  o.write(bTimeOut);
  o.write(bTimeOut2);
  o.write(bmFormatString);
  o.write(bmPINBlockString);
  o.write(bmPINLengthFormat);
  o.write(getMaxPINSize());
  o.write(getMinPINSize());
  o.write(bEntryValidationCondition);
  o.write(bNumberMessage);
  byte lang_low=(byte)(wLangId & 0xFF);
  byte lang_high=(byte)((wLangId >> 8) & 0xFF);
  o.write(lang_high);
  o.write(lang_low);
  o.write(bMsgIndex);
  o.write(bTeoPrologue,0,bTeoPrologue.length);
  byte[] ulDataLength_bytes=IntegerUtils.toByteArray(ulDataLength);
  for (int i=ulDataLength_bytes.length - 1; i >= 0; i--) {
    o.write(ulDataLength_bytes[i]);
  }
  for (int i=ulDataLength_bytes.length; i < 4; i++) {
    o.write(0);
  }
  if (ulDataLength > 0) {
    o.write(abData,0,abData.length);
  }
  byte[] result=o.toByteArray();
  return result;
}

Fixed version (ground truth):
public byte[] toBytes(){
  ByteArrayOutputStream o=new ByteArrayOutputStream(42);
  o.write(bTimeOut);
  o.write(bTimeOut2);
  o.write(bmFormatString);
  o.write(bmPINBlockString);
  o.write(bmPINLengthFormat);
  o.write(getMaxPINSize());
  o.write(getMinPINSize());
  o.write(bEntryValidationCondition);
  o.write(bNumberMessage);
  byte lang_low=(byte)((wLangId >> 8) & 0xFF);
  byte lang_high=(byte)(wLangId & 0xFF);
  o.write(lang_high);
  o.write(lang_low);
  o.write(bMsgIndex);
  o.write(bTeoPrologue,0,bTeoPrologue.length);
  byte[] ulDataLength_bytes=IntegerUtils.toByteArray(ulDataLength);
  for (int i=ulDataLength_bytes.length - 1; i >= 0; i--) {
    o.write(ulDataLength_bytes[i]);
  }
  for (int i=ulDataLength_bytes.length; i < 4; i++) {
    o.write(0);
  }
  if (ulDataLength > 0) {
    o.write(abData,0,abData.length);
  }
  byte[] result=o.toByteArray();
  return result;
}
Program: 48147
Project: 48147
Buggy source:
/** 
 * A new card application is created on an eCard with the CardApplicationCreate function. See BSI-TR-03112-4, version 1.1.2, section 3.3.2.
 * @param request CardApplicationCreate
 * @return CardApplicationCreateResponse
 */
@Override public CardApplicationCreateResponse cardApplicationCreate(CardApplicationCreate request){
  CardApplicationCreateResponse response=WSHelper.makeResponse(CardApplicationCreateResponse.class,WSHelper.makeResultOK());
  try {
    ConnectionHandleType connectionHandle=SALUtils.getConnectionHandle(request);
    CardStateEntry cardStateEntry=states.getEntry(connectionHandle,false);
    SALUtils.getCardStateEntry(states,connectionHandle);
    byte[] cardApplicationName=request.getCardApplicationName();
    Assert.assertIncorrectParameter(cardApplicationName,"String_Node_Str");
    AccessControlListType cardApplicationACL=request.getCardApplicationACL();
    Assert.assertIncorrectParameter(cardApplicationACL,"String_Node_Str");
    CardApplicationType cardApplicationType=new CardApplicationType();
    cardApplicationType.setApplicationIdentifier(cardApplicationName);
    cardApplicationType.setCardApplicationACL(cardApplicationACL);
    CardInfoWrapper cardInfoWrapper=cardStateEntry.getInfo();
    cardInfoWrapper.getApplicationCapabilities().getCardApplication().add(cardApplicationType);
  }
 catch (  ECardException e) {
    response.setResult(e.getResult());
  }
catch (  Exception e) {
    logger.error(e.getMessage(),e);
    response.setResult(WSHelper.makeResult(e));
  }
  return response;
}

Fixed version (ground truth):
/** 
 * A new card application is created on an eCard with the CardApplicationCreate function. See BSI-TR-03112-4, version 1.1.2, section 3.3.2.
 * @param request CardApplicationCreate
 * @return CardApplicationCreateResponse
 */
@Override public CardApplicationCreateResponse cardApplicationCreate(CardApplicationCreate request){
  CardApplicationCreateResponse response=WSHelper.makeResponse(CardApplicationCreateResponse.class,WSHelper.makeResultOK());
  try {
    ConnectionHandleType connectionHandle=SALUtils.getConnectionHandle(request);
    CardStateEntry cardStateEntry=states.getEntry(connectionHandle,false);
    byte[] cardApplicationName=request.getCardApplicationName();
    Assert.assertIncorrectParameter(cardApplicationName,"String_Node_Str");
    AccessControlListType cardApplicationACL=request.getCardApplicationACL();
    Assert.assertIncorrectParameter(cardApplicationACL,"String_Node_Str");
    CardApplicationType cardApplicationType=new CardApplicationType();
    cardApplicationType.setApplicationIdentifier(cardApplicationName);
    cardApplicationType.setCardApplicationACL(cardApplicationACL);
    CardInfoWrapper cardInfoWrapper=cardStateEntry.getInfo();
    cardInfoWrapper.getApplicationCapabilities().getCardApplication().add(cardApplicationType);
  }
 catch (  ECardException e) {
    response.setResult(e.getResult());
  }
catch (  Exception e) {
    logger.error(e.getMessage(),e);
    response.setResult(WSHelper.makeResult(e));
  }
  return response;
}
Program: 48148
Project: 48148
Buggy source:
/** 
 * Gets the thread local instance of the context. If no instance exists yet, a new one is created possibly based on the one from the parent thread.
 * @return The DynamicContext instance of this thread.
 */
@Nonnull public static DynamicContext getInstance(@Nonnull String key){
  final Map<String,DynamicContext> local=localMap.get();
synchronized (local) {
    DynamicContext inst;
    if (local.containsKey(key)) {
      inst=local.get(key);
    }
 else {
      inst=new DynamicContext();
      local.put(key,inst);
    }
    return inst;
  }
}

Fixed version (ground truth):
/** 
 * Gets the thread local instance of the context. If no instance exists yet, a new one is created possibly based on the one from the parent thread.
 * @param key Lookup key for the desired variable.
 * @return The DynamicContext instance of this thread.
 */
@Nonnull public static DynamicContext getInstance(@Nonnull String key){
  final Map<String,DynamicContext> local=localMap.get();
synchronized (local) {
    DynamicContext inst;
    if (local.containsKey(key)) {
      inst=local.get(key);
    }
 else {
      inst=new DynamicContext();
      local.put(key,inst);
    }
    return inst;
  }
}
Program: 48150
Project: 48150
Buggy source:
/** 
 * Verifies the PathSecurity-Parameter element of the TCToken.
 * @throws Exception
 */
public void verifyPathSecurityParameters() throws TCTokenException {
  try {
    if (token.getPathSecurityProtocol().equals("String_Node_Str") || token.getPathSecurityProtocol().equals("String_Node_Str")) {
      TCTokenType.PathSecurityParameters psp=token.getPathSecurityParameters();
      if (!checkEmpty(psp)) {
        assertRequired(psp.getPSK());
        checkPSKLength(ByteUtils.toHexString(psp.getPSK()));
      }
    }
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the PathSecurity-Parameter element of the TCToken.
 * @throws TCTokenException
 */
public void verifyPathSecurityParameters() throws TCTokenException {
  try {
    if (token.getPathSecurityProtocol().equals("String_Node_Str") || token.getPathSecurityProtocol().equals("String_Node_Str")) {
      TCTokenType.PathSecurityParameters psp=token.getPathSecurityParameters();
      if (!checkEmpty(psp)) {
        assertRequired(psp.getPSK());
        checkPSKLength(ByteUtils.toHexString(psp.getPSK()));
      }
    }
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48151
Project: 48151
Buggy source:
/** 
 * Verifies the Binding element of the TCToken.
 * @throws Exception
 */
public void verifyBinding() throws TCTokenException {
  try {
    String value=token.getBinding();
    assertRequired(value);
    checkEqual(value,"String_Node_Str");
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the Binding element of the TCToken.
 * @throws TCTokenException
 */
public void verifyBinding() throws TCTokenException {
  try {
    String value=token.getBinding();
    assertRequired(value);
    checkEqualOR(value,"String_Node_Str","String_Node_Str");
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48152
Project: 48152
Buggy source:
/** 
 * Verifies the SessionIdentifier element of the TCToken.
 * @throws Exception
 */
public void verifySessionIdentifier() throws TCTokenException {
  try {
    String value=token.getSessionIdentifier();
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the SessionIdentifier element of the TCToken.
 * @throws TCTokenException
 */
public void verifySessionIdentifier() throws TCTokenException {
  try {
    String value=token.getSessionIdentifier();
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48153
Project: 48153
Buggy source:
/** 
 * Verifies the ServerAddress element of the TCToken.
 * @throws Exception
 */
public void verifyServerAddress() throws TCTokenException {
  try {
    String value=token.getServerAddress();
    assertURL(value);
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the ServerAddress element of the TCToken.
 * @throws TCTokenException
 */
public void verifyServerAddress() throws TCTokenException {
  try {
    String value=token.getServerAddress();
    assertURL(value);
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48154
Project: 48154
Buggy source:
/** 
 * Verifies the PathSecurity-Protocol element of the TCToken.
 * @throws Exception
 */
public void verifyPathSecurityProtocol() throws TCTokenException {
  try {
    String value=token.getPathSecurityProtocol();
    if (!checkEmpty(value)) {
      checkEqualOR(value,"String_Node_Str","String_Node_Str","String_Node_Str");
    }
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the PathSecurity-Protocol element of the TCToken.
 * @throws TCTokenException
 */
public void verifyPathSecurityProtocol() throws TCTokenException {
  try {
    String value=token.getPathSecurityProtocol();
    if (!checkEmpty(value)) {
      checkEqualOR(value,"String_Node_Str","String_Node_Str","String_Node_Str");
    }
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48155
Project: 48155
Buggy source:
/** 
 * Verifies the RefreshAddress element of the TCToken.
 * @throws Exception
 */
public void verifyRefreshAddress() throws TCTokenException {
  try {
    String value=token.getRefreshAddress();
    assertURL(value);
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Verifies the RefreshAddress element of the TCToken.
 * @throws TCTokenException
 */
public void verifyRefreshAddress() throws TCTokenException {
  try {
    String value=token.getRefreshAddress();
    assertURL(value);
    assertRequired(value);
  }
 catch (  TCTokenException e) {
    throw new TCTokenException("String_Node_Str");
  }
}
Program: 48156
Project: 48156
Buggy source:
@Override public void init(Context aCtx) throws ActionInitializationException {
  this.dispatcher=aCtx.getDispatcher();
  this.gui=aCtx.getUserConsent();
  this.recognition=aCtx.getRecognition();
}

Fixed version (ground truth):
@Override public void init(Context ctx) throws ActionInitializationException {
  this.dispatcher=ctx.getDispatcher();
  this.gui=ctx.getUserConsent();
  this.recognition=ctx.getRecognition();
  this.cardStates=ctx.getCardStates();
}
Program: 48157
Project: 48157
Buggy source:
@Override public void init(Context aCtx) throws ActionInitializationException {
  this.dispatcher=aCtx.getDispatcher();
  this.gui=aCtx.getUserConsent();
  this.recognition=aCtx.getRecognition();
}

Fixed version (ground truth):
@Override public void init(Context aCtx) throws ActionInitializationException {
  this.dispatcher=aCtx.getDispatcher();
  this.gui=aCtx.getUserConsent();
  this.recognition=aCtx.getRecognition();
  this.cardStates=aCtx.getCardStates();
}
Program: 48158
Project: 48158
Buggy source:
@Override protected void saveProperties() throws IOException, SecurityException {
  String path=FileUtils.getHomeConfigDir().getAbsolutePath() + File.separatorChar + "String_Node_Str"+ File.separatorChar+ desc.getId()+ "String_Node_Str";
  File config=new File(path);
  FileWriter writer=new FileWriter(config);
  properties.store(writer,null);
}

Fixed version (ground truth):
@Override protected void saveProperties() throws IOException, SecurityException {
  File home=FileUtils.getHomeConfigDir();
  File path=new File(home,"String_Node_Str");
  path=new File(path,desc.getId());
  File config=new File(path,"String_Node_Str" + "String_Node_Str");
  FileWriter writer=new FileWriter(config);
  properties.store(writer,null);
}
Program: 48159
Project: 48159
Buggy source:
DefaultSettingsGroup(String title,Properties properties,AddonSpecification desc){
  super(title,properties);
  this.desc=desc;
  for (  ConfigurationEntry entry : desc.getConfigDescription().getEntries()) {
    String name=entry.getLocalizedName(LANGUAGE_CODE);
    String description=entry.getLocalizedDescription(LANGUAGE_CODE);
    if (entry instanceof ScalarEntry) {
      ScalarEntry scalarEntry=(ScalarEntry)entry;
      if (scalarEntry.getType().equalsIgnoreCase("String_Node_Str")) {
        addInputItem(name,description,entry.getKey());
      }
 else       if (scalarEntry.getType().equalsIgnoreCase("String_Node_Str")) {
        addBoolItem(name,description,entry.getKey());
      }
 else {
        logger.error("String_Node_Str",scalarEntry.getType());
      }
    }
 else     if (entry instanceof ScalarListEntry) {
      addListInputItem(name,description,entry.getKey());
    }
 else {
      logger.error("String_Node_Str",entry.getClass().getName());
    }
  }
}

Fixed version (ground truth):
DefaultSettingsGroup(String title,Properties properties,AddonSpecification desc){
  super(title,properties);
  this.desc=desc;
  for (  ConfigurationEntry entry : desc.getConfigDescription().getEntries()) {
    String name=entry.getLocalizedName(LANGUAGE_CODE);
    String description=entry.getLocalizedDescription(LANGUAGE_CODE);
    if (ScalarEntry.class.equals(entry.getClass())) {
      ScalarEntry scalarEntry=(ScalarEntry)entry;
      if (scalarEntry.getType().equalsIgnoreCase("String_Node_Str")) {
        addInputItem(name,description,entry.getKey());
      }
 else       if (scalarEntry.getType().equalsIgnoreCase("String_Node_Str")) {
        addBoolItem(name,description,entry.getKey());
      }
 else {
        logger.error("String_Node_Str",scalarEntry.getType());
      }
    }
 else     if (ScalarListEntry.class.equals(entry.getClass())) {
      addListInputItem(name,description,entry.getKey());
    }
 else {
      logger.error("String_Node_Str",entry.getClass().getName());
    }
  }
}
Program: 48163
Project: 48163
Buggy source:
public EstablishPACEResponse(byte[] response){
  int dataLen=response.length;
  int idx=4;
  statusBytes=new byte[]{response[0],response[1]};
  efCardAccessLength=(short)((response[2] & 0xFF) + ((response[3] & 0xFF) << 8));
  if (efCardAccessLength > 0) {
    efCardAccess=Arrays.copyOfRange(response,idx,idx + efCardAccessLength);
    idx+=efCardAccessLength;
  }
 else {
    efCardAccess=new byte[0];
  }
  if (dataLen > idx + 1) {
    currentCARLength=(byte)(response[idx] & 0xFF);
    idx++;
    if (currentCARLength > 0) {
      currentCAR=Arrays.copyOfRange(response,idx,idx + currentCARLength);
      idx+=currentCARLength;
    }
  }
  if (dataLen > idx + 1) {
    previousCARLength=(byte)(response[idx] & 0xFF);
    idx++;
    if (previousCARLength > 0) {
      previousCAR=Arrays.copyOfRange(response,idx,idx + previousCARLength);
      idx+=previousCARLength;
    }
  }
  if (dataLen > idx + 2) {
    idiccLength=(short)((response[idx] & 0xFF) + ((response[idx + 1] & 0xFF) << 8));
    idx+=2;
    if (idiccLength > 0) {
      idicc=Arrays.copyOfRange(response,idx,idx + idiccLength);
      idx+=idiccLength;
    }
  }
}

Fixed version (ground truth):
public EstablishPACEResponse(byte[] response){
  int dataLen=response.length;
  int idx=4;
  statusBytes=Arrays.copyOfRange(response,0,2);
  efCardAccessLength=(short)((response[2] & 0xFF) + ((response[3] & 0xFF) << 8));
  if (efCardAccessLength > 0) {
    efCardAccess=Arrays.copyOfRange(response,idx,idx + efCardAccessLength);
    idx+=efCardAccessLength;
  }
 else {
    efCardAccess=new byte[0];
  }
  if (dataLen > idx + 1) {
    currentCARLength=(byte)(response[idx] & 0xFF);
    idx++;
    if (currentCARLength > 0) {
      currentCAR=Arrays.copyOfRange(response,idx,idx + currentCARLength);
      idx+=currentCARLength;
    }
  }
  if (dataLen > idx + 1) {
    previousCARLength=(byte)(response[idx] & 0xFF);
    idx++;
    if (previousCARLength > 0) {
      previousCAR=Arrays.copyOfRange(response,idx,idx + previousCARLength);
      idx+=previousCARLength;
    }
  }
  if (dataLen > idx + 2) {
    idiccLength=(short)((response[idx] & 0xFF) + ((response[idx + 1] & 0xFF) << 8));
    idx+=2;
    if (idiccLength > 0) {
      idicc=Arrays.copyOfRange(response,idx,idx + idiccLength);
      idx+=idiccLength;
    }
  }
}
Program: 48165
Project: 48165
Buggy source:
public ExecutePACEResponse(byte[] response){
  result=ByteUtils.toInteger(Arrays.copyOfRange(response,0,4));
  length=ByteUtils.toShort(new byte[]{response[5],response[4]});
  data=Arrays.copyOfRange(response,6,6 + length);
}

Fixed version (ground truth):
public ExecutePACEResponse(byte[] response){
  result=ByteUtils.toInteger(Arrays.copyOfRange(response,0,4),false);
  length=ByteUtils.toShort(Arrays.copyOfRange(response,4,6),false);
  data=Arrays.copyOfRange(response,6,6 + length);
}
Program: 48167
Project: 48167
Buggy source:
public byte[] toBytes(){
  ByteArrayOutputStream o=new ByteArrayOutputStream();
  o.write(passwordType);
  if (chatLength > 0) {
    o.write(chatLength);
    if (chatLength > 0) {
      o.write(chat,0,chat.length);
    }
    o.write(passwordLength);
    if (passwordLength > 0) {
      o.write(password,0,password.length);
    }
    if (certDescLength > 0) {
      byte[] dataLength_bytes=ShortUtils.toByteArray(certDescLength);
      for (int i=dataLength_bytes.length - 1; i >= 0; i--) {
        o.write(dataLength_bytes[i]);
      }
      for (int i=dataLength_bytes.length; i < 2; i++) {
        o.write(0);
      }
      o.write(certDesc,0,certDesc.length);
    }
  }
  return o.toByteArray();
}

Fixed version (ground truth):
public byte[] toBytes(){
  ByteArrayOutputStream o=new ByteArrayOutputStream();
  o.write(passwordType);
  if (chatLength > 0) {
    o.write(chatLength);
    if (chatLength > 0) {
      o.write(chat,0,chat.length);
    }
    o.write(passwordLength);
    if (passwordLength > 0) {
      o.write(password,0,password.length);
    }
    if (certDescLength > 0) {
      byte[] dataLength_bytes=ShortUtils.toByteArray(certDescLength);
      for (int i=dataLength_bytes.length - 1; i >= 0; i--) {
        o.write(dataLength_bytes[i]);
      }
      for (int i=dataLength_bytes.length; i < 2; i++) {
        o.write(0);
      }
      o.write(certDesc,0,certDesc.length);
    }
  }
 else {
    o.write(0x00);
    o.write(0x00);
    o.write(0x00);
    o.write(0x00);
  }
  return o.toByteArray();
}
Program: 48169
Project: 48169
Buggy source:
/** 
 * Selects and reads a file.
 * @param dispatcher Dispatcher
 * @param slotHandle Slot handle
 * @param fileID File ID
 * @return File content
 * @throws APDUException
 */
public static byte[] readFile(Dispatcher dispatcher,byte[] slotHandle,byte[] fileID) throws APDUException {
  selectFile(dispatcher,slotHandle,fileID);
  return readFile(dispatcher,slotHandle);
}

Fixed version (ground truth):
/** 
 * Selects and reads a file.
 * @param dispatcher Dispatcher
 * @param slotHandle Slot handle
 * @param fileID File ID
 * @return File content
 * @throws APDUException
 */
public static byte[] readFile(Dispatcher dispatcher,byte[] slotHandle,byte[] fileID) throws APDUException {
  CardResponseAPDU selectResponse=selectFile(dispatcher,slotHandle,fileID);
  FCP fcp=null;
  try {
    fcp=new FCP(selectResponse.getData());
  }
 catch (  TLVException e) {
    logger.warn("String_Node_Str",e);
  }
  return readFile(fcp,dispatcher,slotHandle);
}
Program: 48170
Project: 48170
Buggy source:
/** 
 * Selects a File.
 * @param dispatcher Dispatcher
 * @param slotHandle Slot handle
 * @param fileID File ID
 * @throws APDUException
 */
public static void selectFile(Dispatcher dispatcher,byte[] slotHandle,byte[] fileID) throws APDUException {
  CardCommandAPDU selectFile=new Select.File(fileID);
  selectFile.transmit(dispatcher,slotHandle);
}

Fixed version (ground truth):
/** 
 * Selects a File.
 * @param dispatcher Dispatcher
 * @param slotHandle Slot handle
 * @param fileID File ID
 * @return CardREsponseAPDU containing the File Control Parameters
 * @throws APDUException
 */
public static CardResponseAPDU selectFile(Dispatcher dispatcher,byte[] slotHandle,byte[] fileID) throws APDUException {
  Select selectFile=new Select.File(fileID);
  selectFile.setFCP();
  return selectFile.transmit(dispatcher,slotHandle);
}
Program: 48171
Project: 48171
Buggy source:
/** 
 * Check if all components on the frame are valid. This can be used to see if a jump to the next frame can be made.
 * @return True if all components are valid, false otherwise.
 */
public boolean validateComponents(){
  for (  StepComponent next : components) {
    if (next.isValueType() && !next.validate()) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check if all components on the frame are valid. This can be used to see if a jump to the next frame can be made.
 * @return True if all components are valid, false otherwise.
 */
public boolean validateComponents(){
  for (  StepComponent next : components) {
    Component component=next.getComponent();
    if (next.isValueType() && !next.validate()) {
      component.setBackground(Color.RED);
      return false;
    }
    component.setBackground(null);
  }
  return true;
}
Program: 48172
Project: 48172
Buggy source:
@Override public void actionPerformed(ActionEvent e){
  logger.debug("String_Node_Str",e.getActionCommand());
  NavigationEvent event=NavigationEvent.fromEvent(e);
  if (event == null) {
    logger.error("String_Node_Str",e.getActionCommand());
    return;
  }
  if (action != null && !action.isDone()) {
    logger.debug("String_Node_Str");
    action.cancel(true);
    return;
  }
  StepFrame curStep=stepFrames.get(stepPointer);
  stepBar.enableLoaderImage();
  navBar.lockControls();
  curStep.lockControls();
  curStep.updateResult(event);
}

Fixed version (ground truth):
@Override public void actionPerformed(ActionEvent e){
  logger.debug("String_Node_Str",e.getActionCommand());
  NavigationEvent event=NavigationEvent.fromEvent(e);
  if (event == null) {
    logger.error("String_Node_Str",e.getActionCommand());
    return;
  }
  StepFrame curStep=stepFrames.get(stepPointer);
  if (event == NavigationEvent.NEXT && !curStep.validateComponents()) {
    logger.debug("String_Node_Str");
    return;
  }
  if (action != null && !action.isDone()) {
    logger.debug("String_Node_Str");
    action.cancel(true);
    return;
  }
  stepBar.enableLoaderImage();
  navBar.lockControls();
  curStep.lockControls();
  curStep.updateResult(event);
}
Program: 48173
Project: 48173
Buggy source:
private Image getTrayIconImage(String name){
  Dimension dim=tray.getTrayIconSize();
  if (isLinux()) {
    if (isKde()) {
      return getImageKde(name,dim);
    }
 else {
      return getImageLinux(name,dim);
    }
  }
 else {
    return getImageDefault(name,dim);
  }
}

Fixed version (ground truth):
private Image getTrayIconImage(String name){
  Dimension dim=tray.getTrayIconSize();
  if (isLinux()) {
    if (isKde()) {
      return getImageKde(name,dim);
    }
 else {
      return getImageLinux(name,dim);
    }
  }
 else   if (isMacOSX()) {
    return getImageMacOSX(name,dim);
  }
 else {
    return getImageDefault(name,dim);
  }
}
Program: 48176
Project: 48176
Buggy source:
/** 
 * Remove the entry reference in slotHandle index. <br/> This function is needed to update the index in CardApplicationDisconnect.
 * @param slotHandle SlotHandle for which the entry reference should be deleted.
 */
public synchronized void removeSlotHandleEntry(byte[] slotHandle){
  ConnectionHandleType handle=new ConnectionHandleType();
  handle.setSlotHandle(slotHandle);
  Set<CardStateEntry> entries=getMatchingEntries(handle);
  Iterator<CardStateEntry> it=entries.iterator();
  if (it.hasNext()) {
    CardStateEntry entry=it.next();
    removeMapEntry(handle.getSlotHandle(),slothandleMap,entry);
  }
}

Fixed version (ground truth):
/** 
 * Remove the entry reference in slotHandle index. <br/> This function is needed to update the index in CardApplicationDisconnect.
 * @param slotHandle SlotHandle for which the entry reference should be deleted.
 */
public synchronized void removeSlotHandleEntry(byte[] slotHandle){
  ConnectionHandleType handle=new ConnectionHandleType();
  handle.setSlotHandle(slotHandle);
  Set<CardStateEntry> entries=getMatchingEntries(handle);
  Iterator<CardStateEntry> it=entries.iterator();
  if (it.hasNext()) {
    CardStateEntry entry=it.next();
    removeMapEntry(handle.getSlotHandle(),slothandleMap,entry);
    clearProtocolsForEntry(entry);
  }
}
Program: 48180
Project: 48180
Buggy source:
public SwingFileDialog(){
  this.dialog=new JFileChooser();
  this.dialog.setPreferredSize(new Dimension(800,490));
}

Fixed version (ground truth):
public SwingFileDialog(){
  this.dialog=new JFileChooser(){
    @Override protected JDialog createDialog(    Component parent){
      JDialog dialog=super.createDialog(parent);
      dialog.setIconImage(GUIDefaults.getImage("String_Node_Str",45,45).getImage());
      return dialog;
    }
  }
;
  this.dialog.setPreferredSize(new Dimension(800,490));
}
Program: 48183
Project: 48183
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  intent=getIntent();
  fdSocket=getFilesDir().getAbsolutePath() + "String_Node_Str";
  pathSocket=getFilesDir().getAbsolutePath() + "String_Node_Str";
  if (t == null) {
    t=new Thread(new SocketCommunicationRunnable());
    t.start();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  intent=getIntent();
  if (intent.getBooleanExtra(AndroidUtils.EXIT,false)) {
    finish();
  }
  fdSocket=getFilesDir().getAbsolutePath() + "String_Node_Str";
  pathSocket=getFilesDir().getAbsolutePath() + "String_Node_Str";
  if (t == null) {
    t=new Thread(new SocketCommunicationRunnable());
    t.start();
  }
}
Program: 48186
Project: 48186
Buggy source:
@Override public void perform() throws DispatcherException, InvocationTargetException {
  ConnectionHandleType cHandle=waitForCardType(GERMAN_IDENTITY_CARD);
  if (cHandle == null) {
    logger.debug("String_Node_Str");
    return;
  }
  cHandle=connectToRootApplication(cHandle);
  RecognizedState pinState=recognizeState(cHandle);
  boolean nativePace;
  try {
    nativePace=genericPACESupport(cHandle);
  }
 catch (  WSException e) {
    logger.error("String_Node_Str");
    return;
  }
  ChangePINDialog uc=new ChangePINDialog(gui,dispatcher,cHandle,pinState,!nativePace);
  uc.show();
}

Fixed version (ground truth):
@Override public void perform() throws DispatcherException, InvocationTargetException {
  ConnectionHandleType cHandle=waitForCardType(GERMAN_IDENTITY_CARD);
  if (cHandle == null) {
    logger.debug("String_Node_Str");
    return;
  }
  cHandle=connectToRootApplication(cHandle);
  RecognizedState pinState=recognizeState(cHandle);
  boolean nativePace;
  try {
    nativePace=genericPACESupport(cHandle);
  }
 catch (  WSException e) {
    logger.error("String_Node_Str");
    return;
  }
  ChangePINDialog uc=new ChangePINDialog(gui,dispatcher,cHandle,pinState,!nativePace);
  uc.show();
  Disconnect d=new Disconnect();
  d.setSlotHandle(cHandle.getSlotHandle());
  dispatcher.deliver(d);
}
Program: 48187
Project: 48187
Buggy source:
@Override public void perform() throws DispatcherException, InvocationTargetException {
  ConnectionHandleType cHandle=waitForCardType(GERMAN_IDENTITY_CARD);
  if (cHandle == null) {
    logger.debug("String_Node_Str");
    return;
  }
  cHandle=connectToRootApplication(cHandle);
  RecognizedState pinState=recognizeState(cHandle);
  boolean nativePace;
  try {
    nativePace=genericPACESupport(cHandle);
  }
 catch (  WSException e) {
    logger.error("String_Node_Str");
    return;
  }
  UnblockPINDialog uc=new UnblockPINDialog(gui,dispatcher,cHandle,pinState,!nativePace);
  uc.show();
}

Fixed version (ground truth):
@Override public void perform() throws DispatcherException, InvocationTargetException {
  ConnectionHandleType cHandle=waitForCardType(GERMAN_IDENTITY_CARD);
  if (cHandle == null) {
    logger.debug("String_Node_Str");
    return;
  }
  cHandle=connectToRootApplication(cHandle);
  RecognizedState pinState=recognizeState(cHandle);
  boolean nativePace;
  try {
    nativePace=genericPACESupport(cHandle);
  }
 catch (  WSException e) {
    logger.error("String_Node_Str");
    return;
  }
  UnblockPINDialog uc=new UnblockPINDialog(gui,dispatcher,cHandle,pinState,!nativePace);
  uc.show();
  Disconnect d=new Disconnect();
  d.setSlotHandle(cHandle.getSlotHandle());
  dispatcher.deliver(d);
}
Program: 48189
Project: 48189
Buggy source:
/** 
 * Returns the encoded APDU: CLA | INS | P1 | P2 | (EXT)LC | DATA | (EXT)LE
 * @return Encoded APDU
 */
public final byte[] toByteArray(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream(data.length + 10);
  try {
    baos.write(header);
    if (lc > 255) {
      baos.write(x00);
      baos.write((byte)(lc >> 8));
      baos.write((byte)lc);
    }
 else     if (lc > 0) {
      baos.write((byte)lc);
    }
    baos.write(data);
    if (le > 256) {
      if (lc < 256) {
        baos.write(x00);
      }
      if (le == 65536) {
        baos.write(x00);
        baos.write(x00);
      }
      baos.write((byte)(le >> 8));
      baos.write((byte)le);
    }
 else     if (le == 256) {
      baos.write(x00);
    }
 else     if (le > 0) {
      baos.write((byte)le);
    }
  }
 catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
  return baos.toByteArray();
}

Fixed version (ground truth):
/** 
 * Returns the encoded APDU: CLA | INS | P1 | P2 | (EXT)LC | DATA | (EXT)LE
 * @return Encoded APDU
 */
public final byte[] toByteArray(){
  ByteArrayOutputStream baos=new ByteArrayOutputStream(data.length + 10);
  try {
    baos.write(header);
    if (lc > 255) {
      baos.write(x00);
      baos.write((byte)(lc >> 8));
      baos.write((byte)lc);
    }
 else     if (lc > 0) {
      baos.write((byte)lc);
    }
    baos.write(data);
    if (le > 256) {
      if (lc < 256) {
        baos.write(x00);
      }
      if (le == 65536) {
        baos.write(x00);
        baos.write(x00);
      }
      baos.write((byte)(le >> 8));
      baos.write((byte)le);
    }
 else     if (le > 0) {
      if (lc > 255) {
        baos.write((byte)(le >> 8));
        baos.write((byte)le);
      }
 else {
        baos.write((byte)le);
      }
    }
  }
 catch (  IOException ex) {
    logger.error("String_Node_Str",ex);
  }
  return baos.toByteArray();
}