nus-yam/ex-repair huggingface dataset:
Program: 88901
Project: 88901
Buggy source:
@Override public void execute(OperationContext ctx){
  ByteIterator bi=ctx.getByteIterator();
  int startPos=bi.getPos();
  bi.seek(4 - (startPos % 4));
  int defaultOffset=bi.nextInt();
  int npairs=bi.nextInt();
  Map<Integer,Integer> lookupMap=new HashMap<>(npairs);
  for (int i=0; i < npairs; i++) {
    lookupMap.put(bi.nextInt(),bi.nextInt());
  }
  Integer res=lookupMap.get(ctx.getStack().popRaw());
  int offset=res == null ? defaultOffset : res;
  bi.seek(offset - (bi.getPos() - startPos + 1));
}

Fixed version (ground truth):
@Override public void execute(OperationContext ctx){
  ByteIterator bi=ctx.getByteIterator();
  int startPos=bi.getPos();
  int mod=startPos % 4;
  if (mod > 0) {
    bi.seek(4 - mod);
  }
  int defaultOffset=bi.nextInt();
  int npairs=bi.nextInt();
  Map<Integer,Integer> lookupMap=new HashMap<>(npairs);
  for (int i=0; i < npairs; i++) {
    lookupMap.put(bi.nextInt(),bi.nextInt());
  }
  Integer res=lookupMap.get(ctx.getStack().popRaw());
  int offset=res == null ? defaultOffset : res;
  bi.seek(offset - (bi.getPos() - startPos + 1));
}
Program: 88902
Project: 88902
Buggy source:
public Execution(Method method,Variables localVariables,Thread thread){
  this.method=method;
  this.byteIterator=method.getCode() == null ? null : new ByteBufferIterator(method.getCode().getCode());
  this.localVariables=localVariables;
  this.constantPool=method.getClassObject().getConstantPool();
  this.thread=thread;
  if (method.hasModifier(Modifier.SYNCHRONIZED)) {
    Oop target=method.isStatic() ? method.getClassObject().getOop() : localVariables.getOop(0);
    synchronizedMethodLocks=target.getMarkRef().getMonitor();
    synchronizedMethodLocks.lock();
  }
 else {
    synchronizedMethodLocks=null;
  }
}

Fixed version (ground truth):
public Execution(Method method,Variables localVariables,Thread thread){
  this.method=method;
  this.byteIterator=method.getCode() == null ? null : new ByteBufferIterator(method.getCode().getCode());
  this.localVariables=localVariables;
  this.constantPool=method.getClassObject().getConstantPool();
  this.thread=thread;
  if (method.hasModifier(Modifier.SYNCHRONIZED)) {
    Oop target=method.isStatic() ? method.getClassObject().getOop() : localVariables.getOop(0);
    synchronizedMethodLocks=target.getMarkRef().getMonitor();
    if (!synchronizedMethodLocks.tryLock()) {
      Heap.threadSleeping();
      synchronizedMethodLocks.lock();
      Heap.threadWaking();
    }
  }
 else {
    synchronizedMethodLocks=null;
  }
}
Program: 88903
Project: 88903
Buggy source:
@Override public void execute(OperationContext ctx){
  VariableStack stack=ctx.getStack();
  WideVariable top=stack.popWide();
  WideVariable next=stack.popWide();
  stack.pushWide(top);
  stack.pushWide(next);
  stack.pushWide(top);
}

Fixed version (ground truth):
@Override public void execute(OperationContext ctx){
  VariableStack stack=ctx.getStack();
  if (stack.peekType().isDoubleWidth()) {
    WideVariable top=stack.popWide();
    Variable next=popSingleWidth(stack);
    stack.pushWide(top);
    stack.push(next);
    stack.pushWide(top);
  }
 else {
    Variable one=popSingleWidth(stack);
    Variable two=popSingleWidth(stack);
    Variable three=popSingleWidth(stack);
    stack.push(two);
    stack.push(one);
    stack.push(three);
    stack.push(two);
    stack.push(one);
  }
}
Program: 88904
Project: 88904
Buggy source:
@Override protected final void doInvoke(Method method,OperationContext ctx){
  Variables args=method.newArgArray();
  int argCount=method.getSignature().getLength();
  for (int i=argCount; i >= 1; i--) {
    SimpleType type=method.getSignature().getArgTypes().get(i).asSimpleType();
    args.put(i,type,ctx.getStack().popSingleWidth(type));
  }
  Oop oop=ctx.getStack().popOop();
  args.putOop(0,oop);
  Method implementation=getImplementationMethod(method,oop);
  if (implementation.hasModifier(Modifier.NATIVE)) {
    invokeNativeMethod((NativeMethod)method,args,ctx);
  }
 else {
    int maxLocalVars=implementation.getCode().getMaxLocals();
    if (maxLocalVars > args.length()) {
      Variables tmp=new Variables(maxLocalVars);
      System.arraycopy(args.getRawValues(),0,tmp.getRawValues(),0,args.length());
      System.arraycopy(args.getTypes(),0,tmp.getTypes(),0,args.length());
      args=tmp;
    }
    ctx.getExecutionStack().push(new ExecutionStackElement(implementation,args,implementation.getClassObject().getConstantPool(),ctx.getExecutionStack()));
  }
  afterInvoke(ctx);
}

Fixed version (ground truth):
@Override protected final void doInvoke(Method method,OperationContext ctx){
  Variables args=method.newArgArray();
  int argCount=method.getSignature().getLength();
  for (int i=argCount; i >= 1; i--) {
    SimpleType type=method.getSignature().getArgTypes().get(i - 1).asSimpleType();
    args.put(i,type,ctx.getStack().popSingleWidth(type));
  }
  Oop oop=ctx.getStack().popOop();
  args.putOop(0,oop);
  Method implementation=getImplementationMethod(method,oop);
  if (implementation.hasModifier(Modifier.NATIVE)) {
    invokeNativeMethod((NativeMethod)method,args,ctx);
  }
 else {
    int maxLocalVars=implementation.getCode().getMaxLocals();
    if (maxLocalVars > args.length()) {
      Variables tmp=new Variables(maxLocalVars);
      System.arraycopy(args.getRawValues(),0,tmp.getRawValues(),0,args.length());
      System.arraycopy(args.getTypes(),0,tmp.getTypes(),0,args.length());
      args=tmp;
    }
    ctx.getExecutionStack().push(new ExecutionStackElement(implementation,args,implementation.getClassObject().getConstantPool(),ctx.getExecutionStack()));
  }
  afterInvoke(ctx);
}
Program: 88905
Project: 88905
Buggy source:
@Override public final void doExecute(Field field,OperationContext ctx){
  VariableStack stack=ctx.getStack();
  SimpleType type=field.getType().asSimpleType();
  if (field.getType().isDoubleWidth()) {
    field.set(getOop(stack),stack.popDoubleWidth(type));
  }
 else {
    field.set(getOop(stack),stack.popSingleWidth(type));
  }
}

Fixed version (ground truth):
@Override public final void doExecute(Field field,OperationContext ctx){
  VariableStack stack=ctx.getStack();
  SimpleType type=field.getType().asSimpleType();
  if (field.getType().isDoubleWidth()) {
    int two=stack.popSingleWidth(type);
    int one=stack.popSingleWidth(type);
    field.set(getOop(stack),one,two);
  }
 else {
    int val=stack.popSingleWidth(type);
    field.set(getOop(stack),val);
  }
}
Program: 88906
Project: 88906
Buggy source:
private static void simpleThreadingTest(){
  AtomicInteger ai=new AtomicInteger();
  int num=4;
  final Random random=new Random();
  final CountDownLatch latch=new CountDownLatch(4);
  for (int i=0; i < num; i++) {
    new Thread(new Runnable(){
      @Override public void run(){
        try {
          Thread.sleep(100 + random.nextInt(50));
        }
 catch (        InterruptedException e) {
          throw new AssertionError(e);
        }
        ai.getAndIncrement();
        latch.countDown();
      }
    }
).start();
  }
  try {
    latch.await();
  }
 catch (  InterruptedException e) {
    throw new AssertionError(e);
  }
  System.out.println("String_Node_Str" + num + "String_Node_Str"+ ai);
}

Fixed version (ground truth):
private static void simpleThreadingTest(){
  AtomicInteger ai=new AtomicInteger();
  int num=40;
  final Random random=new Random();
  final CountDownLatch latch=new CountDownLatch(num);
  for (int i=0; i < num; i++) {
    new Thread(new Runnable(){
      @Override public void run(){
        try {
          Thread.sleep(100 + random.nextInt(50));
        }
 catch (        InterruptedException e) {
          throw new AssertionError(e);
        }
        ai.getAndIncrement();
        latch.countDown();
      }
    }
).start();
  }
  try {
    latch.await();
  }
 catch (  InterruptedException e) {
    throw new AssertionError(e);
  }
  System.out.println("String_Node_Str" + num + "String_Node_Str"+ ai);
}
Program: 88907
Project: 88907
Buggy source:
public long popLong(){
  if (head <= 1) {
    throw new NoSuchElementException();
  }
  long val=Utils.toLong(stack[head - 1],stack[head]);
  head-=2;
  return val;
}

Fixed version (ground truth):
public long popLong(){
  if (head <= 1) {
    throw new NoSuchElementException();
  }
  long val=Utils.toLong(stack[head - 2],stack[head - 1]);
  head-=2;
  return val;
}
Program: 88908
Project: 88908
Buggy source:
public Method translate(CpMethodReference cmr,Object[] constantPool){
  ClassObject co=findClassObject(cmr,constantPool);
  final ClassObject coCopy=co;
  NameAndType nat=(NameAndType)constantPool[cmr.getNameAndTypeIndex()];
  String name=(String)constantPool[nat.getNameIndex()];
  String descriptor=(String)constantPool[nat.getDescriptorIndex()];
  MethodSignature methodSignature=MethodSignature.parse(name,descriptor);
  while (co != null) {
    MethodKey key=new MethodKey(co.getClassName(),methodSignature);
    Method method=methods.get(key);
    if (method != null) {
      return method;
    }
    co=co.getSuperClass();
  }
  throw new IllegalArgumentException("String_Node_Str" + new MethodKey(coCopy.getClassName(),methodSignature));
}

Fixed version (ground truth):
public Method translate(CpMethodReference cmr,Object[] constantPool){
  ClassObject co=findClassObject(cmr,constantPool);
  final ClassObject coCopy=co;
  NameAndType nat=(NameAndType)constantPool[cmr.getNameAndTypeIndex()];
  String name=(String)constantPool[nat.getNameIndex()];
  String descriptor=(String)constantPool[nat.getDescriptorIndex()];
  MethodSignature methodSignature=MethodSignature.parse(name,descriptor);
  Method method;
  if (co.hasModifier(Modifier.INTERFACE)) {
    method=translateInterfaceMethod(co,methodSignature);
  }
 else {
    do {
      method=methods.get(new MethodKey(co.getClassName(),methodSignature));
      co=co.getSuperClass();
    }
 while (method == null && co != null);
  }
  if (method == null) {
    throw new IllegalArgumentException("String_Node_Str" + new MethodKey(coCopy.getClassName(),methodSignature));
  }
  return method;
}
Program: 88909
Project: 88909
Buggy source:
public static MethodSignature parse(String name,String description){
  CharIterator it=new CharIterator(description);
  if (it.next() != '(') {
    throw new IllegalArgumentException("String_Node_Str" + description);
  }
  List<Type> argTypes=new ArrayList<>(4);
  while (it.peek() != ')') {
    argTypes.add(Types.parseType(it));
  }
  it.next();
  argTypes=argTypes.isEmpty() ? Collections.emptyList() : argTypes;
  Type returnType=Types.parseType(it);
  return new MethodSignature(name,argTypes,returnType);
}

Fixed version (ground truth):
public static MethodSignature parse(String name,String descriptor){
  CharIterator it=new CharIterator(descriptor);
  if (it.next() != '(') {
    throw new IllegalArgumentException("String_Node_Str" + descriptor);
  }
  List<Type> argTypes=new ArrayList<>(4);
  while (it.peek() != ')') {
    argTypes.add(Types.parseType(it));
  }
  it.next();
  argTypes=argTypes.isEmpty() ? Collections.emptyList() : argTypes;
  Type returnType=Types.parseType(it);
  return new MethodSignature(name,argTypes,returnType);
}
Program: 88910
Project: 88910
Buggy source:
public void saveSelectedList(){
  if (!mSave)   return;
  Set<String> selectedSet=new HashSet<String>();
  Adapter adapter=(Adapter)getListAdapter();
  for (int i=0; i < adapter.getCount(); ++i) {
    Entry entry=adapter.getItem(i);
    if (entry.selected) {
      selectedSet.add(entry.packageName);
    }
  }
  PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putStringSet(mPrefKey,selectedSet).apply();
  mSave=false;
}

Fixed version (ground truth):
public void saveSelectedList(){
  if (!mSave)   return;
  Set<String> selectedSet=new HashSet<String>();
  Adapter adapter=(Adapter)getListAdapter();
  for (int i=0; i < adapter.getCount(); ++i) {
    Entry entry=adapter.getItem(i);
    if (entry.selected) {
      selectedSet.add(entry.packageName);
    }
  }
  FA.getSharedPreferences(getActivity()).edit().putStringSet(mPrefKey,selectedSet).apply();
  mSave=false;
}
Program: 88912
Project: 88912
Buggy source:
@Override public String getInventoryName(){
  return player.getDisplayName();
}

Fixed version (ground truth):
@Override public String getInventoryName(){
  return player.getCommandSenderName();
}
Program: 88913
Project: 88913
Buggy source:
public boolean checkMinecraft(AsieLauncher l,String version){
  assetsDir=l.baseDir + "String_Node_Str";
  gameVersion=version;
  nativesDir=getNativesLocation(l,version);
  File dir=new File(l.baseDir + "String_Node_Str");
  if (!dir.exists())   dir.mkdirs();
  if (!loadJSON(l.directory,l.baseDir,l.baseDir + "String_Node_Str",version))   return false;
  if (!downloadMinecraft(getJarLocation(l,version),version))   return false;
  return true;
}

Fixed version (ground truth):
public boolean checkMinecraft(AsieLauncher l,String version){
  assetsDir=l.baseDir + "String_Node_Str";
  gameVersion=version;
  nativesDir=getNativesLocation(l,version);
  File dir=new File(l.baseDir + "String_Node_Str");
  if (!dir.exists())   dir.mkdirs();
  if (!loadJSON(l.directory,l.baseDir,l.directory + "String_Node_Str",version))   return false;
  if (!downloadMinecraft(getJarLocation(l,version),version))   return false;
  return true;
}
Program: 88914
Project: 88914
Buggy source:
public boolean init(){
  file=Utils.readJSONUrlFile(URL + "String_Node_Str");
  if (file instanceof JSONObject) {
    Object o=file.get("String_Node_Str");
    boolean onlineMode=false;
    if (o instanceof Boolean)     onlineMode=((Boolean)o);
    if (getFileRevision(file) >= 5) {
      mcVersion=(String)file.get("String_Node_Str");
    }
 else     mcVersion="String_Node_Str";
    if (Utils.versionToInt(this.mcVersion) <= Utils.versionToInt("String_Node_Str")) {
      mc=new MinecraftHandler152();
      if (onlineMode)       auth=new AuthenticationMojangLegacy();
    }
 else {
      mc=new MinecraftHandler162();
      if (onlineMode)       auth=new AuthenticationYggdrasil(directory,false);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean init(){
  file=Utils.readJSONUrlFile(URL + "String_Node_Str");
  if (!(file instanceof JSONObject)) {
    file=oldFile;
  }
  if (file instanceof JSONObject) {
    Object o=file.get("String_Node_Str");
    boolean onlineMode=false;
    if (o instanceof Boolean)     onlineMode=((Boolean)o);
    if (getFileRevision(file) >= 5) {
      mcVersion=(String)file.get("String_Node_Str");
    }
 else     mcVersion="String_Node_Str";
    if (Utils.versionToInt(this.mcVersion) <= Utils.versionToInt("String_Node_Str")) {
      mc=new MinecraftHandler152();
      if (onlineMode)       auth=new AuthenticationMojangLegacy();
    }
 else {
      mc=new MinecraftHandler162();
      if (onlineMode)       auth=new AuthenticationYggdrasil(directory,false);
    }
    return (file != oldFile);
  }
  return false;
}
Program: 88916
Project: 88916
Buggy source:
@Override public void actionPerformed(ActionEvent event){
  if (validateLaunch()) {
    quitButton.setEnabled(false);
    launchButton.setEnabled(false);
    loginLabel.setText(Strings.PROGRESS + "String_Node_Str");
    loginLabel.setBounds(10,162,70,15);
    panel.remove(loginField);
    String password="String_Node_Str";
    if (passwordField != null) {
      password=new String(passwordField.getPassword());
      panel.remove(passwordLabel);
      panel.remove(passwordField);
    }
    Utils.saveStringToFile(launcher.directory + "String_Node_Str",loginField.getText());
    if (hasInternet)     options.saveSelectedOptions(options.filename);
    panel.add(progressBar);
    statusLabel.setText(Strings.START_UPDATE);
    repaint();
    LauncherThread thread=new LauncherThread(launcher,options,loginField.getText(),password,hasInternet && !controlDown);
    thread.start();
  }
 else {
    statusLabel.setText(Strings.INVALID_LOGIN);
    repaint();
  }
}

Fixed version (ground truth):
@Override public void actionPerformed(ActionEvent event){
  if (validateLaunch()) {
    quitButton.setEnabled(false);
    launchButton.setEnabled(false);
    loginLabel.setText(Strings.PROGRESS + "String_Node_Str");
    loginLabel.setBounds(10,162,70,15);
    panel.remove(loginField);
    String password="String_Node_Str";
    if (passwordField != null) {
      password=new String(passwordField.getPassword());
      panel.remove(passwordLabel);
      panel.remove(passwordField);
    }
    if (options.loginCheckbox.isSelected())     launcher.setKeepPassword(true);
    Utils.saveStringToFile(launcher.directory + "String_Node_Str",loginField.getText());
    if (hasInternet)     options.saveSelectedOptions(options.filename);
    panel.add(progressBar);
    statusLabel.setText(Strings.START_UPDATE);
    repaint();
    LauncherThread thread=new LauncherThread(launcher,options,loginField.getText(),password,hasInternet && !controlDown);
    thread.start();
  }
 else {
    statusLabel.setText(Strings.INVALID_LOGIN);
    repaint();
  }
}
Program: 88917
Project: 88917
Buggy source:
public void saveSelectedOptions(String filename){
  BufferedWriter writer=null;
  try {
    writer=new BufferedWriter(new FileWriter(filename));
    writer.write(("String_Node_Str" + OPTIONS_VERSION) + '\n');
    writer.write(ramAmount.getText() + '\n');
    writer.write(otherArgs.getText() + '\n');
    for (    JCheckBox box : optionBoxes.values()) {
      if (box != null && box.isSelected())       writer.write(optionBoxIDs.get(box) + '\n');
    }
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    if (writer != null)     try {
      writer.close();
    }
 catch (    Exception ee) {
    }
    return;
  }
  return;
}

Fixed version (ground truth):
public void saveSelectedOptions(String filename){
  BufferedWriter writer=null;
  try {
    writer=new BufferedWriter(new FileWriter(filename));
    writer.write(("String_Node_Str" + OPTIONS_VERSION) + '\n');
    writer.write(ramAmount.getText() + '\n');
    writer.write(otherArgs.getText() + '\n');
    writer.write((loginCheckbox.isSelected() ? "String_Node_Str" : "String_Node_Str") + '\n');
    for (    JCheckBox box : optionBoxes.values()) {
      if (box != null && box.isSelected())       writer.write(optionBoxIDs.get(box) + '\n');
    }
    writer.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    if (writer != null)     try {
      writer.close();
    }
 catch (    Exception ee) {
    }
    return;
  }
  return;
}
Program: 88919
Project: 88919
Buggy source:
public void loadSelectedOptions(String filename){
  String line="String_Node_Str";
  File file=new File(filename);
  if (!file.exists())   return;
  for (  JCheckBox box : optionBoxes.values()) {
    box.setSelected(false);
  }
  try {
    BufferedReader reader=new BufferedReader(new FileReader(file));
    line=reader.readLine();
    int currentVersion=new Integer(line);
    if (currentVersion == 0) {
      reader.close();
      return;
    }
    if (currentVersion > 0) {
      ramAmount.setText(reader.readLine());
      otherArgs.setText(reader.readLine());
    }
    line=reader.readLine();
    while (line != null) {
      JCheckBox box=optionBoxes.get(line);
      if (box != null)       box.setSelected(true);
      line=reader.readLine();
    }
    reader.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return;
}

Fixed version (ground truth):
public void loadSelectedOptions(String filename){
  String line="String_Node_Str";
  File file=new File(filename);
  if (!file.exists())   return;
  for (  JCheckBox box : optionBoxes.values()) {
    box.setSelected(false);
  }
  try {
    BufferedReader reader=new BufferedReader(new FileReader(file));
    line=reader.readLine();
    int currentVersion=new Integer(line);
    if (currentVersion == 0) {
      reader.close();
      return;
    }
    if (currentVersion > 0) {
      ramAmount.setText(reader.readLine());
      otherArgs.setText(reader.readLine());
    }
    if (currentVersion > 1) {
      loginCheckbox.setEnabled(new Boolean(reader.readLine()));
    }
    line=reader.readLine();
    while (line != null) {
      JCheckBox box=optionBoxes.get(line);
      if (box != null)       box.setSelected(true);
      line=reader.readLine();
    }
    reader.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return;
}
Program: 88920
Project: 88920
Buggy source:
@SuppressWarnings("String_Node_Str") private boolean renewSessionID(){
  triedRenewSessionID=true;
  sessionID=Utils.loadStringFromFile(directory + "String_Node_Str");
  if (sessionID == null || sessionID.length() == 0) {
    return false;
  }
  JSONObject payload=new JSONObject();
  payload.put("String_Node_Str",getMojangSessionID());
  payload.put("String_Node_Str",clientToken);
  JSONObject answer=sendJSONPayload("String_Node_Str",payload);
  if (ifErrorThenSet(answer))   return false;
  sessionID=(String)answer.get("String_Node_Str");
  if (keepLoggedIn)   saveSessionID();
  return true;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private boolean renewSessionID(){
  triedRenewSessionID=true;
  sessionID=Utils.loadStringFromFile(directory + "String_Node_Str");
  if (sessionID == null || sessionID.length() == 0) {
    return false;
  }
  JSONObject payload=new JSONObject();
  payload.put("String_Node_Str",getMojangSessionID());
  payload.put("String_Node_Str",clientToken);
  JSONObject answer=sendJSONPayload("String_Node_Str",payload);
  if (ifErrorThenSet(answer)) {
    sessionID=null;
    return false;
  }
  sessionID=(String)answer.get("String_Node_Str");
  if (keepLoggedIn)   saveSessionID();
  return true;
}
Program: 88921
Project: 88921
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public boolean authenticate(String username,String password){
  if (triedRenewSessionID & sessionID != null && sessionID.length() > 0) {
    return true;
  }
  realUsername=username;
  JSONObject payload=new JSONObject();
  payload.put("String_Node_Str",username);
  payload.put("String_Node_Str",password);
  payload.put("String_Node_Str",clientToken);
  JSONObject answer=sendJSONPayload("String_Node_Str",payload);
  if (ifErrorThenSet(answer))   return false;
  JSONObject profile=(JSONObject)answer.get("String_Node_Str");
  realUsername=(String)profile.get("String_Node_Str");
  sessionID=(String)answer.get("String_Node_Str");
  if (keepLoggedIn)   saveSessionID();
  return true;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public boolean authenticate(String username,String password){
  if (triedRenewSessionID && sessionID != null && sessionID.length() > 0) {
    return true;
  }
  realUsername=username;
  JSONObject payload=new JSONObject();
  payload.put("String_Node_Str",username);
  payload.put("String_Node_Str",password);
  payload.put("String_Node_Str",clientToken);
  JSONObject answer=sendJSONPayload("String_Node_Str",payload);
  if (ifErrorThenSet(answer))   return false;
  JSONObject profile=(JSONObject)answer.get("String_Node_Str");
  realUsername=(String)profile.get("String_Node_Str");
  sessionID=(String)answer.get("String_Node_Str");
  if (keepLoggedIn)   saveSessionID();
  return true;
}
Program: 88922
Project: 88922
Buggy source:
@Override public boolean requiresPassword(){
  if (!triedRenewSessionID)   return !renewSessionID();
  return true;
}

Fixed version (ground truth):
@Override public boolean requiresPassword(){
  if (!triedRenewSessionID)   return !renewSessionID();
 else   return true;
}
Program: 88923
Project: 88923
Buggy source:
private boolean ifErrorThenSet(JSONObject errorJSON){
  if (!errorJSON.containsKey("String_Node_Str"))   return false;
  if (errorJSON.containsKey("String_Node_Str"))   error=(String)errorJSON.get("String_Node_Str");
 else   error=(String)errorJSON.get("String_Node_Str");
  return true;
}

Fixed version (ground truth):
private boolean ifErrorThenSet(JSONObject errorJSON){
  if (errorJSON == null) {
    error="String_Node_Str";
    return true;
  }
  if (!errorJSON.containsKey("String_Node_Str"))   return false;
  if (errorJSON.containsKey("String_Node_Str"))   error=(String)errorJSON.get("String_Node_Str");
 else   error=(String)errorJSON.get("String_Node_Str");
  return true;
}
Program: 88924
Project: 88924
Buggy source:
public boolean init(){
  file=readJSONNetworkFile(URL + "String_Node_Str");
  return (file instanceof JSONObject);
}

Fixed version (ground truth):
public boolean init(){
  file=readJSONUrlFile(URL + "String_Node_Str");
  return (file instanceof JSONObject);
}
Program: 88925
Project: 88925
Buggy source:
public void configureConfig(){
  configFile=readJSONFile(getClass().getResource("String_Node_Str").getPath());
  PREFIX="String_Node_Str" + (String)configFile.get("String_Node_Str") + "String_Node_Str";
  URL=(String)configFile.get("String_Node_Str");
  WINDOW_NAME=(String)configFile.get("String_Node_Str");
  onlineMode=(Boolean)configFile.get("String_Node_Str");
}

Fixed version (ground truth):
public void configureConfig(){
  configFile=readJSONUrlFile(getClass().getResource("String_Node_Str"));
  PREFIX="String_Node_Str" + (String)configFile.get("String_Node_Str") + "String_Node_Str";
  URL=(String)configFile.get("String_Node_Str");
  WINDOW_NAME=(String)configFile.get("String_Node_Str");
  onlineMode=(Boolean)configFile.get("String_Node_Str");
}
Program: 88927
Project: 88927
Buggy source:
private String getSoundcloudAttributes(String songURL){
  String attributes=null;
  try {
    URL url=new URL("String_Node_Str" + songURL);
    InputStream is=url.openStream();
    StringBuilder buffer=new StringBuilder();
    int ptr;
    while ((ptr=is.read()) != -1) {
      buffer.append((char)ptr);
    }
    attributes=buffer.toString().split("String_Node_Str")[1].split("String_Node_Str")[0].replace("String_Node_Str","String_Node_Str");
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + songURL + "String_Node_Str",ex);
  }
  return attributes;
}

Fixed version (ground truth):
@Nullable private String getSoundcloudAttributes(String songURL){
  String attributes=null;
  try {
    String infoUrl="String_Node_Str" + songURL;
    GetMethod get;
    HttpClient client=new HttpClient();
    get=new GetMethod(infoUrl);
    int errcode=client.executeMethod(get);
    if (errcode != 200) {
      throw new RuntimeException("String_Node_Str" + errcode + "String_Node_Str");
    }
    String resp=IOUtils.toString(get.getResponseBodyAsStream(),"String_Node_Str");
    attributes=resp.split("String_Node_Str")[1].split("String_Node_Str")[0].replace("String_Node_Str","String_Node_Str");
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str" + songURL + "String_Node_Str",ex);
  }
  return attributes;
}
Program: 88928
Project: 88928
Buggy source:
public synchronized void irc_soundcloud(String sender,String requestStr){
  if (StringUtils.isBlank(requestStr)) {
    denySong(sender,"String_Node_Str");
    return;
  }
  int startSeconds=extractStartSecondsFromTimeParam(requestStr);
  String url=requestStr;
  if (!requestStr.startsWith("String_Node_Str")) {
    url="String_Node_Str" + url;
  }
  doSoundcloudRequest(sender,url,startSeconds);
}

Fixed version (ground truth):
public synchronized void irc_soundcloud(String sender,String requestStr){
  if (StringUtils.isBlank(requestStr)) {
    denySong(sender,"String_Node_Str");
    return;
  }
  int startSeconds=extractStartSecondsFromTimeParam(requestStr);
  String url=requestStr;
  if (requestStr.trim().charAt(0) == '/')   requestStr=requestStr.replaceFirst("String_Node_Str","String_Node_Str");
  if (!requestStr.startsWith("String_Node_Str")) {
    url="String_Node_Str" + url;
  }
  doSoundcloudRequest(sender,url,startSeconds);
}
Program: 88929
Project: 88929
Buggy source:
public void setChannel(String channel){
  if (channel.startsWith("String_Node_Str")) {
    this.channel=channel.substring(1);
  }
 else {
    this.channel=channel;
  }
}

Fixed version (ground truth):
public void setChannel(String channel){
  if (channel.startsWith("String_Node_Str")) {
    this.channel=channel.substring(1);
  }
 else {
    this.channel=channel;
  }
  this.channel=this.channel.toLowerCase(Locale.US);
}
Program: 88931
Project: 88931
Buggy source:
private String determineDropboxLink(DjConfiguration conf){
  DbxClient client=getDbxClient();
  try {
    String url=client.createShareableUrl(dboxFilePath);
    return url.replace("String_Node_Str","String_Node_Str");
  }
 catch (  DbxException e) {
    logger.error("String_Node_Str",e);
    return null;
  }
}

Fixed version (ground truth):
private String determineDropboxLink(DjConfiguration conf){
  DbxClient client=getDbxClient();
  try {
    String url=client.createShareableUrl(dboxFilePath);
    if (url == null) {
      return url;
    }
    return url.replace("String_Node_Str","String_Node_Str");
  }
 catch (  DbxException e) {
    logger.error("String_Node_Str",e);
    return null;
  }
}
Program: 88932
Project: 88932
Buggy source:
private boolean countryIsAllowed(JSONObject contentDetails){
  JSONObject regionRestriction=contentDetails.optJSONObject("String_Node_Str");
  if (regionRestriction != null) {
    JSONArray allowed=regionRestriction.optJSONArray("String_Node_Str");
    if (allowed != null) {
      boolean weAreAllowed=false;
      for (int i=0; i < allowed.length(); ++i) {
        String country=allowed.getString(i);
        if (country.equalsIgnoreCase(conf.getUserCountryCode())) {
          weAreAllowed=true;
        }
      }
      if (!weAreAllowed) {
        return false;
      }
    }
    JSONArray blocked=contentDetails.optJSONArray("String_Node_Str");
    if (blocked != null) {
      for (int i=0; i < blocked.length(); ++i) {
        String country=blocked.getString(i);
        if (country.equalsIgnoreCase(conf.getUserCountryCode())) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean countryIsAllowed(JSONObject contentDetails){
  JSONObject regionRestriction=contentDetails.optJSONObject("String_Node_Str");
  if (regionRestriction != null) {
    JSONArray allowed=regionRestriction.optJSONArray("String_Node_Str");
    if (allowed != null) {
      boolean weAreAllowed=false;
      for (int i=0; i < allowed.length(); ++i) {
        String country=allowed.getString(i);
        if (country.equalsIgnoreCase(conf.getUserCountryCode())) {
          weAreAllowed=true;
        }
      }
      if (!weAreAllowed) {
        return false;
      }
    }
    JSONArray blocked=regionRestriction.optJSONArray("String_Node_Str");
    if (blocked != null) {
      for (int i=0; i < blocked.length(); ++i) {
        String country=blocked.getString(i);
        if (country.equalsIgnoreCase(conf.getUserCountryCode())) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 88933
Project: 88933
Buggy source:
public SongEntry nextSong(){
  updateSongLists();
  boolean playingSecondary=false;
  SongEntry song;
  if (songList.size() == 0) {
    if (secondarySongList.size() == 0) {
      return null;
    }
    song=secondarySongList.remove(0);
    playingSecondary=true;
    System.out.println("String_Node_Str" + song.getTitle() + "String_Node_Str");
  }
 else {
    song=songList.remove(0);
  }
  String secondaryReport="String_Node_Str";
  if (playingSecondary) {
    secondaryReport="String_Node_Str";
  }
  sendMessage(channel,"String_Node_Str" + song.getTitle() + "String_Node_Str"+ song.getUser()+ secondaryReport);
  return song;
}

Fixed version (ground truth):
public SongEntry nextSong(){
  updateQueuesForLeavers();
  boolean playingSecondary=false;
  SongEntry song;
  if (songList.size() == 0) {
    if (secondarySongList.size() == 0) {
      return null;
    }
    song=secondarySongList.remove(0);
    playingSecondary=true;
    System.out.println("String_Node_Str" + song.getTitle() + "String_Node_Str");
  }
 else {
    song=songList.remove(0);
  }
  String secondaryReport="String_Node_Str";
  if (playingSecondary) {
    secondaryReport="String_Node_Str";
  }
  sendMessage(channel,"String_Node_Str" + song.getTitle() + "String_Node_Str"+ song.getUser()+ secondaryReport);
  currentSong=song;
  try {
    updatePlayedSongsFile();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return song;
}
Program: 88935
Project: 88935
Buggy source:
/** 
 * Greets Rocket.  Requires a connected socket, otherwise throws.
 */
private void greetServer() throws Exception {
  logger.finer("String_Node_Str");
  out.writeBytes(CLIENT_GREET);
  logger.finer("String_Node_Str");
  byte greet[]=new byte[SERVER_GREET.length()];
  try {
    in.readFully(greet,0,SERVER_GREET.length());
  }
 catch (  Exception e) {
    logger.severe("String_Node_Str");
    throw new Exception("String_Node_Str");
  }
  logger.finer("String_Node_Str");
  if (!SERVER_GREET.equals(new String(greet))) {
    logger.severe("String_Node_Str");
    throw new Exception("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Greets Rocket.  Requires a connected socket, otherwise throws.
 */
private void greetServer() throws Exception {
  logger.finer("String_Node_Str");
  out.writeBytes(CLIENT_GREET);
  logger.finer("String_Node_Str");
  byte greet[]=new byte[SERVER_GREET.length()];
  try {
    in.readFully(greet,0,SERVER_GREET.length());
  }
 catch (  Exception e) {
    logger.severe("String_Node_Str" + e);
    throw new Exception("String_Node_Str",e);
  }
  logger.finer("String_Node_Str");
  if (!SERVER_GREET.equals(new String(greet))) {
    logger.severe("String_Node_Str");
    throw new Exception("String_Node_Str");
  }
}
Program: 88936
Project: 88936
Buggy source:
public SocketConnector(Logger logger,TrackContainer tracks,Controller controller,String host,int port) throws Exception {
  super(logger,tracks,controller);
  logger.fine(String.format("String_Node_Str",host,port));
  try {
    initSocket(host,port);
    greetServer();
  }
 catch (  Exception e) {
    logger.warning("String_Node_Str");
    close();
    throw e;
  }
  logger.info(String.format("String_Node_Str",host,port));
}

Fixed version (ground truth):
public SocketConnector(Logger logger,TrackContainer tracks,Controller controller,String host,int port) throws Exception {
  super(logger,tracks,controller);
  logger.fine(String.format("String_Node_Str",host,port));
  int triesAmount=10;
  for (int i=0; i < triesAmount; i++) {
    try {
      initSocket(host,port);
      greetServer();
      break;
    }
 catch (    Exception e) {
      if (i < triesAmount - 1) {
        logger.warning("String_Node_Str");
        if (socket != null)         socket.close();
      }
 else {
        logger.warning("String_Node_Str");
        close();
        throw e;
      }
    }
  }
  logger.info(String.format("String_Node_Str",host,port));
}
Program: 88937
Project: 88937
Buggy source:
public void update(){
  controller.update();
  connector.update();
}

Fixed version (ground truth):
public void update(){
  if (controller != null && connector != null) {
    controller.update();
    connector.update();
  }
}
Program: 88938
Project: 88938
Buggy source:
/** 
 * Inserts new TrackKey or updates an existing one. If row matches, the old key is replaced.
 */
protected void addOrUpdateKey(TrackKey key){
  int row=key.getRow();
  int index=getKeyIndex(row);
  if (index > 0 && keys.get(index).getRow() == row) {
    keys.set(index,key);
  }
 else {
    this.keys.add(key);
    Collections.sort(keys);
  }
}

Fixed version (ground truth):
/** 
 * Inserts new TrackKey or updates an existing one. If row matches, the old key is replaced.
 */
protected void addOrUpdateKey(TrackKey key){
  int row=key.getRow();
  int index=getKeyIndex(row);
  if (index >= 0 && keys.get(index).getRow() == row) {
    keys.set(index,key);
  }
 else {
    this.keys.add(key);
    Collections.sort(keys);
  }
}
Program: 88939
Project: 88939
Buggy source:
/** 
 * @param processId the process <strong>Definition</strong> Id - NOT the process Instance Id.
 * @return png image of diagram - nothing highlighted since this is the process definition - not a specific instance.
 */
public byte[] getProcessDefinitionDiagram(String processId) throws IOException {
  ProcessDefinition pd=this.repoSrvc.createProcessDefinitionQuery().processDefinitionKey(processId).latestVersion().singleResult();
  LOG.debug("String_Node_Str",pd.getId());
  InputStream in=this.appContext.getResource("String_Node_Str").getInputStream();
  byte[] bytes=IOUtils.toByteArray(in);
  IOUtils.closeQuietly(in);
  LOG.debug("String_Node_Str",bytes.length);
  return bytes;
}

Fixed version (ground truth):
/** 
 * @param processId the process <strong>Definition</strong> Id - NOT the process Instance Id.
 * @return png image of diagram - nothing highlighted since this is the process definition - not a specific instance.
 */
public byte[] getProcessDefinitionDiagram(String processId) throws IOException {
  ProcessDefinition pd=this.repoSrvc.createProcessDefinitionQuery().processDefinitionKey(processId).latestVersion().singleResult();
  LOG.debug("String_Node_Str",pd.getId());
  BpmnModel bpmnModel=repoSrvc.getBpmnModel(pd.getId());
  new BpmnAutoLayout(bpmnModel).execute();
  InputStream in=new DefaultProcessDiagramGenerator().generatePngDiagram(bpmnModel);
  byte[] bytes=IOUtils.toByteArray(in);
  IOUtils.closeQuietly(in);
  LOG.debug("String_Node_Str",bytes.length);
  return bytes;
}
Program: 88941
Project: 88941
Buggy source:
/** 
 * Complete an approval task
 * @param approved
 * @param comment
 * @param taskId
 */
public void approveOrRejectDoc(boolean approved,String comment,String taskId){
  LOG.debug("String_Node_Str" + approved);
  UserDetails userDetails=userService.currentUser();
  try {
    identityService.setAuthenticatedUserId(userDetails.getUsername());
    Task task=taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult();
    if (task == null) {
      throw new RuntimeException("String_Node_Str");
    }
    Map<String,Object> vars=task.getProcessVariables();
    if (StringUtils.equalsIgnoreCase((String)vars.get("String_Node_Str"),userDetails.getUsername())) {
      throw new RuntimeException("String_Node_Str");
    }
    runtimeService.setVariable(task.getExecutionId(),WFConstants.PROCESS_VAR_APPROVED_OR_REJECTED,approved);
    taskService.setAssignee(task.getId(),userDetails.getUsername());
    taskService.addComment(task.getId(),task.getProcessInstanceId(),comment);
    taskService.setVariableLocal(task.getId(),WFConstants.TASK_VAR_APPROVED_OR_REJECTED,Boolean.valueOf(approved));
    taskService.complete(task.getId());
  }
  finally {
    identityService.setAuthenticatedUserId(null);
  }
}

Fixed version (ground truth):
/** 
 * Complete an approval task
 * @param approved
 * @param comment
 * @param taskId
 */
public void approveOrRejectDoc(boolean approved,String comment,String taskId){
  LOG.debug("String_Node_Str" + approved);
  UserDetails userDetails=userService.currentUser();
  try {
    identityService.setAuthenticatedUserId(userDetails.getUsername());
    Task task=taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult();
    if (task == null) {
      throw new RuntimeException("String_Node_Str");
    }
    Map<String,Object> vars=task.getProcessVariables();
    if (StringUtils.equalsIgnoreCase((String)vars.get("String_Node_Str"),userDetails.getUsername())) {
      throw new RuntimeException("String_Node_Str");
    }
    runtimeService.setVariable(task.getExecutionId(),WFConstants.PROCESS_VAR_APPROVED_OR_REJECTED,approved);
    taskService.setAssignee(task.getId(),userDetails.getUsername());
    taskService.addComment(task.getId(),task.getProcessInstanceId(),comment);
    taskService.setVariableLocal(task.getId(),WFConstants.TASK_VAR_OUTCOME,approved ? "String_Node_Str" : "String_Node_Str");
    taskService.complete(task.getId());
  }
  finally {
    identityService.setAuthenticatedUserId(null);
  }
}
Program: 88942
Project: 88942
Buggy source:
/** 
 * Complete a collaboration task
 * @param taskId
 * @param comment
 */
public void collaborateTask(String taskId,String comment){
  LOG.debug("String_Node_Str");
  UserDetails userDetails=userService.currentUser();
  try {
    identityService.setAuthenticatedUserId(userDetails.getUsername());
    Task task=taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult();
    if (task == null) {
      throw new RuntimeException("String_Node_Str");
    }
    taskService.setAssignee(task.getId(),userDetails.getUsername());
    taskService.addComment(task.getId(),task.getProcessInstanceId(),comment);
    taskService.complete(task.getId());
  }
  finally {
    identityService.setAuthenticatedUserId(null);
  }
}

Fixed version (ground truth):
/** 
 * Complete a collaboration task
 * @param taskId
 * @param comment
 */
public void collaborateTask(String taskId,String comment){
  LOG.debug("String_Node_Str");
  UserDetails userDetails=userService.currentUser();
  try {
    identityService.setAuthenticatedUserId(userDetails.getUsername());
    Task task=taskService.createTaskQuery().taskId(taskId).includeProcessVariables().singleResult();
    if (task == null) {
      throw new RuntimeException("String_Node_Str");
    }
    taskService.setAssignee(task.getId(),userDetails.getUsername());
    taskService.addComment(task.getId(),task.getProcessInstanceId(),comment);
    taskService.setVariableLocal(task.getId(),WFConstants.TASK_VAR_OUTCOME,"String_Node_Str");
    taskService.complete(task.getId());
  }
  finally {
    identityService.setAuthenticatedUserId(null);
  }
}
Program: 88943
Project: 88943
Buggy source:
protected void initDemoUsers(){
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Arrays.asList("String_Node_Str","String_Node_Str"),null);
}

Fixed version (ground truth):
protected void initDemoUsers(){
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str"),null);
  createUser("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",null,Arrays.asList("String_Node_Str","String_Node_Str"),null);
}
Program: 88944
Project: 88944
Buggy source:
protected void initDemoGroups(){
  String[] assignmentGroups=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (  String groupId : assignmentGroups) {
    createGroup(groupId,"String_Node_Str");
  }
  String[] securityGroups=new String[]{"String_Node_Str","String_Node_Str"};
  for (  String groupId : securityGroups) {
    createGroup(groupId,"String_Node_Str");
  }
}

Fixed version (ground truth):
protected void initDemoGroups(){
  String[] assignmentGroups=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (  String groupId : assignmentGroups) {
    createGroup(groupId,"String_Node_Str");
  }
  String[] securityGroups=new String[]{"String_Node_Str","String_Node_Str"};
  for (  String groupId : securityGroups) {
    createGroup(groupId,"String_Node_Str");
  }
}
Program: 88945
Project: 88945
Buggy source:
protected static SequenceFlow collaborationTask(SubProcess subProcess,DynamicUserTask from,int currentIdx,int total,SequenceFlow prev){
  org.activiti.bpmn.model.UserTask current=new org.activiti.bpmn.model.UserTask();
  current.setId(String.format("String_Node_Str",WFConstants.TASK_ID_DOC_COLLABORATE,currentIdx));
  if (StringUtils.isBlank(from.getName())) {
    current.setName(String.format("String_Node_Str",currentIdx,total));
  }
 else {
    current.setName(from.getName());
  }
  ActivitiListener onCreate=new ActivitiListener();
  onCreate.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  onCreate.setImplementation("String_Node_Str");
  onCreate.setEvent("String_Node_Str");
  ActivitiListener onComplete=new ActivitiListener();
  onComplete.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  onComplete.setImplementation("String_Node_Str");
  onComplete.setEvent("String_Node_Str");
  current.setTaskListeners(Lists.newArrayList(onCreate,onComplete));
  subProcess.addFlowElement(current);
  prev.setTargetRef(current.getId());
  SequenceFlow ref=new SequenceFlow();
  ref.setId(String.format("String_Node_Str",currentIdx,total));
  ref.setName(String.format("String_Node_Str",currentIdx,total));
  ref.setSourceRef(current.getId());
  return ref;
}

Fixed version (ground truth):
protected static SequenceFlow collaborationTask(SubProcess subProcess,DynamicUserTask from,int currentIdx,int total,SequenceFlow prev){
  org.activiti.bpmn.model.UserTask current=new org.activiti.bpmn.model.UserTask();
  current.setId(String.format("String_Node_Str",WFConstants.TASK_ID_DOC_COLLABORATE,currentIdx));
  if (StringUtils.isBlank(from.getName())) {
    current.setName(String.format("String_Node_Str",currentIdx,total));
  }
 else {
    current.setName(from.getName());
  }
  ActivitiListener onCreate=new ActivitiListener();
  onCreate.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  onCreate.setImplementation("String_Node_Str");
  onCreate.setEvent("String_Node_Str");
  ActivitiListener onComplete=new ActivitiListener();
  onComplete.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  onComplete.setImplementation("String_Node_Str");
  onComplete.setEvent("String_Node_Str");
  current.setTaskListeners(Lists.newArrayList(onCreate,onComplete));
  subProcess.addFlowElement(current);
  prev.setTargetRef(current.getId());
  SequenceFlow ref=new SequenceFlow();
  ref.setId(String.format("String_Node_Str",currentIdx,total));
  ref.setName(String.format("String_Node_Str",currentIdx,total));
  ref.setSourceRef(current.getId());
  subProcess.addFlowElement(ref);
  return ref;
}