nus-yam/ex-repair huggingface dataset:
Program: 102821
Project: 102821
Buggy source:
@ExceptionHandler({OAuth2AccessDeniedException.class}) public ResponseEntity<Object> handleOAuth2AccessDeniedException(final OAuth2AccessDeniedException ex,final WebRequest request){
  logger.error("String_Node_Str",ex);
  final String response="String_Node_Str" + ex.getMessage();
  return handleExceptionInternal(ex,response,new HttpHeaders(),HttpStatus.FORBIDDEN,request);
}

Fixed version (ground truth):
@ExceptionHandler({OAuth2AccessDeniedException.class}) public ModelAndView handleOAuth2AccessDeniedException(final OAuth2AccessDeniedException ex,final WebRequest request){
  logger.error("String_Node_Str",ex);
  final String response="String_Node_Str" + ex.getMessage();
  final ModelAndView model=new ModelAndView("String_Node_Str");
  model.addObject("String_Node_Str",response);
  return model;
}
Program: 102822
Project: 102822
Buggy source:
@ExceptionHandler({HttpClientErrorException.class}) public ResponseEntity<Object> handleHttpClientErrorException(final HttpClientErrorException ex,final WebRequest request){
  logger.error("String_Node_Str",ex);
  final String response="String_Node_Str" + ex.getMessage();
  return handleExceptionInternal(ex,response,new HttpHeaders(),HttpStatus.TOO_MANY_REQUESTS,request);
}

Fixed version (ground truth):
@ExceptionHandler({HttpClientErrorException.class}) public ModelAndView handleHttpClientErrorException(final HttpClientErrorException ex,final WebRequest request){
  logger.error("String_Node_Str",ex);
  final String response="String_Node_Str" + ex.getMessage();
  final ModelAndView model=new ModelAndView("String_Node_Str");
  model.addObject("String_Node_Str",response);
  return model;
}
Program: 102823
Project: 102823
Buggy source:
private void onDownloadSuccess(Request request,Page page){
  onSuccess(request);
  if (site.getAcceptStatCode().contains(page.getStatusCode())) {
    pageProcessor.process(page);
    extractAndAddRequests(page,spawnUrl);
    if (!page.getResultItems().isSkip()) {
      for (      Pipeline pipeline : pipelines) {
        pipeline.process(page.getResultItems(),this);
      }
    }
  }
  sleep(site.getSleepTime());
  return;
}

Fixed version (ground truth):
private void onDownloadSuccess(Request request,Page page){
  if (site.getAcceptStatCode().contains(page.getStatusCode())) {
    pageProcessor.process(page);
    extractAndAddRequests(page,spawnUrl);
    if (!page.getResultItems().isSkip()) {
      for (      Pipeline pipeline : pipelines) {
        pipeline.process(page.getResultItems(),this);
      }
    }
  }
  sleep(site.getSleepTime());
  return;
}
Program: 102824
Project: 102824
Buggy source:
private void onDownloaderFail(Request request){
  if (site.getCycleRetryTimes() == 0) {
    sleep(site.getSleepTime());
  }
 else {
    doCycleRetry(request);
  }
  onError(request);
}

Fixed version (ground truth):
private void onDownloaderFail(Request request){
  if (site.getCycleRetryTimes() == 0) {
    sleep(site.getSleepTime());
  }
 else {
    doCycleRetry(request);
  }
}
Program: 102825
Project: 102825
Buggy source:
/** 
 * start with more than one threads
 * @param executorService executorService to run the spider
 * @param threadNum threadNum
 * @return this
 */
public Spider thread(ExecutorService executorService,int threadNum){
  checkIfRunning();
  this.threadNum=threadNum;
  if (threadNum <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  return this;
}

Fixed version (ground truth):
/** 
 * start with more than one threads
 * @param executorService executorService to run the spider
 * @param threadNum threadNum
 * @return this
 */
public Spider thread(ExecutorService executorService,int threadNum){
  checkIfRunning();
  this.threadNum=threadNum;
  if (threadNum <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.executorService=executorService;
  return this;
}
Program: 102826
Project: 102826
Buggy source:
protected void registerMBean(SpiderStatusMXBean spiderStatus) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
  ObjectName objName=new ObjectName(jmxServerName + "String_Node_Str" + spiderStatus.getName());
  mbeanServer.registerMBean(spiderStatus,objName);
}

Fixed version (ground truth):
protected void registerMBean(SpiderStatusMXBean spiderStatus) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
  ObjectName objName=new ObjectName(jmxServerName + "String_Node_Str" + UrlUtils.removePort(spiderStatus.getName()));
  mbeanServer.registerMBean(spiderStatus,objName);
}
Program: 102827
Project: 102827
Buggy source:
@Test(expected=NullPointerException) public void testNthNodesGet(){
  Html html=new Html("String_Node_Str");
  assertThat(html.xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
  Selectable selectable=html.xpath("String_Node_Str").nodes().get(0);
  assertThat(selectable.xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test(expected=NullPointerException.class) public void testNthNodesGet(){
  Html html=new Html("String_Node_Str");
  assertThat(html.xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
  Selectable selectable=html.xpath("String_Node_Str").nodes().get(0);
  assertThat(selectable.xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
}
Program: 102828
Project: 102828
Buggy source:
@Override public void process(GithubRepo o,Task task){
  Assert.assertEquals(86,o.getStar());
  Assert.assertEquals(70,o.getFork());
}

Fixed version (ground truth):
@Override public void process(GithubRepo o,Task task){
  assertThat(o.getStar()).isEqualTo(86);
  assertThat(o.getFork()).isEqualTo(70);
}
Program: 102829
Project: 102829
Buggy source:
@Test public void test(){
  OOSpider.create(Site.me().addStartUrl("String_Node_Str").setSleepTime(0),new PageModelPipeline<GithubRepo>(){
    @Override public void process(    GithubRepo o,    Task task){
      Assert.assertEquals(86,o.getStar());
      Assert.assertEquals(70,o.getFork());
    }
  }
,GithubRepo.class).setDownloader(new MockGithubDownloader()).test("String_Node_Str");
}

Fixed version (ground truth):
@Test public void test(){
  OOSpider.create(Site.me().setSleepTime(0),new PageModelPipeline<GithubRepo>(){
    @Override public void process(    GithubRepo o,    Task task){
      assertThat(o.getStar()).isEqualTo(86);
      assertThat(o.getFork()).isEqualTo(70);
    }
  }
,GithubRepo.class).addUrl("String_Node_Str").setDownloader(new MockGithubDownloader()).test("String_Node_Str");
}
Program: 102830
Project: 102830
Buggy source:
protected void processRequest(Request request){
  Page page=downloader.download(request,this);
  if (page == null) {
    sleep(site.getSleepTime());
    onError(request);
    return;
  }
  if (page.isNeedCycleRetry()) {
    extractAndAddRequests(page,true);
    sleep(site.getSleepTime());
    return;
  }
  pageProcessor.process(page);
  extractAndAddRequests(page,spawnUrl);
  if (!page.getResultItems().isSkip()) {
    for (    Pipeline pipeline : pipelines) {
      pipeline.process(page.getResultItems(),this);
    }
  }
  sleep(site.getSleepTime());
}

Fixed version (ground truth):
protected void processRequest(Request request){
  Page page=downloader.download(request,this);
  if (page == null) {
    sleep(site.getSleepTime());
    onError(request);
    return;
  }
  if (page.isNeedCycleRetry()) {
    extractAndAddRequests(page,true);
    sleep(site.getSleepTime());
    return;
  }
  pageProcessor.process(page);
  extractAndAddRequests(page,spawnUrl);
  if (!page.getResultItems().isSkip()) {
    for (    Pipeline pipeline : pipelines) {
      pipeline.process(page.getResultItems(),this);
    }
  }
  request.putExtra(Request.STATUS_CODE,page.getStatusCode());
  sleep(site.getSleepTime());
}
Program: 102831
Project: 102831
Buggy source:
@Override public long getDelay(TimeUnit unit){
  return unit.convert(canReuseTime - System.nanoTime(),unit.NANOSECONDS);
}

Fixed version (ground truth):
@Override public long getDelay(TimeUnit unit){
  return unit.convert(canReuseTime - System.nanoTime(),TimeUnit.NANOSECONDS);
}
Program: 102832
Project: 102832
Buggy source:
private void readProxyList(){
  try {
    ObjectInputStream is=new ObjectInputStream(new FileInputStream(proxyFile));
    addProxy((Map<String,Proxy>)is.readObject());
    is.close();
  }
 catch (  FileNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  ClassNotFoundException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void readProxyList(){
  try {
    ObjectInputStream is=new ObjectInputStream(new FileInputStream(fBase.getFile(proxyFilePath)));
    addProxy((Map<String,Proxy>)is.readObject());
    is.close();
  }
 catch (  FileNotFoundException e) {
    logger.info("String_Node_Str",e);
  }
catch (  IOException e) {
  }
catch (  ClassNotFoundException e) {
  }
}
Program: 102833
Project: 102833
Buggy source:
public void returnProxy(HttpHost host,int statusCode){
  Proxy p=allProxy.get(host.getAddress().getHostAddress());
  if (p == null) {
    return;
  }
switch (statusCode) {
case Proxy.SUCCESS:
    p.setReuseTimeInterval(reuseInterval);
  p.setFailedNum(0);
p.setFailedErrorType(new ArrayList<Integer>());
p.recordResponse();
p.successNumIncrement(1);
break;
case Proxy.ERROR_403:
p.fail(Proxy.ERROR_403);
p.setReuseTimeInterval(reuseInterval * p.getFailedNum());
logger.info(host + "String_Node_Str" + p.getReuseTimeInterval() / 1000.0);
break;
case Proxy.ERROR_BANNED:
p.fail(Proxy.ERROR_BANNED);
p.setReuseTimeInterval(10 * 60 * 1000* p.getFailedNum());
logger.warn("String_Node_Str" + p.getHttpHost());
logger.info(host + "String_Node_Str" + p.getReuseTimeInterval() / 1000.0);
break;
case Proxy.ERROR_404:
break;
default :
p.fail(statusCode);
break;
}
if (p.getFailedNum() > 20) {
p.setReuseTimeInterval(reviveTime);
logger.error("String_Node_Str" + host + "String_Node_Str"+ p.getFailedType()+ "String_Node_Str"+ proxyQueue.size());
return;
}
if (p.getFailedNum() % 5 == 0) {
if (!ProxyUtil.validateProxy(host)) {
p.setReuseTimeInterval(reviveTime);
logger.error("String_Node_Str" + host + "String_Node_Str"+ p.getFailedType()+ "String_Node_Str"+ proxyQueue.size());
return;
}
}
try {
proxyQueue.put(p);
}
 catch (InterruptedException e) {
logger.warn("String_Node_Str",e);
}
}

Fixed version (ground truth):
public void returnProxy(HttpHost host,int statusCode){
  Proxy p=allProxy.get(host.getAddress().getHostAddress());
  if (p == null) {
    return;
  }
switch (statusCode) {
case Proxy.SUCCESS:
    p.setReuseTimeInterval(reuseInterval);
  p.setFailedNum(0);
p.setFailedErrorType(new ArrayList<Integer>());
p.recordResponse();
p.successNumIncrement(1);
break;
case Proxy.ERROR_403:
p.fail(Proxy.ERROR_403);
p.setReuseTimeInterval(reuseInterval * p.getFailedNum());
logger.info(host + "String_Node_Str" + p.getReuseTimeInterval() / 1000.0);
break;
case Proxy.ERROR_BANNED:
p.fail(Proxy.ERROR_BANNED);
p.setReuseTimeInterval(10 * 60 * 1000* p.getFailedNum());
logger.warn("String_Node_Str" + p.getHttpHost());
logger.info(host + "String_Node_Str" + p.getReuseTimeInterval() / 1000.0);
break;
case Proxy.ERROR_404:
break;
default :
p.fail(statusCode);
break;
}
if (p.getFailedNum() > 20) {
p.setReuseTimeInterval(reviveTime);
logger.error("String_Node_Str" + host + "String_Node_Str"+ p.getFailedType()+ "String_Node_Str"+ proxyQueue.size());
return;
}
if (p.getFailedNum() > 0 && p.getFailedNum() % 5 == 0) {
if (!ProxyUtils.validateProxy(host)) {
p.setReuseTimeInterval(reviveTime);
logger.error("String_Node_Str" + host + "String_Node_Str"+ p.getFailedType()+ "String_Node_Str"+ proxyQueue.size());
return;
}
}
try {
proxyQueue.put(p);
}
 catch (InterruptedException e) {
logger.warn("String_Node_Str",e);
}
}
Program: 102834
Project: 102834
Buggy source:
public void addProxy(String[]... httpProxyList){
  isEnable=true;
  for (  String[] s : httpProxyList) {
    try {
      if (allProxy.containsKey(s[0])) {
        continue;
      }
      HttpHost item=new HttpHost(InetAddress.getByName(s[0]),Integer.valueOf(s[1]));
      if (!validateWhenInit || ProxyUtil.validateProxy(item)) {
        Proxy p=new Proxy(item,reuseInterval);
        proxyQueue.add(p);
        allProxy.put(s[0],p);
      }
    }
 catch (    NumberFormatException e) {
      logger.error("String_Node_Str",e);
    }
catch (    UnknownHostException e) {
      logger.error("String_Node_Str",e);
    }
  }
  logger.info("String_Node_Str" + allProxy.size());
}

Fixed version (ground truth):
public void addProxy(String[]... httpProxyList){
  isEnable=true;
  for (  String[] s : httpProxyList) {
    try {
      if (allProxy.containsKey(s[0])) {
        continue;
      }
      HttpHost item=new HttpHost(InetAddress.getByName(s[0]),Integer.valueOf(s[1]));
      if (!validateWhenInit || ProxyUtils.validateProxy(item)) {
        Proxy p=new Proxy(item,reuseInterval);
        proxyQueue.add(p);
        allProxy.put(s[0],p);
      }
    }
 catch (    NumberFormatException e) {
      logger.error("String_Node_Str",e);
    }
catch (    UnknownHostException e) {
      logger.error("String_Node_Str",e);
    }
  }
  logger.info("String_Node_Str" + allProxy.size());
}
Program: 102835
Project: 102835
Buggy source:
private void saveProxyList(){
  if (allProxy.size() == 0) {
    return;
  }
  try {
    ObjectOutputStream os=new ObjectOutputStream(new FileOutputStream(proxyFile));
    os.writeObject(prepareForSaving());
    os.close();
    logger.info("String_Node_Str");
  }
 catch (  FileNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private void saveProxyList(){
  if (allProxy.size() == 0) {
    return;
  }
  try {
    ObjectOutputStream os=new ObjectOutputStream(new FileOutputStream(fBase.getFile(proxyFilePath)));
    os.writeObject(prepareForSaving());
    os.close();
    logger.info("String_Node_Str");
  }
 catch (  FileNotFoundException e) {
    logger.error("String_Node_Str",e);
  }
catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 102836
Project: 102836
Buggy source:
public ProxyPool(List<String[]> httpProxyList){
  readProxyList();
  addProxy(httpProxyList.toArray(new String[httpProxyList.size()][]));
  timer.schedule(saveProxyTask,10 * 60 * 1000L,10 * 60 * 1000);
}

Fixed version (ground truth):
public ProxyPool(List<String[]> httpProxyList,boolean isUseLastProxy){
  if (httpProxyList != null) {
    addProxy(httpProxyList.toArray(new String[httpProxyList.size()][]));
  }
  if (isUseLastProxy) {
    if (!new File(proxyFilePath).exists()) {
      setFilePath();
    }
    setFilePath();
    readProxyList();
    timer.schedule(saveProxyTask,0,saveProxyInterval);
  }
}
Program: 102838
Project: 102838
Buggy source:
/** 
 * @param key1
 * @param key2
 * @param value
 * @return value
 */
public V put(K1 key1,K2 key2,V value){
  if (map.get(key1) == null) {
    map.put(key1,this.<K2,V>newMap());
  }
  return get(key1).put(key2,value);
}

Fixed version (ground truth):
/** 
 * @param key1
 * @param key2
 * @param value
 * @return value
 */
public synchronized V put(K1 key1,K2 key2,V value){
  if (map.get(key1) == null) {
    map.put(key1,this.<K2,V>newMap());
  }
  return get(key1).put(key2,value);
}
Program: 102839
Project: 102839
Buggy source:
@Override public List<Selectable> nodes(){
  ArrayList<Selectable> selectables=new ArrayList<Selectable>();
  selectables.add(this);
  return selectables;
}

Fixed version (ground truth):
@Override public List<Selectable> nodes(){
  List<Selectable> selectables=new ArrayList<Selectable>();
  for (  Element element : getElements()) {
    List<Element> childElements=new ArrayList<Element>(1);
    childElements.add(element);
    selectables.add(new HtmlNode(childElements));
  }
  return selectables;
}
Program: 102840
Project: 102840
Buggy source:
@Override public List<String> selectList(String text){
  List<String> list=new ArrayList<String>();
  Object object=jsonPath.read(text);
  if (object == null) {
    return list;
  }
  if (object instanceof List) {
    return (List<String>)object;
  }
 else {
    list.add(object.toString());
  }
  return list;
}

Fixed version (ground truth):
@Override public List<String> selectList(String text){
  List<String> list=new ArrayList<String>();
  Object object=jsonPath.read(text);
  if (object == null) {
    return list;
  }
  if (object instanceof List) {
    List<Object> items=(List<Object>)object;
    for (    Object item : items) {
      list.add(String.valueOf(item));
    }
  }
 else {
    list.add(String.valueOf(object));
  }
  return list;
}
Program: 102841
Project: 102841
Buggy source:
@Test public void testCombo(){
  Assert.assertEquals("String_Node_Str",and($("String_Node_Str"),regex("String_Node_Str")).select(html2));
  OrSelector or=or($("String_Node_Str","String_Node_Str"),xpath("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",or.select(html));
  Assert.assertEquals("String_Node_Str",or.select(html2));
}

Fixed version (ground truth):
@Test public void testCombo(){
  assertThat(and($("String_Node_Str"),regex("String_Node_Str")).select(html2)).isEqualTo("String_Node_Str");
  OrSelector or=or($("String_Node_Str","String_Node_Str"),xpath("String_Node_Str"));
  assertThat(or.select(html)).isEqualTo("String_Node_Str");
  assertThat(or.select(html2)).isEqualTo("String_Node_Str");
}
Program: 102842
Project: 102842
Buggy source:
@Test public void testEach(){
  Assert.assertEquals("String_Node_Str",$("String_Node_Str").select(html));
  Assert.assertEquals("String_Node_Str",$("String_Node_Str","String_Node_Str").select(html));
  Assert.assertEquals("String_Node_Str",$("String_Node_Str","String_Node_Str").select(html));
  Assert.assertEquals("String_Node_Str",xpath("String_Node_Str").select(html));
  Assert.assertEquals("String_Node_Str",regex("String_Node_Str").select(html));
  Assert.assertEquals("String_Node_Str",regex("String_Node_Str",2).select(html));
}

Fixed version (ground truth):
@Test public void testEach(){
  assertThat($("String_Node_Str").select(html)).isEqualTo("String_Node_Str");
  assertThat($("String_Node_Str","String_Node_Str").select(html)).isEqualTo("String_Node_Str");
  assertThat($("String_Node_Str","String_Node_Str").select(html)).isEqualTo("String_Node_Str");
  assertThat(xpath("String_Node_Str").select(html)).isEqualTo("String_Node_Str");
  assertThat(regex("String_Node_Str").select(html)).isEqualTo("String_Node_Str");
  assertThat(regex("String_Node_Str",2).select(html)).isEqualTo("String_Node_Str");
}
Program: 102843
Project: 102843
Buggy source:
@Test public void testRegexWithLeftBracketQuoted(){
  String regex="String_Node_Str";
  String source="String_Node_Str";
  RegexSelector regexSelector=new RegexSelector(regex);
  String select=regexSelector.select(source);
  Assert.assertEquals(source,select);
}

Fixed version (ground truth):
@Test public void testRegexWithLeftBracketQuoted(){
  String regex="String_Node_Str";
  String source="String_Node_Str";
  RegexSelector regexSelector=new RegexSelector(regex);
  String select=regexSelector.select(source);
  Assertions.assertThat(select).isEqualTo(source);
}
Program: 102844
Project: 102844
Buggy source:
/** 
 * select elements
 * @param elementSelector
 * @return
 */
protected Selectable selectElements(BaseElementSelector elementSelector){
  if (!elementSelector.hasAttribute()) {
    List<Element> resultElements=new ArrayList<Element>();
    for (    Element element : getElements()) {
      List<Element> selectElements=elementSelector.selectElements(element);
      resultElements.addAll(selectElements);
    }
    return new HtmlNode(resultElements);
  }
 else {
    List<String> resultStrings=new ArrayList<String>();
    for (    Element element : getElements()) {
      List<String> selectList=elementSelector.selectList(element);
      resultStrings.addAll(selectList);
    }
    return new PlainText(resultStrings);
  }
}

Fixed version (ground truth):
/** 
 * select elements
 * @param elementSelector
 * @return
 */
protected Selectable selectElements(BaseElementSelector elementSelector){
  ListIterator<Element> elementIterator=getElements().listIterator();
  if (!elementSelector.hasAttribute()) {
    List<Element> resultElements=new ArrayList<Element>();
    while (elementIterator.hasNext()) {
      Element element=checkElementAndConvert(elementIterator);
      List<Element> selectElements=elementSelector.selectElements(element);
      resultElements.addAll(selectElements);
    }
    return new HtmlNode(resultElements);
  }
 else {
    List<String> resultStrings=new ArrayList<String>();
    while (elementIterator.hasNext()) {
      Element element=checkElementAndConvert(elementIterator);
      List<String> selectList=elementSelector.selectList(element);
      resultStrings.addAll(selectList);
    }
    return new PlainText(resultStrings);
  }
}
Program: 102845
Project: 102845
Buggy source:
@Test public void testNodes() throws Exception {
  Html selectable=new Html(html);
  List<Selectable> links=selectable.xpath("String_Node_Str").nodes();
  assertThat(links.get(0).xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
  assertThat(links.get(1).xpath("String_Node_Str").get()).isEqualTo("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testNodes() throws Exception {
  Html selectable=new Html(html);
  List<Selectable> links=selectable.xpath("String_Node_Str").nodes();
  assertThat(links.get(0).links().get()).isEqualTo("String_Node_Str");
}
Program: 102846
Project: 102846
Buggy source:
@Override public void push(Request request,Task task){
  logger.trace("String_Node_Str",request.getUrl());
  if (isDuplicate(request,task) || shouldReserved(request)) {
    logger.debug("String_Node_Str",request.getUrl());
    pushWhenNoDuplicate(request,task);
  }
}

Fixed version (ground truth):
@Override public void push(Request request,Task task){
  logger.trace("String_Node_Str",request.getUrl());
  if (!isDuplicate(request,task) || shouldReserved(request)) {
    logger.debug("String_Node_Str",request.getUrl());
    pushWhenNoDuplicate(request,task);
  }
}
Program: 102847
Project: 102847
Buggy source:
@Override protected boolean isDuplicate(Request request,Task task){
  return urls.add(request.getUrl());
}

Fixed version (ground truth):
@Override protected boolean isDuplicate(Request request,Task task){
  return !urls.add(request.getUrl());
}
Program: 102848
Project: 102848
Buggy source:
@Override protected boolean isDuplicate(Request request,Task task){
  Jedis jedis=pool.getResource();
  try {
    boolean isDuplicate=!jedis.sismember(getSetKey(task),request.getUrl());
    if (!isDuplicate) {
      jedis.sadd(getSetKey(task),request.getUrl());
    }
    return isDuplicate;
  }
  finally {
    pool.returnResource(jedis);
  }
}

Fixed version (ground truth):
@Override protected boolean isDuplicate(Request request,Task task){
  Jedis jedis=pool.getResource();
  try {
    boolean isDuplicate=jedis.sismember(getSetKey(task),request.getUrl());
    if (!isDuplicate) {
      jedis.sadd(getSetKey(task),request.getUrl());
    }
    return isDuplicate;
  }
  finally {
    pool.returnResource(jedis);
  }
}
Program: 102849
Project: 102849
Buggy source:
public static void main(String[] args){
  Spider.create(new OschinaBlogPageProcesser()).run();
}

Fixed version (ground truth):
public static void main(String[] args){
  Spider.create(new OschinaBlogPageProcesser()).setScheduler(new RedisScheduler("String_Node_Str")).run();
}
Program: 102850
Project: 102850
Buggy source:
public int getThreadAlive(){
  return threadAlive;
}

Fixed version (ground truth):
public int getThreadAlive(){
  return threadAlive.get();
}
Program: 102851
Project: 102851
Buggy source:
public void execute(Runnable runnable){
  try {
    reentrantLock.lock();
    while (threadAlive >= threadNum) {
      try {
        condition.await();
      }
 catch (      InterruptedException e) {
      }
    }
    threadAlive++;
    System.out.println(threadAlive);
    executorService.execute(runnable);
  }
  finally {
    threadAlive--;
    condition.signal();
    reentrantLock.unlock();
  }
}

Fixed version (ground truth):
public void execute(final Runnable runnable){
  try {
    if (threadAlive.get() >= threadNum) {
      reentrantLock.lock();
      while (threadAlive.get() >= threadNum) {
        try {
          condition.await();
        }
 catch (        InterruptedException e) {
        }
      }
    }
    threadAlive.incrementAndGet();
    executorService.execute(new Runnable(){
      @Override public void run(){
        try {
          runnable.run();
        }
  finally {
          try {
            reentrantLock.lock();
            threadAlive.decrementAndGet();
            condition.signal();
          }
  finally {
            reentrantLock.unlock();
          }
        }
      }
    }
);
  }
  finally {
    if (reentrantLock.isLocked()) {
      reentrantLock.unlock();
    }
  }
}
Program: 102852
Project: 102852
Buggy source:
private void init(Class clazz){
}

Fixed version (ground truth):
private void init(Class clazz){
  this.clazz=clazz;
  initClassExtractors();
  fieldExtractors=new ArrayList<FieldExtractor>();
  for (  Field field : ClassUtils.getFieldsIncludeSuperClass(clazz)) {
    field.setAccessible(true);
    FieldExtractor fieldExtractor=getAnnotationExtractBy(clazz,field);
    FieldExtractor fieldExtractorTmp=getAnnotationExtractCombo(clazz,field);
    if (fieldExtractor != null && fieldExtractorTmp != null) {
      throw new IllegalStateException("String_Node_Str");
    }
 else     if (fieldExtractor == null && fieldExtractorTmp != null) {
      fieldExtractor=fieldExtractorTmp;
    }
    fieldExtractorTmp=getAnnotationExtractByUrl(clazz,field);
    if (fieldExtractor != null && fieldExtractorTmp != null) {
      throw new IllegalStateException("String_Node_Str");
    }
 else     if (fieldExtractor == null && fieldExtractorTmp != null) {
      fieldExtractor=fieldExtractorTmp;
    }
    if (fieldExtractor != null) {
      checkFormat(field,fieldExtractor);
      fieldExtractors.add(fieldExtractor);
    }
  }
}
Program: 102853
Project: 102853
Buggy source:
private void checkFormat(Field field,FieldExtractor fieldExtractor){
  if (!fieldExtractor.isMulti() && !String.class.isAssignableFrom(field.getType())) {
    Class<?> fieldClazz=BasicTypeFormatter.detectBasicClass(field.getType());
    ObjectFormatter objectFormatter=getObjectFormatter(field,fieldClazz);
    if (objectFormatter == null) {
      throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str"+ fieldClazz);
    }
 else {
      fieldExtractor.setObjectFormatter(objectFormatter);
    }
  }
 else   if (fieldExtractor.isMulti()) {
    if (!List.class.isAssignableFrom(field.getType())) {
      throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str");
    }
    Formatter formatter=field.getAnnotation(Formatter.class);
    if (formatter != null) {
      if (!formatter.subClazz().equals(Void.class)) {
        ObjectFormatter objectFormatter=getObjectFormatter(field,formatter.subClazz());
        if (objectFormatter == null) {
          throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str"+ formatter.subClazz());
        }
 else {
          fieldExtractor.setObjectFormatter(objectFormatter);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void checkFormat(Field field,FieldExtractor fieldExtractor){
  Formatter formatter=field.getAnnotation(Formatter.class);
  if (formatter != null && !formatter.formatter().equals(ObjectFormatter.class)) {
    if (formatter != null) {
      if (!formatter.formatter().equals(ObjectFormatter.class)) {
        ObjectFormatter objectFormatter=initFormatter(formatter.formatter());
        objectFormatter.initParam(formatter.value());
        fieldExtractor.setObjectFormatter(objectFormatter);
        return;
      }
    }
  }
  if (!fieldExtractor.isMulti() && !String.class.isAssignableFrom(field.getType())) {
    Class<?> fieldClazz=BasicTypeFormatter.detectBasicClass(field.getType());
    ObjectFormatter objectFormatter=getObjectFormatter(field,fieldClazz,formatter);
    if (objectFormatter == null) {
      throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str"+ fieldClazz);
    }
 else {
      fieldExtractor.setObjectFormatter(objectFormatter);
    }
  }
 else   if (fieldExtractor.isMulti()) {
    if (!List.class.isAssignableFrom(field.getType())) {
      throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str");
    }
    if (formatter != null) {
      if (!formatter.subClazz().equals(Void.class)) {
        ObjectFormatter objectFormatter=getObjectFormatter(field,formatter.subClazz(),formatter);
        if (objectFormatter == null) {
          throw new IllegalStateException("String_Node_Str" + field.getName() + "String_Node_Str"+ formatter.subClazz());
        }
 else {
          fieldExtractor.setObjectFormatter(objectFormatter);
        }
      }
    }
  }
}
Program: 102854
Project: 102854
Buggy source:
private ObjectFormatter getObjectFormatter(Field field,Class<?> fieldClazz){
  Formatter formatter=field.getAnnotation(Formatter.class);
  if (formatter != null) {
    if (!formatter.formatter().equals(ObjectFormatter.class)) {
      ObjectFormatter objectFormatter=initFormatter(formatter.formatter());
      objectFormatter.initParam(formatter.value());
    }
  }
  return initFormatter(ObjectFormatters.get(fieldClazz));
}

Fixed version (ground truth):
private ObjectFormatter getObjectFormatter(Field field,Class<?> fieldClazz,Formatter formatter){
  return initFormatter(ObjectFormatters.get(fieldClazz));
}
Program: 102855
Project: 102855
Buggy source:
/** 
 * set scheduler for Spider
 * @param scheduler
 * @return this
 * @see Scheduler
 * @since 0.2.1
 */
public Spider setScheduler(Scheduler scheduler){
  checkIfRunning();
  this.scheduler=scheduler;
  return this;
}

Fixed version (ground truth):
/** 
 * set scheduler for Spider
 * @param scheduler
 * @return this
 * @see Scheduler
 * @since 0.2.1
 */
public Spider setScheduler(Scheduler scheduler){
  checkIfRunning();
  Scheduler oldScheduler=this.scheduler;
  this.scheduler=scheduler;
  Request request;
  while ((request=oldScheduler.poll(this)) != null) {
    this.scheduler.push(request,this);
  }
  return this;
}
Program: 102856
Project: 102856
Buggy source:
/** 
 * add urls to fetch
 * @param requests
 */
public void addTargetRequests(List<String> requests,long priority){
synchronized (targetRequests) {
    for (    String s : requests) {
      if (StringUtils.isBlank(s) || s.equals("String_Node_Str") || s.startsWith("String_Node_Str")) {
        break;
      }
      s=UrlUtils.canonicalizeUrl(s,url.toString());
      targetRequests.add(new Request(s).setPriority(priority));
    }
  }
}

Fixed version (ground truth):
/** 
 * add urls to fetch
 * @param requests
 */
public void addTargetRequests(List<String> requests,long priority){
synchronized (targetRequests) {
    for (    String s : requests) {
      if (StringUtils.isBlank(s) || s.equals("String_Node_Str") || s.startsWith("String_Node_Str")) {
        continue;
      }
      s=UrlUtils.canonicalizeUrl(s,url.toString());
      targetRequests.add(new Request(s).setPriority(priority));
    }
  }
}
Program: 102857
Project: 102857
Buggy source:
protected Selectable select(Selector selector,List<String> strings){
  List<String> results=new ArrayList<String>();
  for (  String string : strings) {
    String result=selector.select(string);
    if (result != null) {
      results.add(result);
    }
  }
  return new PlainText(results);
}

Fixed version (ground truth):
@Override public Selectable select(Selector selector){
  return select(selector,strings);
}
Program: 102858
Project: 102858
Buggy source:
protected Selectable selectList(Selector selector,List<String> strings){
  List<String> results=new ArrayList<String>();
  for (  String string : strings) {
    List<String> result=selector.selectList(string);
    results.addAll(result);
  }
  return new PlainText(results);
}

Fixed version (ground truth):
@Override public Selectable selectList(Selector selector){
  return selectList(selector,strings);
}
Program: 102859
Project: 102859
Buggy source:
private void extractLinks(Page page,Selector urlRegionSelector,List<Pattern> urlPatterns){
  List<String> links;
  if (urlRegionSelector == null) {
    links=page.getHtml().links().all();
  }
 else {
    links=urlRegionSelector.selectList(page.getHtml().toString());
  }
  for (  String link : links) {
    for (    Pattern targetUrlPattern : urlPatterns) {
      Matcher matcher=targetUrlPattern.matcher(link);
      if (matcher.find()) {
        page.addTargetRequest(new Request(matcher.group(1)));
      }
    }
  }
}

Fixed version (ground truth):
private void extractLinks(Page page,Selector urlRegionSelector,List<Pattern> urlPatterns){
  List<String> links;
  if (urlRegionSelector == null) {
    links=page.getHtml().links().all();
  }
 else {
    links=page.getHtml().selectList(urlRegionSelector).links().all();
  }
  for (  String link : links) {
    for (    Pattern targetUrlPattern : urlPatterns) {
      Matcher matcher=targetUrlPattern.matcher(link);
      if (matcher.find()) {
        page.addTargetRequest(new Request(matcher.group(1)));
      }
    }
  }
}
Program: 102860
Project: 102860
Buggy source:
@Override public void process(Page page){
  for (  PageModelExtractor pageModelExtractor : pageModelExtractorList) {
    extractLinks(page,pageModelExtractor.getHelpUrlRegionSelector(),pageModelExtractor.getHelpUrlPatterns());
    extractLinks(page,pageModelExtractor.getTargetUrlRegionSelector(),pageModelExtractor.getTargetUrlPatterns());
    Object process=pageModelExtractor.process(page);
    if (process == null || (process instanceof List && ((List)process).size() == 0)) {
      page.getResultItems().setSkip(true);
    }
    postProcessPageModel(pageModelExtractor.getClazz(),process);
    page.putField(pageModelExtractor.getClazz().getCanonicalName(),process);
  }
}

Fixed version (ground truth):
@Override public void process(Page page){
  for (  PageModelExtractor pageModelExtractor : pageModelExtractorList) {
    extractLinks(page,pageModelExtractor.getHelpUrlRegionSelector(),pageModelExtractor.getHelpUrlPatterns());
    extractLinks(page,pageModelExtractor.getTargetUrlRegionSelector(),pageModelExtractor.getTargetUrlPatterns());
    Object process=pageModelExtractor.process(page);
    if (process == null || (process instanceof List && ((List)process).size() == 0)) {
      continue;
    }
    postProcessPageModel(pageModelExtractor.getClazz(),process);
    page.putField(pageModelExtractor.getClazz().getCanonicalName(),process);
  }
  if (page.getResultItems().getAll().size() == 0) {
    page.getResultItems().setSkip(true);
  }
}
Program: 102861
Project: 102861
Buggy source:
/** 
 * Exit when complete. <br/> True: exit when all url of the site is downloaded. <br/> False: not exit until call stop manually.<br/>
 * @param exitWhenComplete
 * @return
 */
public Spider setExitWhenComplete(boolean exitWhenComplete){
  this.exitWhenComplete=exitWhenComplete;
  return this;
}

Fixed version (ground truth):
/** 
 * Exit when complete. <br/> True: exit when all url of the site is downloaded. <br/> False: not exit until call stop() manually.<br/>
 * @param exitWhenComplete
 * @return
 */
public Spider setExitWhenComplete(boolean exitWhenComplete){
  this.exitWhenComplete=exitWhenComplete;
  return this;
}
Program: 102863
Project: 102863
Buggy source:
/** 
 * Add a url to start url.<br>
 * @param startUrl
 * @return this
 */
public Site addStartUrl(String startUrl){
  this.startUrls.add(startUrl);
  return this;
}

Fixed version (ground truth):
/** 
 * Add a url to start url.<br>
 * @param startUrl
 * @return this
 */
public Site addStartUrl(String startUrl){
  this.startUrls.add(startUrl);
  if (domain == null) {
    if (startUrls.size() > 0) {
      domain=UrlUtils.getDomain(startUrls.get(0));
    }
  }
  return this;
}
Program: 102864
Project: 102864
Buggy source:
/** 
 * get domain
 * @return get domain
 */
public String getDomain(){
  if (domain == null) {
    if (startUrls.size() > 0) {
      domain=UrlUtils.getDomain(startUrls.get(0));
    }
  }
  return domain;
}

Fixed version (ground truth):
/** 
 * get domain
 * @return get domain
 */
public String getDomain(){
  return domain;
}
Program: 102865
Project: 102865
Buggy source:
public static String getCharset(String contentType){
  Matcher matcher=patternForCharset.matcher(contentType);
  if (matcher.find()) {
    return matcher.group(1);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public static String getCharset(String contentType){
  Matcher matcher=patternForCharset.matcher(contentType);
  if (matcher.find()) {
    String charset=matcher.group(1);
    if (Charset.isSupported(charset)) {
      return charset;
    }
  }
  return null;
}
Program: 102866
Project: 102866
Buggy source:
@Ignore("String_Node_Str") @Test public void testDownload(){
  String s=new HttpClientDownloader().download("String_Node_Str","String_Node_Str").smartContent().text().toString();
  Assert.assertNotNull(text);
}

Fixed version (ground truth):
@Ignore("String_Node_Str") @Test public void testDownload(){
  String s=new HttpClientDownloader().download("String_Node_Str","String_Node_Str").smartContent().text().toString();
  Assert.assertNotNull(s);
}
Program: 102867
Project: 102867
Buggy source:
private FieldExtractor getAnnotationExtractBy(Class clazz,Field field){
  FieldExtractor fieldExtractor=null;
  ExtractBy extractBy=field.getAnnotation(ExtractBy.class);
  if (extractBy != null) {
    Selector selector=ExtractorUtils.getSelector(extractBy);
    fieldExtractor=new FieldExtractor(field,selector,FieldExtractor.Source.Html,extractBy.notNull(),extractBy.multi());
    Method setterMethod=getSetterMethod(clazz,field);
    if (setterMethod != null) {
      fieldExtractor.setSetterMethod(setterMethod);
    }
  }
  return fieldExtractor;
}

Fixed version (ground truth):
private FieldExtractor getAnnotationExtractBy(Class clazz,Field field){
  FieldExtractor fieldExtractor=null;
  ExtractBy extractBy=field.getAnnotation(ExtractBy.class);
  if (extractBy != null) {
    Selector selector=ExtractorUtils.getSelector(extractBy);
    fieldExtractor=new FieldExtractor(field,selector,extractBy.source() == ExtractBy.Source.RawHtml ? FieldExtractor.Source.RawHtml : FieldExtractor.Source.Html,extractBy.notNull(),extractBy.multi());
    Method setterMethod=getSetterMethod(clazz,field);
    if (setterMethod != null) {
      fieldExtractor.setSetterMethod(setterMethod);
    }
  }
  return fieldExtractor;
}
Program: 102868
Project: 102868
Buggy source:
private FieldExtractor getAnnotationExtractCombo(Class clazz,Field field){
  FieldExtractor fieldExtractor=null;
  ComboExtract comboExtract=field.getAnnotation(ComboExtract.class);
  if (comboExtract != null) {
    ExtractBy[] extractBies=comboExtract.value();
    Selector selector;
switch (comboExtract.op()) {
case And:
      selector=new AndSelector(ExtractorUtils.getSelectors(extractBies));
    break;
case Or:
  selector=new OrSelector(ExtractorUtils.getSelectors(extractBies));
break;
default :
selector=new AndSelector(ExtractorUtils.getSelectors(extractBies));
}
fieldExtractor=new FieldExtractor(field,selector,FieldExtractor.Source.Html,comboExtract.notNull(),comboExtract.multi());
Method setterMethod=getSetterMethod(clazz,field);
if (setterMethod != null) {
fieldExtractor.setSetterMethod(setterMethod);
}
}
return fieldExtractor;
}

Fixed version (ground truth):
private FieldExtractor getAnnotationExtractCombo(Class clazz,Field field){
  FieldExtractor fieldExtractor=null;
  ComboExtract comboExtract=field.getAnnotation(ComboExtract.class);
  if (comboExtract != null) {
    ExtractBy[] extractBies=comboExtract.value();
    Selector selector;
switch (comboExtract.op()) {
case And:
      selector=new AndSelector(ExtractorUtils.getSelectors(extractBies));
    break;
case Or:
  selector=new OrSelector(ExtractorUtils.getSelectors(extractBies));
break;
default :
selector=new AndSelector(ExtractorUtils.getSelectors(extractBies));
}
fieldExtractor=new FieldExtractor(field,selector,comboExtract.source() == ComboExtract.Source.RawHtml ? FieldExtractor.Source.RawHtml : FieldExtractor.Source.Html,comboExtract.notNull(),comboExtract.multi());
Method setterMethod=getSetterMethod(clazz,field);
if (setterMethod != null) {
fieldExtractor.setSetterMethod(setterMethod);
}
}
return fieldExtractor;
}
Program: 102869
Project: 102869
Buggy source:
/** 
 * 新建一个FilePipeline
 * @param path 文件保存路径
 */
public FilePipeline(String path){
  this.path=path;
}

Fixed version (ground truth):
/** 
 * 新建一个FilePipeline
 * @param path 文件保存路径
 */
public FilePipeline(String path){
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")) {
    path+="String_Node_Str";
  }
  this.path=path;
}
Program: 102870
Project: 102870
Buggy source:
public FileDownloader(String path,Downloader downloaderWhenFileMiss){
  this.path=path;
  this.downloaderWhenFileMiss=downloaderWhenFileMiss;
}

Fixed version (ground truth):
public FileDownloader(String path,Downloader downloaderWhenFileMiss){
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")) {
    path+="String_Node_Str";
  }
  this.path=path;
  this.downloaderWhenFileMiss=downloaderWhenFileMiss;
}
Program: 102871
Project: 102871
Buggy source:
/** 
 * 新建一个FilePipeline
 * @param path 文件保存路径
 */
public JsonFilePipeline(String path){
  this.path=path;
}

Fixed version (ground truth):
/** 
 * 新建一个FilePipeline
 * @param path 文件保存路径
 */
public JsonFilePipeline(String path){
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")) {
    path+="String_Node_Str";
  }
  this.path=path;
}
Program: 102872
Project: 102872
Buggy source:
public FileCacheQueueScheduler(String filePath){
  this.filePath=filePath;
}

Fixed version (ground truth):
public FileCacheQueueScheduler(String filePath){
  if (!filePath.endsWith("String_Node_Str") && !filePath.endsWith("String_Node_Str")) {
    filePath+="String_Node_Str";
  }
  this.filePath=filePath;
}
Program: 102873
Project: 102873
Buggy source:
/** 
 * 获取已设置的domain
 * @return 已设置的domain
 */
public String getDomain(){
  return domain;
}

Fixed version (ground truth):
/** 
 * 获取已设置的domain
 * @return 已设置的domain
 */
public String getDomain(){
  if (domain == null) {
    if (startUrls.size() > 0) {
      domain=UrlUtils.getDomain(startUrls.get(0));
    }
  }
  return domain;
}
Program: 102874
Project: 102874
Buggy source:
public static void main(String[] args){
  OOSpider.create(Site.me().addStartUrl("String_Node_Str"),OschinaBlog.class).run();
}

Fixed version (ground truth):
public static void main(String[] args){
  OOSpider.create(Site.me().addStartUrl("String_Node_Str"),OschinaBlog.class).pipeline(new ConsolePipeline()).pipeline(new JsonFilePipeline()).run();
}
Program: 102876
Project: 102876
Buggy source:
@Test public void test(){
  OOSpider.create(Site.me().addStartUrl("String_Node_Str"),OschinaBlog.class).run();
}

Fixed version (ground truth):
@Ignore("String_Node_Str") @Test public void test(){
  System.out.println(List.class.isAssignableFrom(ArrayList.class));
  OOSpider.create(Site.me().addStartUrl("String_Node_Str"),OschinaBlog.class).run();
}
Program: 102877
Project: 102877
Buggy source:
@Override public List<String> selectList(String text){
  List<String> results=new ArrayList<String>();
  try {
    HtmlCleaner htmlCleaner=new HtmlCleaner();
    TagNode tagNode=htmlCleaner.clean(text);
    Document document=new DomSerializer(new CleanerProperties()).createDOM(tagNode);
    Object result;
    try {
      result=xPathExpression.evaluate(document,XPathConstants.NODESET);
    }
 catch (    XPathExpressionException e) {
      result=xPathExpression.evaluate(document,XPathConstants.STRING);
    }
    if (result instanceof NodeList) {
      NodeList nodeList=(NodeList)result;
      Transformer transformer=TransformerFactory.newInstance().newTransformer();
      StreamResult xmlOutput=new StreamResult();
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
      for (int i=0; i < nodeList.getLength(); i++) {
        xmlOutput.setWriter(new StringWriter());
        transformer.transform(new DOMSource(nodeList.item(i)),xmlOutput);
        results.add(xmlOutput.getWriter().toString());
      }
    }
 else {
      results.add(result.toString());
    }
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + xpathStr,e);
  }
  return results;
}

Fixed version (ground truth):
@Override public List<String> selectList(String text){
  List<String> results=new ArrayList<String>();
  try {
    HtmlCleaner htmlCleaner=new HtmlCleaner();
    TagNode tagNode=htmlCleaner.clean(text);
    Document document=new DomSerializer(new CleanerProperties()).createDOM(tagNode);
    Object result;
    try {
      result=xPathExpression.evaluate(document,XPathConstants.NODESET);
    }
 catch (    XPathExpressionException e) {
      result=xPathExpression.evaluate(document,XPathConstants.STRING);
    }
    if (result instanceof NodeList) {
      NodeList nodeList=(NodeList)result;
      Transformer transformer=TransformerFactory.newInstance().newTransformer();
      StreamResult xmlOutput=new StreamResult();
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
      for (int i=0; i < nodeList.getLength(); i++) {
        Node item=nodeList.item(i);
        if (item.getNodeType() == Node.ATTRIBUTE_NODE || item.getNodeType() == Node.TEXT_NODE) {
          results.add(item.getTextContent());
        }
 else {
          xmlOutput.setWriter(new StringWriter());
          transformer.transform(new DOMSource(item),xmlOutput);
          results.add(xmlOutput.getWriter().toString());
        }
      }
    }
 else {
      results.add(result.toString());
    }
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + xpathStr,e);
  }
  return results;
}
Program: 102878
Project: 102878
Buggy source:
@Override public String select(String text){
  try {
    HtmlCleaner htmlCleaner=new HtmlCleaner();
    TagNode tagNode=htmlCleaner.clean(text);
    Document document=new DomSerializer(new CleanerProperties()).createDOM(tagNode);
    Object result;
    try {
      result=xPathExpression.evaluate(document,XPathConstants.NODESET);
    }
 catch (    XPathExpressionException e) {
      result=xPathExpression.evaluate(document,XPathConstants.STRING);
    }
    if (result instanceof NodeList) {
      StreamResult xmlOutput=new StreamResult(new StringWriter());
      Transformer transformer=TransformerFactory.newInstance().newTransformer();
      transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
      NodeList nodeList=(NodeList)result;
      if (nodeList.getLength() == 0) {
        return null;
      }
      transformer.transform(new DOMSource(nodeList.item(0)),xmlOutput);
      return xmlOutput.getWriter().toString();
    }
    return result.toString();
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + xpathStr,e);
  }
  return null;
}

Fixed version (ground truth):
@Override public String select(String text){
  try {
    HtmlCleaner htmlCleaner=new HtmlCleaner();
    TagNode tagNode=htmlCleaner.clean(text);
    Document document=new DomSerializer(new CleanerProperties()).createDOM(tagNode);
    Object result;
    try {
      result=xPathExpression.evaluate(document,XPathConstants.NODESET);
    }
 catch (    XPathExpressionException e) {
      result=xPathExpression.evaluate(document,XPathConstants.STRING);
    }
    if (result instanceof NodeList) {
      NodeList nodeList=(NodeList)result;
      if (nodeList.getLength() == 0) {
        return null;
      }
      Node item=nodeList.item(0);
      if (item.getNodeType() == Node.ATTRIBUTE_NODE || item.getNodeType() == Node.TEXT_NODE) {
        return item.getTextContent();
      }
 else {
        StreamResult xmlOutput=new StreamResult(new StringWriter());
        Transformer transformer=TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"String_Node_Str");
        transformer.transform(new DOMSource(item),xmlOutput);
        return xmlOutput.getWriter().toString();
      }
    }
    return result.toString();
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + xpathStr,e);
  }
  return null;
}