nus-yam/ex-repair huggingface dataset:
Program: 143932
Project: 143932
Buggy source:
/** 
 * Read data from the remote host. Blocks until data is available.  Returns an array of bytes that will be displayed.
 */
synchronized public byte[] handleSSH(byte[] b) throws IOException {
  byte[] rest=null;
  while (lastPacketReceived != null && lastPacketReceived.toBeFinished) {
    byte[] buff=lastPacketReceived.unfinishedBuffer;
    int start=lastPacketReceived.positionInUnfinishedBuffer;
    if (buff != null) {
      byte[] result=packetDone(handleBytes(buff,start,buff.length));
      if (rest != null) {
        if (result != null) {
          byte[] tmp=new byte[rest.length + result.length];
          System.arraycopy(rest,0,tmp,0,rest.length);
          System.arraycopy(result,0,tmp,rest.length,result.length);
          rest=tmp;
        }
      }
 else       rest=result;
    }
  }
  byte[] result=packetDone(handleBytes(b,0,b.length));
  if (rest != null)   if (result != null) {
    byte[] cat=new byte[rest.length + result.length];
    System.arraycopy(rest,0,cat,0,rest.length);
    System.arraycopy(result,0,cat,rest.length,result.length);
    return cat;
  }
 else   return rest;
  return result;
}

Fixed version (ground truth):
/** 
 * Read data from the remote host. Blocks until data is available.  Returns an array of bytes that will be displayed.
 */
synchronized public byte[] handleSSH(byte[] b) throws IOException {
  byte[] result=packetDone(handleBytes(b,0,b.length));
  while (lastPacketReceived != null && lastPacketReceived.toBeFinished) {
    byte[] buff=lastPacketReceived.unfinishedBuffer;
    int start=lastPacketReceived.positionInUnfinishedBuffer;
    if (buff != null) {
      byte[] rest=packetDone(handleBytes(buff,start,buff.length));
      if (rest != null) {
        if (result != null) {
          byte[] tmp=new byte[rest.length + result.length];
          System.arraycopy(result,0,tmp,0,result.length);
          System.arraycopy(rest,0,tmp,result.length,rest.length);
          result=tmp;
        }
 else         result=rest;
      }
    }
  }
  return result;
}
Program: 143934
Project: 143934
Buggy source:
/** 
 * Create a new scripting plugin.
 */
public Script(PluginBus bus,final String id){
  super(bus,id);
  bus.registerPluginListener(new SocketListener(){
    public void connect(    String host,    int port){
      setup(savedScript);
    }
    public void disconnect(){
    }
  }
);
  bus.registerPluginListener(new ConfigurationListener(){
    public void setConfiguration(    PluginConfig config){
      savedScript=new Vector();
      String s=config.getProperty("String_Node_Str",id,"String_Node_Str");
      if (s != null) {
        if (s.charAt(0) == '@') {
          Script.this.error("String_Node_Str");
        }
        if (debug > 0)         Script.this.error(s);
        String pair[]=null;
        int old=-1, idx=s.indexOf('|');
        while (idx >= 0) {
          if (pair == null) {
            pair=new String[2];
            pair[0]=s.substring(old + 1,idx);
            if (debug > 0)             System.out.print("String_Node_Str" + pair[0] + "String_Node_Str");
          }
 else {
            pair[1]=s.substring(old + 1,idx) + "String_Node_Str";
            if (debug > 0)             System.out.print(pair[1]);
            savedScript.addElement(pair);
            pair=null;
          }
          old=idx;
          idx=s.indexOf('|',old + 1);
        }
        if (pair != null) {
          pair[1]=s.substring(old + 1) + "String_Node_Str";
          savedScript.addElement(pair);
          if (debug > 0)           System.out.print(pair[1]);
        }
 else         Script.this.error("String_Node_Str");
        setup(savedScript);
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Create a new scripting plugin.
 */
public Script(PluginBus bus,final String id){
  super(bus,id);
  bus.registerPluginListener(new OnlineStatusListener(){
    public void online(){
      setup(savedScript);
    }
    public void offline(){
    }
  }
);
  bus.registerPluginListener(new ConfigurationListener(){
    public void setConfiguration(    PluginConfig config){
      savedScript=new Vector();
      String s=config.getProperty("String_Node_Str",id,"String_Node_Str");
      if (s != null) {
        if (s.charAt(0) == '@') {
          Script.this.error("String_Node_Str");
        }
        if (debug > 0)         Script.this.error(s);
        String pair[]=null;
        int old=-1, idx=s.indexOf('|');
        while (idx >= 0) {
          if (pair == null) {
            pair=new String[2];
            pair[0]=s.substring(old + 1,idx);
            if (debug > 0)             System.out.print("String_Node_Str" + pair[0] + "String_Node_Str");
          }
 else {
            pair[1]=s.substring(old + 1,idx) + "String_Node_Str";
            if (debug > 0)             System.out.print(pair[1]);
            savedScript.addElement(pair);
            pair=null;
          }
          old=idx;
          idx=s.indexOf('|',old + 1);
        }
        if (pair != null) {
          pair[1]=s.substring(old + 1) + "String_Node_Str";
          savedScript.addElement(pair);
          if (debug > 0)           System.out.print(pair[1]);
        }
 else         Script.this.error("String_Node_Str");
      }
    }
  }
);
}
Program: 143935
Project: 143935
Buggy source:
/** 
 * Try to match the byte array s against the most current script match. It will write the answer immediatly  if the script matches and will return instantly when all the script work is done.
 * @param s the array of bytes to match against
 * @param length the amount of bytes in the array
 */
private void match(byte[] s,int length) throws IOException {
  for (int i=0; !done && i < length; i++) {
    if (s[i] == match[matchPos])     if (++matchPos >= match.length)     write(found());
 else     reset();
  }
}

Fixed version (ground truth):
/** 
 * Try to match the byte array s against the most current script match. It will write the answer immediatly  if the script matches and will return instantly when all the script work is done.
 * @param s the array of bytes to match against
 * @param length the amount of bytes in the array
 */
private void match(byte[] s,int length) throws IOException {
  for (int i=0; !done && i < length; i++) {
    if (s[i] == match[matchPos]) {
      if (++matchPos >= match.length)       write(found());
    }
 else     reset();
  }
}
Program: 143936
Project: 143936
Buggy source:
public void setConfiguration(PluginConfig config){
  savedScript=new Vector();
  String s=config.getProperty("String_Node_Str",id,"String_Node_Str");
  if (s != null) {
    if (s.charAt(0) == '@') {
      Script.this.error("String_Node_Str");
    }
    if (debug > 0)     Script.this.error(s);
    String pair[]=null;
    int old=-1, idx=s.indexOf('|');
    while (idx >= 0) {
      if (pair == null) {
        pair=new String[2];
        pair[0]=s.substring(old + 1,idx);
        if (debug > 0)         System.out.print("String_Node_Str" + pair[0] + "String_Node_Str");
      }
 else {
        pair[1]=s.substring(old + 1,idx) + "String_Node_Str";
        if (debug > 0)         System.out.print(pair[1]);
        savedScript.addElement(pair);
        pair=null;
      }
      old=idx;
      idx=s.indexOf('|',old + 1);
    }
    if (pair != null) {
      pair[1]=s.substring(old + 1) + "String_Node_Str";
      savedScript.addElement(pair);
      if (debug > 0)       System.out.print(pair[1]);
    }
 else     Script.this.error("String_Node_Str");
    setup(savedScript);
  }
}

Fixed version (ground truth):
public void setConfiguration(PluginConfig config){
  savedScript=new Vector();
  String s=config.getProperty("String_Node_Str",id,"String_Node_Str");
  if (s != null) {
    if (s.charAt(0) == '@') {
      Script.this.error("String_Node_Str");
    }
    if (debug > 0)     Script.this.error(s);
    String pair[]=null;
    int old=-1, idx=s.indexOf('|');
    while (idx >= 0) {
      if (pair == null) {
        pair=new String[2];
        pair[0]=s.substring(old + 1,idx);
        if (debug > 0)         System.out.print("String_Node_Str" + pair[0] + "String_Node_Str");
      }
 else {
        pair[1]=s.substring(old + 1,idx) + "String_Node_Str";
        if (debug > 0)         System.out.print(pair[1]);
        savedScript.addElement(pair);
        pair=null;
      }
      old=idx;
      idx=s.indexOf('|',old + 1);
    }
    if (pair != null) {
      pair[1]=s.substring(old + 1) + "String_Node_Str";
      savedScript.addElement(pair);
      if (debug > 0)       System.out.print(pair[1]);
    }
 else     Script.this.error("String_Node_Str");
  }
}
Program: 143939
Project: 143939
Buggy source:
/** 
 * Set the current window base. This allows to view the scrollback buffer.
 * @param line the line where the screen window starts
 * @see setBufferSize
 * @see getBufferSize
 */
public void setWindowBase(int line){
  if (line > screenBase)   line=screenBase;
 else   if (line < 0)   line=0;
  windowBase=line;
  repaint();
}

Fixed version (ground truth):
/** 
 * Set the current window base. This allows to view the scrollback buffer.
 * @param line the line where the screen window starts
 * @see setBufferSize
 * @see getBufferSize
 */
public void setWindowBase(int line){
  if (line > screenBase)   line=screenBase;
 else   if (line < 0)   line=0;
  windowBase=line;
  update[0]=true;
  redraw();
}
Program: 143940
Project: 143940
Buggy source:
public void mouseDragged(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    int x=(evt.getX() - xoffset) / charWidth;
    int y=(evt.getY() - yoffset) / charHeight + windowBase;
    int oldx=selectEnd.x, oldy=selectEnd.y;
    if ((x < selectBegin.x && y < selectBegin.y) && (x < selectEnd.x && y < selectEnd.y)) {
      selectBegin.x=x;
      selectBegin.y=y;
    }
 else {
      selectEnd.x=x;
      selectEnd.y=y;
    }
    if (oldx != x || oldy != y)     repaint();
  }
}

Fixed version (ground truth):
public void mouseDragged(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    int x=(evt.getX() - xoffset) / charWidth;
    int y=(evt.getY() - yoffset) / charHeight + windowBase;
    int oldx=selectEnd.x, oldy=selectEnd.y;
    if ((x < selectBegin.x && y < selectBegin.y) && (x < selectEnd.x && y < selectEnd.y)) {
      selectBegin.x=x;
      selectBegin.y=y;
    }
 else {
      selectEnd.x=x;
      selectEnd.y=y;
    }
    if (oldx != x || oldy != y) {
      update[0]=true;
      redraw();
    }
  }
}
Program: 143941
Project: 143941
Buggy source:
/** 
 * Paint the current screen. All painting is done here. Only lines that have changed will be redrawn!
 */
public void paint(Graphics g){
  if (backingStore == null) {
    Dimension size=super.getSize();
    backingStore=createImage(size.width,size.height);
    redraw();
  }
  g.drawImage(backingStore,0,0,this);
}

Fixed version (ground truth):
/** 
 * Paint the current screen. All painting is done here. Only lines that have changed will be redrawn!
 */
public void paint(Graphics g){
  if (backingStore == null) {
    Dimension size=super.getSize();
    backingStore=createImage(size.width,size.height);
    update[0]=true;
    redraw();
  }
  if (debug > 0)   System.err.println("String_Node_Str" + g.getClipBounds());
  g.drawImage(backingStore,0,0,this);
}
Program: 143943
Project: 143943
Buggy source:
/** 
 * Handle mouse released events for copy & paste.
 * @param evt the mouse event
 */
public void mouseReleased(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    mouseDragged(evt);
    if (selectBegin.x == selectEnd.x && selectBegin.y == selectEnd.y) {
      repaint();
      return;
    }
    selection="String_Node_Str";
    if (selectEnd.x < 0)     selectEnd.x=0;
    if (selectEnd.y < 0)     selectEnd.y=0;
    if (selectEnd.y >= charArray.length)     selectEnd.y=charArray.length - 1;
    if (selectEnd.x >= charArray[0].length)     selectEnd.x=charArray[0].length - 1;
    for (int l=selectBegin.y; l <= selectEnd.y; l++) {
      int start, end;
      start=(l == selectBegin.y ? start=selectBegin.x : 0);
      end=(l == selectEnd.y ? end=selectEnd.x : charArray[l].length - 1);
      selection+=(new String(charArray[l])).substring(start,end);
      if (end == charArray[l].length - 1)       selection+="String_Node_Str";
    }
  }
}

Fixed version (ground truth):
/** 
 * Handle mouse released events for copy & paste.
 * @param evt the mouse event
 */
public void mouseReleased(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    mouseDragged(evt);
    if (selectBegin.x == selectEnd.x && selectBegin.y == selectEnd.y) {
      update[0]=true;
      redraw();
      return;
    }
    selection="String_Node_Str";
    if (selectEnd.x < 0)     selectEnd.x=0;
    if (selectEnd.y < 0)     selectEnd.y=0;
    if (selectEnd.y >= charArray.length)     selectEnd.y=charArray.length - 1;
    if (selectEnd.x >= charArray[0].length)     selectEnd.x=charArray[0].length - 1;
    for (int l=selectBegin.y; l <= selectEnd.y; l++) {
      int start, end;
      start=(l == selectBegin.y ? start=selectBegin.x : 0);
      end=(l == selectEnd.y ? end=selectEnd.x : charArray[l].length - 1);
      selection+=(new String(charArray[l])).substring(start,end);
      if (end == charArray[l].length - 1)       selection+="String_Node_Str";
    }
  }
}
Program: 143944
Project: 143944
Buggy source:
/** 
 * Set scrollback buffer size.
 * @param amount new size of the buffer
 */
public void setBufferSize(int amount){
  screenLocked=true;
  if (amount < size.height)   amount=size.height;
  if (amount < maxBufSize) {
    char cbuf[][]=new char[amount][size.width];
    int abuf[][]=new int[amount][size.width];
    if (charArray != null)     System.arraycopy(charArray,bufSize - amount,cbuf,0,amount);
    if (charAttributes != null)     System.arraycopy(charAttributes,bufSize - amount,abuf,0,amount);
    charArray=cbuf;
    charAttributes=abuf;
  }
  maxBufSize=amount;
  screenLocked=false;
  repaint();
}

Fixed version (ground truth):
/** 
 * Set scrollback buffer size.
 * @param amount new size of the buffer
 */
public void setBufferSize(int amount){
  screenLocked=true;
  if (amount < size.height)   amount=size.height;
  if (amount < maxBufSize) {
    char cbuf[][]=new char[amount][size.width];
    int abuf[][]=new int[amount][size.width];
    int copyStart=bufSize - amount < 0 ? 0 : bufSize - amount;
    int copyCount=bufSize - amount < 0 ? bufSize : amount;
    if (charArray != null)     System.arraycopy(charArray,copyStart,cbuf,0,copyCount);
    if (charAttributes != null)     System.arraycopy(charAttributes,copyStart,abuf,0,copyCount);
    charArray=cbuf;
    charAttributes=abuf;
    bufSize=copyCount;
    screenBase=bufSize - size.height;
    windowBase=screenBase;
  }
  maxBufSize=amount;
  screenLocked=false;
  update[0]=true;
  redraw();
}
Program: 143948
Project: 143948
Buggy source:
/** 
 * Change the size of the screen. This will include adjustment of the  scrollback buffer.
 * @param columns width of the screen
 * @param columns height of the screen
 */
public void setScreenSize(int width,int height){
  char cbuf[][];
  int abuf[][];
  int bsize=bufSize;
  if (width < 1 || height < 1)   return;
  if (debug > 0)   System.err.println("String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str");
  screenLocked=true;
  if (height > maxBufSize)   maxBufSize=height;
  if (height > bufSize) {
    bufSize=height;
    screenBase=0;
    windowBase=0;
  }
  cbuf=new char[bufSize][width];
  abuf=new int[bufSize][width];
  if (charArray != null && charAttributes != null)   for (int i=0; i < bsize && i < bufSize; i++) {
    System.arraycopy(charArray[i],0,cbuf[i],0,width < size.width ? width : size.width);
    System.arraycopy(charAttributes[i],0,abuf[i],0,width < size.width ? width : size.width);
  }
  charArray=cbuf;
  charAttributes=abuf;
  size=new Dimension(width,height);
  topMargin=0;
  bottomMargin=height - 1;
  update=new boolean[height + 1];
  for (int i=0; i <= height; i++)   update[i]=true;
  screenLocked=false;
}

Fixed version (ground truth):
/** 
 * Change the size of the screen. This will include adjustment of the  scrollback buffer.
 * @param columns width of the screen
 * @param columns height of the screen
 */
public void setScreenSize(int width,int height){
  char cbuf[][];
  int abuf[][];
  int bsize=bufSize;
  if (width < 1 || height < 1)   return;
  if (debug > 0)   System.err.println("String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str");
  screenLocked=true;
  if (height > maxBufSize)   maxBufSize=height;
  if (height > bufSize) {
    bufSize=height;
    screenBase=0;
    windowBase=0;
  }
  cbuf=new char[bufSize][width];
  abuf=new int[bufSize][width];
  if (charArray != null && charAttributes != null)   for (int i=0; i < bsize && i < bufSize; i++) {
    System.arraycopy(charArray[i],0,cbuf[i],0,width < size.width ? width : size.width);
    System.arraycopy(charAttributes[i],0,abuf[i],0,width < size.width ? width : size.width);
  }
  charArray=cbuf;
  charAttributes=abuf;
  size=new Dimension(width,height);
  topMargin=0;
  bottomMargin=height - 1;
  update=new int[height + 1];
  for (int i=0; i <= height; i++)   update[i]=1;
  screenLocked=false;
}
Program: 143949
Project: 143949
Buggy source:
/** 
 * Redraw marked lines.
 * @see #markLine
 */
public void redraw(){
  update[0]=true;
  repaint();
}

Fixed version (ground truth):
/** 
 * Redraw marked lines.
 * @see #markLine
 */
public void redraw(){
  update[0]+=2;
  repaint();
}
Program: 143950
Project: 143950
Buggy source:
/** 
 * Mark lines to be updated with redraw().
 * @param l starting line
 * @param n amount of lines to be updated
 * @see #redraw
 */
public void markLine(int l,int n){
  l=checkBounds(l,0,size.height - 1);
  for (int i=0; i < n && l + i < size.height; i++)   update[l + i + 1]=true;
}

Fixed version (ground truth):
/** 
 * Mark lines to be updated with redraw().
 * @param l starting line
 * @param n amount of lines to be updated
 * @see #redraw
 */
public void markLine(int l,int n){
  l=checkBounds(l,0,size.height - 1);
  for (int i=0; (i < n) && (l + i < size.height); i++)   update[l + i + 1]=1;
}
Program: 143951
Project: 143951
Buggy source:
public void print(Graphics g){
  for (int i=0; i <= size.height; i++)   update[i]=true;
  paint(g);
}

Fixed version (ground truth):
public void print(Graphics g){
  for (int i=0; i <= size.height; i++)   update[i]=1;
  paint(g);
}
Program: 143953
Project: 143953
Buggy source:
/** 
 * Split up comma separated lists of strings. This is quite strict, no whitespace characters are allowed.
 * @param s the string to be split up
 * @return an array of strings
 */
private static Vector split(String s){
  Vector v=new Vector();
  int old=-1, idx=s.indexOf(',');
  while (idx >= 0) {
    v.addElement(s.substring(old + 1,idx));
    old=idx;
    idx=s.indexOf(',',old + 1);
  }
  v.addElement(s.substring(old + 1));
  return v;
}

Fixed version (ground truth):
/** 
 * Split up comma separated lists of strings. This is quite strict, no whitespace characters are allowed.
 * @param s the string to be split up
 * @return an array of strings
 */
private static Vector split(String s){
  if (s == null)   return null;
  Vector v=new Vector();
  int old=-1, idx=s.indexOf(',');
  while (idx >= 0) {
    v.addElement(s.substring(old + 1,idx));
    old=idx;
    idx=s.indexOf(',',old + 1);
  }
  v.addElement(s.substring(old + 1));
  return v;
}
Program: 143954
Project: 143954
Buggy source:
public Common(Properties config){
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + "String_Node_Str");
  plugins=new Hashtable();
  components=new Hashtable();
  menus=new Hashtable();
  Vector names=split(config.getProperty("String_Node_Str"));
  Enumeration e=names.elements();
  while (e.hasMoreElements()) {
    String name=(String)e.nextElement();
    System.out.println("String_Node_Str" + name + "String_Node_Str");
    Plugin plugin=addPlugin(name);
    if (plugin instanceof VisualPlugin) {
      Component c=((VisualPlugin)plugin).getPluginVisual();
      if (c != null)       components.put(name,c);
      Menu menu=((VisualPlugin)plugin).getPluginMenu();
      if (menu != null)       menus.put(name,menu);
    }
  }
  broadcast(new ConfigurationRequest(config));
}

Fixed version (ground truth):
public Common(Properties config){
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str" + "String_Node_Str");
  plugins=new Hashtable();
  components=new Hashtable();
  menus=new Hashtable();
  Vector names=split(config.getProperty("String_Node_Str"));
  if (names == null) {
    System.err.println("String_Node_Str");
    return;
  }
  Enumeration e=names.elements();
  while (e.hasMoreElements()) {
    String name=(String)e.nextElement();
    System.out.println("String_Node_Str" + name + "String_Node_Str");
    Plugin plugin=addPlugin(name);
    if (plugin instanceof VisualPlugin) {
      Component c=((VisualPlugin)plugin).getPluginVisual();
      if (c != null)       components.put(name,c);
      Menu menu=((VisualPlugin)plugin).getPluginMenu();
      if (menu != null)       menus.put(name,menu);
    }
  }
  broadcast(new ConfigurationRequest(config));
}
Program: 143955
Project: 143955
Buggy source:
public void mouseReleased(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    mouseDragged(evt);
    if (selectBegin.x == selectEnd.x && selectBegin.y == selectEnd.y) {
      repaint();
      return;
    }
    selection="String_Node_Str";
    if (selectEnd.x < 0)     selectEnd.x=0;
    if (selectEnd.y < 0)     selectEnd.y=0;
    if (selectEnd.y >= charArray.length)     selectEnd.y=charArray.length - 1;
    if (selectEnd.x >= charArray[0].length)     selectEnd.x=charArray[0].length - 1;
    for (int l=selectBegin.y; l <= selectEnd.y; l++) {
      int start, end;
      start=(l == selectBegin.y ? start=selectBegin.x : 0);
      end=(l == selectEnd.y ? end=selectEnd.x : charArray.length - 1);
      selection+=(new String(charArray[l])).substring(start,end);
      if (end == charArray.length - 1)       selection+="String_Node_Str";
    }
    repaint();
  }
}

Fixed version (ground truth):
public void mouseReleased(MouseEvent evt){
  if (buttonCheck(evt.getModifiers(),MouseEvent.BUTTON1_MASK)) {
    int xoffset=(super.getSize().width - size.width * charWidth) / 2;
    int yoffset=(super.getSize().height - size.height * charHeight) / 2;
    mouseDragged(evt);
    if (selectBegin.x == selectEnd.x && selectBegin.y == selectEnd.y) {
      repaint();
      return;
    }
    selection="String_Node_Str";
    if (selectEnd.x < 0)     selectEnd.x=0;
    if (selectEnd.y < 0)     selectEnd.y=0;
    if (selectEnd.y >= charArray.length)     selectEnd.y=charArray.length - 1;
    if (selectEnd.x >= charArray[0].length)     selectEnd.x=charArray[0].length - 1;
    for (int l=selectBegin.y; l <= selectEnd.y; l++) {
      int start, end;
      start=(l == selectBegin.y ? start=selectBegin.x : 0);
      end=(l == selectEnd.y ? end=selectEnd.x : charArray[l].length - 1);
      selection+=(new String(charArray[l])).substring(start,end);
      if (end == charArray[l].length - 1)       selection+="String_Node_Str";
    }
    repaint();
  }
}
Program: 143956
Project: 143956
Buggy source:
public void actionPerformed(ActionEvent evt){
  Dialog d=new Dialog(frame,"String_Node_Str",true);
  d.add(new Label("String_Node_Str" + "String_Node_Str"));
  d.setResizable(false);
  d.pack();
  d.show();
}

Fixed version (ground truth):
public void actionPerformed(ActionEvent evt){
  d.dispose();
}
Program: 143959
Project: 143959
Buggy source:
/** 
 * Not used.
 */
public void keyTyped(KeyEvent evt){
  boolean control=evt.isControlDown();
  boolean shift=evt.isShiftDown();
  boolean alt=evt.isAltDown();
  int keyCode=evt.getKeyCode();
  char keyChar=evt.getKeyChar();
  if (shift && (keyChar == '\t'))   write(KeyBacktab);
 else   if (alt)   write("String_Node_Str" + ((char)(keyChar | 0x80)));
 else   if (capslock && !shift)   write(("String_Node_Str" + keyChar).toUpperCase());
 else   write("String_Node_Str" + keyChar);
}

Fixed version (ground truth):
/** 
 * Not used.
 */
public void keyTyped(KeyEvent evt){
  boolean control=evt.isControlDown();
  boolean shift=evt.isShiftDown();
  boolean alt=evt.isAltDown();
  int keyCode=evt.getKeyCode();
  char keyChar=evt.getKeyChar();
  if (shift && (keyChar == '\t'))   write(KeyBacktab);
 else   if (alt)   write("String_Node_Str" + ((char)(keyChar | 0x80)));
 else   if (capslock && !shift)   write(("String_Node_Str" + keyChar).toUpperCase());
 else   if (!(keyChar == '\r' || keyChar == '\n') || control)   write("String_Node_Str" + keyChar);
}
Program: 143961
Project: 143961
Buggy source:
private <T>List<DataInstance<Vector>> shuffledInstances(Map<DataInstance<Vector>,Map<Label,T>> map){
  List<DataInstance<Vector>> instances=new ArrayList<>(map.keySet());
  Collections.shuffle(instances);
  return instances;
}

Fixed version (ground truth):
private <T>List<DataInstance<Vector>> shuffledInstances(Map<DataInstance<Vector>,Map<Label,T>> map){
  List<DataInstance<Vector>> instances=new ArrayList<>(map.keySet());
  Collections.shuffle(instances,new Random(9999));
  return instances;
}
Program: 143968
Project: 143968
Buggy source:
private List<GroundPredicate> solve(ConsensusADMMSolver.Builder solverBuilder){
  for (  Constraint constraint : constraints)   solverBuilder.addConstraint(constraint.constraint,constraint.variableIndexes);
  solver=solverBuilder.subProblemSolver((subProblem) -> solveProbabilisticSoftLogicSubProblem(subProblem,subProblemCholeskyFactors)).maximumNumberOfIterations(5000).checkForPointConvergence(false).checkForObjectiveConvergence(false).checkForGradientConvergence(false).logObjectiveValue(false).logGradientNorm(false).loggingLevel(0).build();
  Vector result=solver.solve();
  this.solverBuilder=solverBuilder.initialPoint(solver.currentPoint);
  List<GroundPredicate> groundPredicates=new ArrayList<>();
  for (int internalId=0; internalId < result.size(); internalId++) {
    GroundPredicate groundPredicate=logicManager.getGroundPredicate(externalToInternalIdsMap.inverse().get(internalId));
    groundPredicate.setValue(result.get(internalId));
    groundPredicates.add(groundPredicate);
  }
  return groundPredicates;
}

Fixed version (ground truth):
private List<GroundPredicate> solve(ConsensusADMMSolver.Builder solverBuilder){
  for (  Constraint constraint : constraints)   solverBuilder.addConstraint(constraint.constraint,constraint.variableIndexes);
  solver=solverBuilder.subProblemSolver((subProblem) -> solveProbabilisticSoftLogicSubProblem(subProblem,subProblemCholeskyFactors)).maximumNumberOfIterations(5000).checkForPointConvergence(false).checkForObjectiveConvergence(false).checkForGradientConvergence(false).logObjectiveValue(false).logGradientNorm(false).loggingLevel(0).build();
  Vector result=objectiveFunction.getNumberOfVariables() > 0 ? solver.solve() : Vectors.dense(0);
  this.solverBuilder=solverBuilder.initialPoint(solver.currentPoint);
  List<GroundPredicate> groundPredicates=new ArrayList<>();
  for (int internalId=0; internalId < result.size(); internalId++) {
    GroundPredicate groundPredicate=logicManager.getGroundPredicate(externalToInternalIdsMap.inverse().get(internalId));
    groundPredicate.setValue(result.get(internalId));
    groundPredicates.add(groundPredicate);
  }
  return groundPredicates;
}
Program: 143971
Project: 143971
Buggy source:
private AbstractBuilder(String predictedDataFilename){
  super(predictedDataFilename);
}

Fixed version (ground truth):
private AbstractBuilder(String predictedDataFilename){
  super(predictedDataFilename);
  extractLabelsSet();
}
Program: 143974
Project: 143974
Buggy source:
private void sampleConfusionMatrix(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++) {
    int currentNumberOfClusters=dpPriors[p].computeClustersDistribution();
    for (int k=0; k < currentNumberOfClusters; k++) {
      int clusterID=dpPriors[p].getClusterID(k);
      confusionMatrixSamples[sampleNumber][p][clusterID][0][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[0][0] + confusionMatrixCounts[p][clusterID][0][0],confusionMatrixPrior[0][1] + confusionMatrixCounts[p][clusterID][0][1]);
      confusionMatrixSamples[sampleNumber][p][clusterID][1][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[1][0] + confusionMatrixCounts[p][clusterID][1][0],confusionMatrixPrior[1][1] + confusionMatrixCounts[p][clusterID][1][1]);
      confusionMatrixSamples[sampleNumber][p][clusterID][0][1]=1 - confusionMatrixSamples[sampleNumber][p][clusterID][0][0];
      confusionMatrixSamples[sampleNumber][p][clusterID][1][1]=1 - confusionMatrixSamples[sampleNumber][p][clusterID][1][0];
    }
  }
}

Fixed version (ground truth):
private void sampleConfusionMatrix(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++) {
    for (int j=0; j < numberOfFunctions; j++) {
      confusionMatrixSamples[sampleNumber][p][j][0][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[0][0] + confusionMatrixCounts[p][j][0][0],confusionMatrixPrior[0][1] + confusionMatrixCounts[p][j][0][1]);
      confusionMatrixSamples[sampleNumber][p][j][1][0]=randomDataGenerator.nextBeta(confusionMatrixPrior[1][0] + confusionMatrixCounts[p][j][1][0],confusionMatrixPrior[1][1] + confusionMatrixCounts[p][j][1][1]);
      confusionMatrixSamples[sampleNumber][p][j][0][1]=1 - confusionMatrixSamples[sampleNumber][p][j][0][0];
      confusionMatrixSamples[sampleNumber][p][j][1][1]=1 - confusionMatrixSamples[sampleNumber][p][j][1][0];
    }
  }
}
Program: 143975
Project: 143975
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public DenseVector transMult(Matrix matrix){
  if (matrix.getRowDimension() != size) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DenseVector resultVector=new DenseVector(matrix.getColumnDimension());
  double[] resultVectorArray=resultVector.getArray();
  for (int i=0; i < matrix.getRowDimension(); i++) {
    for (int j=0; j < size; j++) {
      resultVectorArray[i]+=array[j] * matrix.getElement(i,j);
    }
  }
  return resultVector;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public DenseVector transMult(Matrix matrix){
  if (matrix.getRowDimension() != size) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  DenseVector resultVector=new DenseVector(matrix.getColumnDimension());
  double[] resultVectorArray=resultVector.getArray();
  for (int i=0; i < matrix.getRowDimension(); i++) {
    for (int j=0; j < matrix.getColumnDimension(); j++) {
      resultVectorArray[j]+=array[i] * matrix.getElement(i,j);
    }
  }
  return resultVector;
}
Program: 143981
Project: 143981
Buggy source:
private void updateCountsAfterSamplingLabel(int sampleNumber,int p,int i){
  priorCounts[p][labelsSamples[sampleNumber][p][i]]++;
  for (int j=0; j < numberOfFunctions; j++)   confusionMatrixCounts[p][clusterAssignmentSamples[sampleNumber][p][j]][labelsSamples[sampleNumber][p][i]][functionOutputsArray[j][p][i]]++;
}

Fixed version (ground truth):
private void updateCountsAfterSamplingLabel(int sampleNumber,int p,int i){
  labelPriorsCounts[p][labelsSamples[sampleNumber][p][i]]++;
  for (int j=0; j < numberOfFunctions; j++)   confusionMatrixCounts[p][clusterAssignmentSamples[sampleNumber][p][j]][labelsSamples[sampleNumber][p][i]][functionOutputsArray[j][p][i]]++;
}
Program: 143983
Project: 143983
Buggy source:
private void samplePriors(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++)   priorSamples[sampleNumber][p]=randomDataGenerator.nextBeta(labelsPriorAlpha + priorCounts[p][1],labelsPriorBeta + priorCounts[p][0]);
}

Fixed version (ground truth):
private void samplePriors(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++)   labelPriorsSamples[sampleNumber][p]=randomDataGenerator.nextBeta(labelsPriorAlpha + labelPriorsCounts[p][1],labelsPriorBeta + labelPriorsCounts[p][0]);
}
Program: 143986
Project: 143986
Buggy source:
private void updateCountsBeforeSamplingLabel(int sampleNumber,int p,int i){
  priorCounts[p][labelsSamples[sampleNumber][p][i]]--;
  for (int j=0; j < numberOfFunctions; j++)   confusionMatrixCounts[p][clusterAssignmentSamples[sampleNumber][p][j]][labelsSamples[sampleNumber][p][i]][functionOutputsArray[j][p][i]]--;
}

Fixed version (ground truth):
private void updateCountsBeforeSamplingLabel(int sampleNumber,int p,int i){
  labelPriorsCounts[p][labelsSamples[sampleNumber][p][i]]--;
  for (int j=0; j < numberOfFunctions; j++)   confusionMatrixCounts[p][clusterAssignmentSamples[sampleNumber][p][j]][labelsSamples[sampleNumber][p][i]][functionOutputsArray[j][p][i]]--;
}
Program: 143987
Project: 143987
Buggy source:
private void storeSample(int sampleIndex){
  copyArray(priorSamples[sampleIndex - 1],priorSamples[sampleIndex]);
  copyArray(confusionMatrixSamples[sampleIndex - 1],confusionMatrixSamples[sampleIndex]);
  copyArray(clusterAssignmentSamples[sampleIndex - 1],clusterAssignmentSamples[sampleIndex]);
  copyArray(labelsSamples[sampleIndex - 1],labelsSamples[sampleIndex]);
}

Fixed version (ground truth):
private void storeSample(int sampleIndex){
  copyArray(labelPriorsSamples[sampleIndex - 1],labelPriorsSamples[sampleIndex]);
  copyArray(confusionMatrixSamples[sampleIndex - 1],confusionMatrixSamples[sampleIndex]);
  copyArray(clusterAssignmentSamples[sampleIndex - 1],clusterAssignmentSamples[sampleIndex]);
  copyArray(labelsSamples[sampleIndex - 1],labelsSamples[sampleIndex]);
}
Program: 143988
Project: 143988
Buggy source:
private void sampleLabels(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++) {
    for (int i=0; i < numberOfDataSamples[p]; i++) {
      double p0=1 - priorSamples[sampleNumber][p];
      double p1=priorSamples[sampleNumber][p];
      for (int j=0; j < numberOfFunctions; j++) {
        p0*=confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][0][functionOutputsArray[j][p][i]];
        p1*=confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][1][functionOutputsArray[j][p][i]];
      }
      int newLabel=randomDataGenerator.nextBinomial(1,p1 / (p0 + p1));
      if (labelsSamples[sampleNumber][p][i] != newLabel) {
        updateCountsBeforeSamplingLabel(sampleNumber,p,i);
        labelsSamples[sampleNumber][p][i]=newLabel;
        updateCountsAfterSamplingLabel(sampleNumber,p,i);
      }
    }
  }
}

Fixed version (ground truth):
private void sampleLabels(int sampleNumber){
  for (int p=0; p < numberOfDomains; p++) {
    for (int i=0; i < numberOfDataSamples[p]; i++) {
      double p0=1 - labelPriorsSamples[sampleNumber][p];
      double p1=labelPriorsSamples[sampleNumber][p];
      for (int j=0; j < numberOfFunctions; j++) {
        p0*=confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][0][functionOutputsArray[j][p][i]];
        p1*=confusionMatrixSamples[sampleNumber][p][clusterAssignmentSamples[sampleNumber][p][j]][1][functionOutputsArray[j][p][i]];
      }
      int newLabel=randomDataGenerator.nextBinomial(1,p1 / (p0 + p1));
      if (labelsSamples[sampleNumber][p][i] != newLabel) {
        updateCountsBeforeSamplingLabel(sampleNumber,p,i);
        labelsSamples[sampleNumber][p][i]=newLabel;
        updateCountsAfterSamplingLabel(sampleNumber,p,i);
      }
    }
  }
}
Program: 143991
Project: 143991
Buggy source:
public Map<Label,DataSet<PredictedDataInstance<Vector,Double>>> getEvaluationPredictedDataSet(){
  return evaluationPredictedDataSet;
}

Fixed version (ground truth):
public Map<DataInstance<Vector>,Map<Label,Double>> getEvaluationPredictedDataSet(){
  return evaluationPredictedDataSet;
}
Program: 143992
Project: 143992
Buggy source:
private ConstrainedLearningWithoutReTraining(int numberOfExamplesToPickPerIteration,int maximumNumberOfIterations,ActiveLearningMethod activeLearningMethod,ExamplePickingMethod examplePickingMethod,String workingDirectory,ImportedDataSet importedDataSet,Set<ResultType> resultTypes){
  this.numberOfExamplesToPickPerIteration=numberOfExamplesToPickPerIteration;
  this.maximumNumberOfIterations=maximumNumberOfIterations;
  this.activeLearningMethod=activeLearningMethod;
  this.examplePickingMethod=examplePickingMethod;
  this.labels=importedDataSet.labels;
  this.dataSet=importedDataSet.evaluationDataSet;
  this.predictedDataSet=importedDataSet.evaluationPredictedDataSet;
  this.resultTypes=resultTypes;
  logger.info("String_Node_Str");
  constraints=importConstraints(workingDirectory);
}

Fixed version (ground truth):
private ConstrainedLearningWithoutReTraining(int numberOfExamplesToPickPerIteration,int maximumNumberOfIterations,ActiveLearningMethod activeLearningMethod,ExamplePickingMethod examplePickingMethod,String workingDirectory,ImportedDataSet importedDataSet,Set<ResultType> resultTypes){
  this.numberOfExamplesToPickPerIteration=numberOfExamplesToPickPerIteration;
  this.maximumNumberOfIterations=maximumNumberOfIterations;
  this.activeLearningMethod=activeLearningMethod;
  this.examplePickingMethod=examplePickingMethod;
  this.labels=importedDataSet.labels;
  this.dataSet=importedDataSet.evaluationDataSet;
  this.predictedDataSet=importedDataSet.evaluationPredictedDataSet;
  this.predictedDataSetInstances=importedDataSet.evaluationPredictedDataSetInstances;
  this.resultTypes=resultTypes;
  logger.info("String_Node_Str");
  constraints=importConstraints(workingDirectory);
}
Program: 143994
Project: 143994
Buggy source:
protected AbstractBuilder(Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet){
  super(dataSet);
}

Fixed version (ground truth):
protected AbstractBuilder(Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet,Function<InstanceToLabel,Double> probabilityFunction){
  super(dataSet,probabilityFunction);
}
Program: 143995
Project: 143995
Buggy source:
public Builder(Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet){
  super(dataSet);
}

Fixed version (ground truth):
public Builder(Map<DataInstance<Vector>,Map<Label,Boolean>> dataSet,Function<InstanceToLabel,Double> probabilityFunction){
  super(dataSet,probabilityFunction);
}
Program: 143998
Project: 143998
Buggy source:
@Override public int hashCode(){
  return Objects.hashCode(predicate,arguments,value);
}

Fixed version (ground truth):
@Override public int hashCode(){
  return Objects.hashCode(id);
}
Program: 143999
Project: 143999
Buggy source:
@Override public boolean equals(Object other){
  if (this == other)   return true;
  if (other == null || getClass() != other.getClass())   return false;
  GroundPredicate that=(GroundPredicate)other;
  return Objects.equal(predicate,that.predicate) && Objects.equal(arguments,that.arguments) && Objects.equal(value,that.value);
}

Fixed version (ground truth):
@Override public boolean equals(Object other){
  if (this == other)   return true;
  if (other == null || getClass() != other.getClass())   return false;
  GroundPredicate that=(GroundPredicate)other;
  return Objects.equal(id,that.id);
}
Program: 144002
Project: 144002
Buggy source:
public EntityType(long id,String name,Set<Long> allowedValues){
  this.name=name;
  this.allowedValues=allowedValues;
}

Fixed version (ground truth):
public EntityType(long id,String name,Set<Long> allowedValues){
  this.id=id;
  this.name=name;
  this.allowedValues=allowedValues;
}
Program: 144003
Project: 144003
Buggy source:
private RulePart convertRulePartToInternalRepresentation(int[] externalVariableIndexes,boolean[] negations){
  List<Integer> internalVariableIndexes=new ArrayList<>();
  List<Boolean> internalVariableNegations=new ArrayList<>();
  double observedConstant=0;
  for (int i=0; i < externalVariableIndexes.length; ++i) {
    double observedValue=observedVariableValues.getOrDefault(externalVariableIndexes[i],Double.NaN);
    if (!Double.isNaN(observedValue)) {
      if (negations[i])       observedConstant+=observedValue - 1;
 else       observedConstant-=observedValue;
    }
 else {
      int internalVariableIndex=externalToInternalIndexesMapping.getOrDefault(externalVariableIndexes[i],-1);
      if (internalVariableIndex < 0) {
        internalVariableIndex=nextInternalIndex++;
        externalToInternalIndexesMapping.put(externalVariableIndexes[i],internalVariableIndex);
      }
      internalVariableIndexes.add(internalVariableIndex);
      internalVariableNegations.add(negations[i]);
    }
  }
  return new RulePart(Ints.toArray(internalVariableIndexes),Booleans.toArray(internalVariableNegations),observedConstant);
}

Fixed version (ground truth):
private RulePart convertRulePartToInternalRepresentation(List<GroundedPredicate<Integer,Double>> groundedRulePredicates,boolean[] negations){
  List<Integer> internalVariableIndexes=new ArrayList<>();
  List<Boolean> internalVariableNegations=new ArrayList<>();
  double observedConstant=0;
  for (int i=0; i < groundedRulePredicates.size(); ++i) {
    Double observedValue=groundedRulePredicates.get(i).getValue();
    if (observedValue != null) {
      if (negations[i])       observedConstant+=observedValue - 1;
 else       observedConstant-=observedValue;
    }
 else {
      int internalVariableIndex=externalToInternalIndexesMapping.getOrDefault((int)groundedRulePredicates.get(i).getIdentifier(),-1);
      if (internalVariableIndex < 0) {
        internalVariableIndex=nextInternalIndex++;
        externalToInternalIndexesMapping.put((int)groundedRulePredicates.get(i).getIdentifier(),internalVariableIndex);
      }
      internalVariableIndexes.add(internalVariableIndex);
      internalVariableNegations.add(negations[i]);
    }
  }
  return new RulePart(Ints.toArray(internalVariableIndexes),Booleans.toArray(internalVariableNegations),observedConstant);
}
Program: 144004
Project: 144004
Buggy source:
public Builder(int[] observedVariableIndexes,double[] observedVariableValues,int numberOfUnobservedVariables){
  ImmutableMap.Builder<Integer,Double> observedVariableValueBuilder=ImmutableMap.builder();
  if ((observedVariableIndexes == null) != (observedVariableValues == null)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (observedVariableIndexes != null) {
    if (observedVariableIndexes.length != observedVariableValues.length) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
    for (int i=0; i < observedVariableIndexes.length; ++i) {
      observedVariableValueBuilder.put(observedVariableIndexes[i],observedVariableValues[i]);
    }
  }
  this.observedVariableValues=observedVariableValueBuilder.build();
  this.externalToInternalIndexesMapping=HashBiMap.create(numberOfUnobservedVariables);
  this.externalPredicateIdToTerms=new HashMap<>(numberOfUnobservedVariables + observedVariableIndexes.length,1);
}

Fixed version (ground truth):
public Builder(LogicManager<Integer,Double> logicManager){
  this.logicManager=logicManager;
  this.externalToInternalIndexesMapping=HashBiMap.create(logicManager.getNumberOfVariables());
  this.externalPredicateIdToTerms=new HashMap<>(logicManager.getNumberOfVariables());
}
Program: 144009
Project: 144009
Buggy source:
public boolean groundedPredicateExists(Predicate<T> predicate,List<T> argumentAssignments){
  if (!groundedPredicates.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  return groundedPredicates.get(predicate.getIdentifier()).containsKey(argumentAssignments);
}

Fixed version (ground truth):
public boolean groundedPredicateExists(Predicate<T> predicate,List<T> argumentAssignments){
  if (!groundedPredicates.containsKey(predicate.getIdentifier()))   throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  return groundedPredicates.get(predicate.getIdentifier()).containsKey(argumentAssignments) || closedPredicateIdentifiers.contains(predicate.getIdentifier());
}
Program: 144015
Project: 144015
Buggy source:
public Builder(int[] observedVariableIndexes,double[] observedVariableValues,int numberOfUnobservedVariables){
  ImmutableMap.Builder<Integer,Double> observedVariableValueBuilder=ImmutableMap.builder();
  if ((observedVariableIndexes == null) != (observedVariableValues == null)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (observedVariableIndexes != null) {
    if (observedVariableIndexes.length != observedVariableValues.length) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
    for (int i=0; i < observedVariableIndexes.length; ++i) {
      observedVariableValueBuilder.put(observedVariableIndexes[i],observedVariableValues[i]);
    }
  }
  observedVariableValueBuilder.put(-1,0.0);
  this.observedVariableValues=observedVariableValueBuilder.build();
  this.externalToInternalIndexesMapping=HashBiMap.create(numberOfUnobservedVariables);
  this.externalPredicateIdToTerms=new HashMap<>(numberOfUnobservedVariables + observedVariableIndexes.length,1);
}

Fixed version (ground truth):
public Builder(int[] observedVariableIndexes,double[] observedVariableValues,int numberOfUnobservedVariables){
  ImmutableMap.Builder<Integer,Double> observedVariableValueBuilder=ImmutableMap.builder();
  if ((observedVariableIndexes == null) != (observedVariableValues == null)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (observedVariableIndexes != null) {
    if (observedVariableIndexes.length != observedVariableValues.length) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
    }
    for (int i=0; i < observedVariableIndexes.length; ++i) {
      observedVariableValueBuilder.put(observedVariableIndexes[i],observedVariableValues[i]);
    }
  }
  this.observedVariableValues=observedVariableValueBuilder.build();
  this.externalToInternalIndexesMapping=HashBiMap.create(numberOfUnobservedVariables);
  this.externalPredicateIdToTerms=new HashMap<>(numberOfUnobservedVariables + observedVariableIndexes.length,1);
}