nus-yam/ex-repair huggingface dataset:
Program: 81229
Project: 81229
Buggy source:
private byte[] mutate(byte[] b,TestHarness harness){
  StringBuffer corpus=new StringBuffer(new String(b));
  int nmuts=Math.abs(rand.nextInt(30));
  while (--nmuts > 0) {
    int from_off=rand.nextInt(corpus.length());
    int from_len=(int)(rand.nextDouble() * rand.nextInt(corpus.length() - from_off));
    int to_off=rand.nextInt(corpus.length());
    int to_len=(int)(rand.nextDouble() * rand.nextInt(corpus.length() - to_off));
switch (rand.nextInt(3)) {
case 0:
      harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str"+ to_off+ "String_Node_Str"+ to_len+ "String_Node_Str");
    corpus.replace(to_off,to_off + to_len,corpus.substring(from_off,from_off + from_len));
  break;
case 1:
harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str"+ to_off+ "String_Node_Str"+ to_len+ "String_Node_Str");
corpus.insert(to_off,corpus.substring(from_off,from_off + from_len));
break;
case 2:
harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str");
corpus.delete(from_off,from_off + from_len);
break;
}
}
return corpus.toString().getBytes();
}

Fixed version (ground truth):
/** 
 * Derived from `mutate.pl' from librsync, (C) 1999, 2000 by Martin Pool and (C) 1999 by Andrew Tridgell.
 */
private byte[] mutate(byte[] b,TestHarness harness){
  StringBuffer corpus=new StringBuffer(new String(b));
  int nmuts=1 + rand.nextInt(30);
  harness.verbose("String_Node_Str" + nmuts + "String_Node_Str");
  while (--nmuts > 0) {
    int from_off=rand.nextInt(corpus.length());
    int from_len=(int)(rand.nextDouble() * rand.nextInt(corpus.length() - from_off));
    int to_off=rand.nextInt(corpus.length());
    int to_len=(int)(rand.nextDouble() * rand.nextInt(corpus.length() - to_off));
switch (rand.nextInt(3)) {
case 0:
      harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str"+ to_off+ "String_Node_Str"+ to_len+ "String_Node_Str");
    corpus.replace(to_off,to_off + to_len,corpus.substring(from_off,from_off + from_len));
  break;
case 1:
harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str"+ to_off+ "String_Node_Str"+ to_len+ "String_Node_Str");
corpus.insert(to_off,corpus.substring(from_off,from_off + from_len));
break;
case 2:
harness.verbose("String_Node_Str" + from_off + "String_Node_Str"+ from_len+ "String_Node_Str");
corpus.delete(from_off,from_off + from_len);
break;
}
}
return corpus.toString().getBytes();
}
Program: 81230
Project: 81230
Buggy source:
public void test(TestHarness harness){
  String[] mds=getMessageDigests();
  harness.checkPoint("String_Node_Str");
  Security.addProvider(new JarsyncProvider());
  Configuration conf=new Configuration();
  try {
    conf.strongSum=MessageDigest.getInstance("String_Node_Str");
  }
 catch (  Exception x) {
    throw new Error(x);
  }
  conf.weakSum=new Checksum32();
  conf.strongSumLength=conf.strongSum.getDigestLength();
  for (int i=0; i < 50; i++) {
    conf.blockLength=rand.nextInt(1400) + 250;
    byte[] n3w=new byte[rand.nextInt(1000000) + 500];
    rand.nextBytes(n3w);
    byte[] old=mutate(n3w,harness);
    harness.verbose("String_Node_Str" + (i + 1) + "String_Node_Str"+ old.length+ "String_Node_Str"+ n3w.length+ "String_Node_Str"+ conf.blockLength+ "String_Node_Str"+ conf.strongSum.getAlgorithm());
    Generator gen=new Generator(conf);
    Collection sums=gen.generateSums(old);
    Matcher mat=new Matcher(conf);
    Collection deltas=mat.hashSearch(sums,n3w,0);
    byte[] reconst=Rebuilder.rebuild(old,deltas);
    harness.check(Arrays.equals(n3w,reconst));
    try {
      conf.strongSum=MessageDigest.getInstance(mds[rand.nextInt(mds.length)]);
      conf.strongSumLength=conf.strongSum.getDigestLength();
    }
 catch (    Exception x) {
      throw new Error(x);
    }
  }
}

Fixed version (ground truth):
public void test(TestHarness harness){
  String[] mds=getMessageDigests();
  harness.checkPoint("String_Node_Str");
  Security.addProvider(new JarsyncProvider());
  Configuration conf=new Configuration();
  try {
    conf.strongSum=MessageDigest.getInstance("String_Node_Str","String_Node_Str");
  }
 catch (  Exception x) {
    throw new Error(x);
  }
  conf.weakSum=new Checksum32();
  conf.strongSumLength=conf.strongSum.getDigestLength();
  for (int i=0; i < 50; i++) {
    conf.blockLength=rand.nextInt(1400) + 250;
    byte[] n3w=new byte[rand.nextInt(1000000) + 500];
    rand.nextBytes(n3w);
    byte[] old=mutate(n3w,harness);
    harness.verbose("String_Node_Str" + (i + 1) + "String_Node_Str"+ old.length+ "String_Node_Str"+ n3w.length+ "String_Node_Str"+ conf.blockLength+ "String_Node_Str"+ conf.strongSum.getAlgorithm());
    Generator gen=new Generator(conf);
    Collection sums=gen.generateSums(old);
    Matcher mat=new Matcher(conf);
    Collection deltas=mat.hashSearch(sums,n3w,0);
    byte[] reconst=Rebuilder.rebuild(old,deltas);
    harness.check(Arrays.equals(n3w,reconst));
    try {
      conf.strongSum=MessageDigest.getInstance(mds[rand.nextInt(mds.length)]);
      conf.strongSumLength=conf.strongSum.getDigestLength();
    }
 catch (    Exception x) {
      throw new Error(x);
    }
  }
}
Program: 81231
Project: 81231
Buggy source:
private String[] getMessageDigests(){
  HashSet algs=new HashSet();
  String[] tries={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < tries.length; i++) {
    try {
      MessageDigest.getInstance(tries[i]);
      algs.add(tries[i]);
    }
 catch (    Exception x) {
    }
  }
  return (String[])algs.toArray(tries);
}

Fixed version (ground truth):
private String[] getMessageDigests(){
  HashSet algs=new HashSet();
  String[] tries={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  for (int i=0; i < tries.length; i++) {
    try {
      MessageDigest.getInstance(tries[i]);
      algs.add(tries[i]);
    }
 catch (    Exception x) {
    }
  }
  return (String[])algs.toArray(tries);
}
Program: 81234
Project: 81234
Buggy source:
@Test(expected=NotAuthorizedException.class) public void testNotAutorizedException(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse("String_Node_Str",responseHeaders,HttpStatus.valueOf(401),"String_Node_Str"));
  yammerTemplate.userOperations().getUsers(1);
}

Fixed version (ground truth):
@Test(expected=NotAuthorizedException.class) public void testNotAutorizedException(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withStatus(UNAUTHORIZED));
  yammerTemplate.userOperations().getUsers(1);
}
Program: 81235
Project: 81235
Buggy source:
@Test(expected=RateLimitExceededException.class) public void testRateLimitExceeded() throws IOException {
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders,HttpStatus.valueOf(401),"String_Node_Str"));
  yammerTemplate.userOperations().getUsers(1);
}

Fixed version (ground truth):
/** 
 * Tests that 401 is interpreted as rate limit exceeded if json body returned indicates so. According to Yammer API doc 403 will be returned if rate limit is exceeded, empiric evidence suggests otherwise.
 * @throws IOException
 */
@Test(expected=RateLimitExceededException.class) public void testRateLimitExceeded() throws IOException {
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withStatus(UNAUTHORIZED).body(jsonResource("String_Node_Str")).contentType(MediaType.APPLICATION_JSON));
  yammerTemplate.userOperations().getUsers(1);
}
Program: 81236
Project: 81236
Buggy source:
@Test public void testCreateGroup(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(POST)).andRespond(withResponse("String_Node_Str",responseHeaders));
  yammerTemplate.groupOperations().createGroup("String_Node_Str",false);
}

Fixed version (ground truth):
@Test public void testCreateGroup(){
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(POST)).andRespond(withSuccess("String_Node_Str",MediaType.TEXT_PLAIN));
  yammerTemplate.groupOperations().createGroup("String_Node_Str",false);
}
Program: 81237
Project: 81237
Buggy source:
@Test public void testJoinGroup(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(POST)).andRespond(withResponse("String_Node_Str",responseHeaders));
  yammerTemplate.groupOperations().joinGroup(1234L);
}

Fixed version (ground truth):
@Test public void testJoinGroup(){
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(POST)).andRespond(withSuccess("String_Node_Str",MediaType.TEXT_PLAIN));
  yammerTemplate.groupOperations().joinGroup(1234L);
}
Program: 81238
Project: 81238
Buggy source:
@Test public void testGetGroups_withNullParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,null,null,false);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
  assertThat(groups.get(0).getLastMessageAt(),notNullValue());
}

Fixed version (ground truth):
@Test public void testGetGroups_withNullParams(){
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withSuccess(jsonResource("String_Node_Str"),APPLICATION_JSON));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,null,null,false);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
  assertThat(groups.get(0).getLastMessageAt(),notNullValue());
}
Program: 81239
Project: 81239
Buggy source:
@Test public void testGetGroup(){
  Long id=4022983L;
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str" + id + "String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  Group group=yammerTemplate.groupOperations().getGroup(id);
  assertThat(group.getFullName(),equalTo("String_Node_Str"));
  assertThat(group.getLastMessageAt(),notNullValue());
}

Fixed version (ground truth):
@Test public void testGetGroup(){
  Long id=4022983L;
  mockServer.expect(requestTo("String_Node_Str" + id + "String_Node_Str")).andExpect(method(GET)).andRespond(withSuccess(jsonResource("String_Node_Str"),APPLICATION_JSON));
  Group group=yammerTemplate.groupOperations().getGroup(id);
  assertThat(group.getFullName(),equalTo("String_Node_Str"));
  assertThat(group.getLastMessageAt(),notNullValue());
}
Program: 81240
Project: 81240
Buggy source:
@Test public void testGetGroups_withAllParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,'A',GroupOperations.SORT_BY_PRIVACY,true);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testGetGroups_withAllParams(){
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withSuccess(jsonResource("String_Node_Str"),APPLICATION_JSON));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,'A',GroupOperations.SORT_BY_PRIVACY,true);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
}
Program: 81241
Project: 81241
Buggy source:
@Test public void testLeaveGroup(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(DELETE)).andRespond(withResponse("String_Node_Str",responseHeaders));
  yammerTemplate.groupOperations().leaveGroup(1234L);
}

Fixed version (ground truth):
@Test public void testLeaveGroup(){
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(DELETE)).andRespond(withSuccess("String_Node_Str",MediaType.TEXT_PLAIN));
  yammerTemplate.groupOperations().leaveGroup(1234L);
}
Program: 81242
Project: 81242
Buggy source:
public GroupStats(int updates,int members){
  this.updates=updates;
  this.members=members;
}

Fixed version (ground truth):
public GroupStats(int updates,int members,Date lastMessageAt,long lastMessageId){
  this.updates=updates;
  this.members=members;
  this.lastMessageAt=lastMessageAt;
  this.lastMessageId=lastMessageId;
}
Program: 81243
Project: 81243
Buggy source:
@JsonCreator GroupStatsMixin(@JsonProperty("String_Node_Str") int members,@JsonProperty("String_Node_Str") int updates){
}

Fixed version (ground truth):
@JsonCreator GroupStatsMixin(@JsonProperty("String_Node_Str") int members,@JsonProperty("String_Node_Str") int updates,@JsonProperty("String_Node_Str") @JsonDeserialize(using=YammerDateDeserializer.class) Date lastMessageAt,@JsonProperty("String_Node_Str") long lastMessageId){
}
Program: 81244
Project: 81244
Buggy source:
@Test public void testGetGroups_withNullParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,null,null,false);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testGetGroups_withNullParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,null,null,false);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
  assertThat(groups.get(0).getLastMessageAt(),notNullValue());
}
Program: 81245
Project: 81245
Buggy source:
@Test public void testGetGroup(){
  Long id=4022983L;
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str" + id + "String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  Group group=yammerTemplate.groupOperations().getGroup(id);
  assertThat(group.getFullName(),equalTo("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testGetGroup(){
  Long id=4022983L;
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str" + id + "String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(jsonResource("String_Node_Str"),responseHeaders));
  Group group=yammerTemplate.groupOperations().getGroup(id);
  assertThat(group.getFullName(),equalTo("String_Node_Str"));
  assertThat(group.getLastMessageAt(),notNullValue());
}
Program: 81246
Project: 81246
Buggy source:
private boolean isFollowing(URI url){
  try {
    restTemplate.getForObject(url,String.class);
    return true;
  }
 catch (  HttpClientErrorException ex) {
    if (ex.getStatusCode() == HttpStatus.NOT_FOUND) {
      return false;
    }
 else {
      throw ex;
    }
  }
}

Fixed version (ground truth):
private boolean isFollowing(URI url){
  try {
    restTemplate.getForObject(url,String.class);
    return true;
  }
 catch (  ResourceNotFoundException ex) {
    return false;
  }
}
Program: 81247
Project: 81247
Buggy source:
public List<Group> getGroups(int page,Character letter,String sortBy,boolean reverse){
  MultiValueMap<String,String> params=new LinkedMultiValueMap<String,String>();
  params.set("String_Node_Str",String.valueOf(page));
  if (sortBy != null) {
    params.set("String_Node_Str",GroupOperations.SORT_BY_PRIVACY);
  }
  params.set("String_Node_Str",String.valueOf(reverse));
  if (letter != null) {
    params.set("String_Node_Str",String.valueOf(letter));
  }
  return restTemplate.getForObject(buildUri("String_Node_Str",params),GroupList.class);
}

Fixed version (ground truth):
public List<Group> getGroups(int page,Character letter,String sortBy,boolean reverse){
  MultiValueMap<String,String> params=new LinkedMultiValueMap<String,String>();
  params.set("String_Node_Str",String.valueOf(page));
  if (sortBy != null) {
    params.set("String_Node_Str",sortBy);
  }
  params.set("String_Node_Str",String.valueOf(reverse));
  if (letter != null) {
    params.set("String_Node_Str",String.valueOf(letter));
  }
  return restTemplate.getForObject(buildUri("String_Node_Str",params),GroupList.class);
}
Program: 81248
Project: 81248
Buggy source:
@Test public void testGetGroups_withAllParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(new ClassPathResource("String_Node_Str",getClass()),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,'A',"String_Node_Str",true);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testGetGroups_withAllParams(){
  responseHeaders.setContentType(MediaType.APPLICATION_JSON);
  mockServer.expect(requestTo("String_Node_Str")).andExpect(method(GET)).andRespond(withResponse(new ClassPathResource("String_Node_Str",getClass()),responseHeaders));
  List<Group> groups=yammerTemplate.groupOperations().getGroups(1,'A',GroupOperations.SORT_BY_PRIVACY,true);
  assertThat(groups.get(0).getFullName(),equalTo("String_Node_Str"));
}
Program: 81249
Project: 81249
Buggy source:
public MessageInfo getMessages(long olderThan,long newerThan,String threaded,int limit){
  MultiValueMap<String,String> params=new LinkedMultiValueMap<String,String>();
  if (olderThan != 0) {
    params.set("String_Node_Str",String.valueOf(olderThan));
  }
  if (newerThan != 0) {
    params.set("String_Node_Str",String.valueOf(newerThan));
  }
  if (threaded != null) {
    params.set("String_Node_Str",String.valueOf(threaded));
  }
  if (limit != 0) {
    params.set("String_Node_Str",String.valueOf(limit));
  }
  return restTemplate.getForObject(buildUri("String_Node_Str"),MessageInfo.class);
}

Fixed version (ground truth):
public MessageInfo getMessages(long olderThan,long newerThan,String threaded,int limit){
  MultiValueMap<String,String> params=buildParams(olderThan,newerThan,threaded,limit);
  return restTemplate.getForObject(buildUri("String_Node_Str",params),MessageInfo.class);
}
Program: 81250
Project: 81250
Buggy source:
@Override public EngineEvent listen(){
  if (this.events.isEmpty()) {
synchronized (this.waiter) {
      try {
        this.waiter.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
synchronized (this.events) {
    return this.events.pop();
  }
}

Fixed version (ground truth):
@Override public EngineEvent listen(){
  while (this.events.isEmpty()) {
synchronized (this.waiter) {
      try {
        this.waiter.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
synchronized (this.events) {
    return this.events.pop();
  }
}
Program: 81251
Project: 81251
Buggy source:
private List<Query> readQueries(){
  List<HPCService.Query> qs=new ArrayList<HPCService.Query>();
  String queryFile=System.getProperty("String_Node_Str");
  if (!queryFile.startsWith("String_Node_Str")) {
    String currentPath=System.getProperty("String_Node_Str");
    queryFile=currentPath + (currentPath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str") + queryFile;
  }
  String queryContents=getContents(new File(queryFile));
  String[] vals=queryContents.split("String_Node_Str");
  for (int i=0; i < vals.length; i+=3) {
    String name=vals[i].replaceAll("String_Node_Str","String_Node_Str");
    String node=vals[i + 1];
    String script=vals[i + 2].replaceAll("String_Node_Str","String_Node_Str");
    Query q=new Query(name,node,script);
    qs.add(q);
  }
  return qs;
}

Fixed version (ground truth):
private List<Query> readQueries(){
  List<HPCService.Query> qs=new ArrayList<HPCService.Query>();
  String queryFile=System.getProperty("String_Node_Str");
  if (!queryFile.startsWith("String_Node_Str")) {
    String currentPath=System.getProperty("String_Node_Str");
    queryFile=currentPath + (currentPath.endsWith("String_Node_Str") ? "String_Node_Str" : "String_Node_Str") + queryFile;
  }
  String queryContents=getContents(new File(queryFile));
  String[] vals=queryContents.split("String_Node_Str");
  for (int i=0; i < vals.length; i+=3) {
    String name=vals[i].replaceAll("String_Node_Str","String_Node_Str");
    String node=vals[i + 1].equals("String_Node_Str") ? null : vals[i + 1];
    String script=vals[i + 2].replaceAll("String_Node_Str","String_Node_Str");
    Query q=new Query(name,node,script);
    qs.add(q);
  }
  return qs;
}
Program: 81252
Project: 81252
Buggy source:
@Override public void run(){
  while (true) {
    EngineEvent event=engine.listen();
    if (event == EngineEvent.TICK_END) {
      saveResults(runQueries());
      engine.wake();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (true) {
    EngineEvent event=engine.listen();
    if (event == EngineEvent.TICK_END) {
      saveResults(runQueries());
      engine.wake();
    }
    if (engine.getState() == EngineState.STOPPING) {
      engine.release();
      logger.warn("String_Node_Str");
      System.exit(0);
    }
  }
}
Program: 81253
Project: 81253
Buggy source:
public HPCService(){
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("String_Node_Str","String_Node_Str");
  engine=context.getBean(EngineServiceImpl.class);
  try {
    engine.init();
    engine.start();
    db=context.getBean(DbServiceImpl.class);
    if (System.getProperty("String_Node_Str") != null) {
      runId=System.getProperty("String_Node_Str");
    }
 else {
      runId=UUID.randomUUID().toString();
    }
    if (System.getProperty("String_Node_Str") != null) {
      resultsPath=System.getProperty("String_Node_Str");
    }
 else {
      resultsPath="String_Node_Str";
    }
    if (System.getProperty("String_Node_Str") != null) {
      queries=readQueries();
    }
 else {
      queries=Collections.emptyList();
    }
    listener=new EngineListener();
    listener.start();
  }
 catch (  EngineException err) {
    logger.error(err.getMessage());
  }
}

Fixed version (ground truth):
public HPCService(){
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("String_Node_Str","String_Node_Str");
  engine=context.getBean(EngineServiceImpl.class);
  try {
    if (System.getProperty("String_Node_Str") != null) {
      scenarioFilename=System.getProperty("String_Node_Str");
      engine.init(scenarioFilename);
    }
 else {
      engine.init();
    }
    if (System.getProperty("String_Node_Str") != null) {
      runId=System.getProperty("String_Node_Str");
    }
 else {
      runId=UUID.randomUUID().toString();
    }
    logger.warn("String_Node_Str" + engine.getCurrentScenario() + "String_Node_Str"+ runId);
    engine.start();
    db=context.getBean(DbServiceImpl.class);
    if (System.getProperty("String_Node_Str") != null) {
      resultsPath=System.getProperty("String_Node_Str");
    }
 else {
      resultsPath="String_Node_Str";
    }
    if (System.getProperty("String_Node_Str") != null) {
      queries=readQueries();
    }
 else {
      queries=Collections.emptyList();
    }
    listener=new EngineListener();
    listener.start();
  }
 catch (  EngineException err) {
    logger.error(err.getMessage());
  }
}
Program: 81254
Project: 81254
Buggy source:
private int findRole(String name){
  int i=0;
  for (  RoleAgent ba : roleList) {
    String n=ba.getName();
    if (n != null && n.equals(name)) {
      return i;
    }
    i++;
  }
  return -1;
}

Fixed version (ground truth):
private int findRole(String name){
  int i=0;
  int index=-1;
  for (  RoleAgent ba : roleList) {
    String n=ba.getName();
    if (n != null && n.equals(name)) {
      index=i;
    }
    i++;
  }
  return index;
}
Program: 81255
Project: 81255
Buggy source:
private int findRoleAfterMe(String name){
  for (  RoleAgent ba : roleList) {
    String after=ba.getAfter();
    if (after != "String_Node_Str" && after.equals(name)) {
      return roleList.indexOf(ba);
    }
  }
  return -1;
}

Fixed version (ground truth):
private int findRoleAfterMe(String name){
  int index=Integer.MAX_VALUE;
  for (  RoleAgent ba : roleList) {
    String after=ba.getAfter();
    if (after != "String_Node_Str" && after.equals(name)) {
      index=Math.min(index,roleList.indexOf(ba));
    }
  }
  return (index == Integer.MAX_VALUE) ? -1 : index;
}
Program: 81256
Project: 81256
Buggy source:
public void addRole(String name,Role<? extends Agent> role,Agent agent){
  RoleAgent roleAgent=new RoleAgent(name,role,agent);
  boolean first=roleAgent.isFirst();
  boolean last=roleAgent.isLast();
  String after=roleAgent.getAfter();
  if (first) {
    roleList.add(0,roleAgent);
  }
 else   if (last) {
    roleList.add(roleList.size(),roleAgent);
  }
 else   if (after != "String_Node_Str" && findRole(after) >= 0) {
    roleList.add(findRole(after) + 1,roleAgent);
  }
 else {
    int position=findRoleAfterMe(name);
    if (position >= 0) {
      roleList.add(position,roleAgent);
    }
 else {
      int size=roleList.size();
      boolean isLastRole=true;
      while (size > 0 && isLastRole) {
        RoleAgent lastRole=roleList.get(size - 1);
        isLastRole=lastRole.isLast();
        if (isLastRole)         size--;
      }
      roleList.add(size,roleAgent);
    }
  }
}

Fixed version (ground truth):
public void addRole(String name,Role<? extends Agent> role,Agent agent){
  RoleAgent roleAgent=new RoleAgent(name,role,agent);
  boolean first=roleAgent.isFirst();
  boolean last=roleAgent.isLast();
  String after=roleAgent.getAfter();
  if (first) {
    roleList.add(0,roleAgent);
  }
 else   if (last) {
    roleList.add(roleList.size(),roleAgent);
  }
 else   if (after != "String_Node_Str") {
    int afterIndex=findRole(after);
    if (afterIndex >= 0) {
      afterIndex++;
      if (afterIndex >= roleList.size()) {
        roleList.add(roleAgent);
      }
 else {
        roleList.add(afterIndex,roleAgent);
      }
    }
 else {
      roleList.add(roleAgent);
    }
  }
 else {
    int position=findRoleAfterMe(name);
    if (position >= 0) {
      roleList.add(position,roleAgent);
    }
 else {
      int size=roleList.size();
      boolean isLastRole=true;
      while (size > 0 && isLastRole) {
        RoleAgent lastRole=roleList.get(size - 1);
        isLastRole=lastRole.isLast();
        if (isLastRole)         size--;
      }
      roleList.add(size,roleAgent);
    }
  }
}
Program: 81257
Project: 81257
Buggy source:
private String constructQuery(String namespace,String type,String[] filters,String limit,Map<String,String> fieldMap){
  String query="String_Node_Str";
  for (  String field : fieldMap.values()) {
    query+="String_Node_Str" + field;
  }
  query+="String_Node_Str";
  query+="String_Node_Str" + getFullName(type,namespace) + "String_Node_Str";
  for (  Entry<String,String> entry : fieldMap.entrySet()) {
    query+=getFullName(entry.getKey(),namespace) + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
  }
  query=query.substring(0,query.lastIndexOf("String_Node_Str")) + "String_Node_Str";
  if (filters.length > 0) {
    query+="String_Node_Str";
    for (    String filter : filters) {
      query+="String_Node_Str" + getFullName(filter,namespace) + "String_Node_Str";
    }
    query=query.substring(0,query.lastIndexOf("String_Node_Str")) + "String_Node_Str";
  }
  if (limit.length() > 0) {
    query+="String_Node_Str" + limit;
  }
  return query;
}

Fixed version (ground truth):
private String constructQuery(String namespace,String type,String[] filters,String limit,Map<String,String> fieldMap){
  String query="String_Node_Str";
  for (  String field : fieldMap.values()) {
    query+="String_Node_Str" + field;
  }
  query+="String_Node_Str";
  query+="String_Node_Str" + getFullName(type,namespace) + "String_Node_Str";
  for (  Entry<String,String> entry : fieldMap.entrySet()) {
    query+=getFullName(entry.getKey(),namespace) + "String_Node_Str" + entry.getValue()+ "String_Node_Str";
  }
  query=query.substring(0,query.lastIndexOf("String_Node_Str")) + "String_Node_Str";
  if (filters.length > 0) {
    query+="String_Node_Str";
    for (    String filter : filters) {
      query+="String_Node_Str" + getFullName(filter,namespace) + "String_Node_Str";
    }
    query=query.substring(0,query.lastIndexOf("String_Node_Str")) + "String_Node_Str";
  }
  query+="String_Node_Str";
  if (limit.length() > 0) {
    query+="String_Node_Str" + limit;
  }
  return query;
}
Program: 81258
Project: 81258
Buggy source:
@Override public void run(){
  while (Schedule.this.state != EngineState.STOPPING) {
    for (    RoleAgent roleAgent : roleList) {
      Role<? extends Agent> role=roleAgent.getRole();
      Agent agent=roleAgent.getAgent();
      long start=roleAgent.getStart();
      long end=roleAgent.getEnd();
      long timeStep=roleAgent.getTimeStep();
      if (start <= currentTick && (end > currentTick || end == 0) && (currentTick % timeStep == 0)) {
        if (agent != null) {
          agent.act(role);
        }
 else {
          role.act(null);
        }
      }
    }
synchronized (this) {
      if (Schedule.this.state == EngineState.PAUSING) {
        Schedule.this.state=EngineState.PAUSED;
      }
      while (Schedule.this.state == EngineState.PAUSED) {
        try {
          this.wait(100);
        }
 catch (        InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
    }
synchronized (this) {
      for (      SimulationListener listener : Schedule.this.listeners) {
        listener.act(EngineEvent.TICK_END);
      }
      try {
        this.wait();
      }
 catch (      InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    currentTick++;
  }
  Schedule.this.state=EngineState.STOPPED;
}

Fixed version (ground truth):
@Override public void run(){
  while (Schedule.this.state != EngineState.STOPPING) {
    logger.info("String_Node_Str");
    for (    RoleAgent roleAgent : roleList) {
      logger.info("String_Node_Str",roleAgent.getName());
    }
    for (    RoleAgent roleAgent : roleList) {
      Role<? extends Agent> role=roleAgent.getRole();
      Agent agent=roleAgent.getAgent();
      long start=roleAgent.getStart();
      long end=roleAgent.getEnd();
      long timeStep=roleAgent.getTimeStep();
      if (start <= currentTick && (end > currentTick || end == 0) && (currentTick % timeStep == 0)) {
        if (agent != null) {
          agent.act(role);
        }
 else {
          role.act(null);
        }
      }
    }
synchronized (this) {
      if (Schedule.this.state == EngineState.PAUSING) {
        Schedule.this.state=EngineState.PAUSED;
      }
      while (Schedule.this.state == EngineState.PAUSED) {
        try {
          this.wait(100);
        }
 catch (        InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
    }
synchronized (this) {
      for (      SimulationListener listener : Schedule.this.listeners) {
        listener.act(EngineEvent.TICK_END);
      }
      try {
        this.wait();
      }
 catch (      InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    currentTick++;
  }
  Schedule.this.state=EngineState.STOPPED;
}
Program: 81259
Project: 81259
Buggy source:
public void addRole(String name,Role<? extends Agent> role,Agent agent){
  RoleAgent roleAgent=new RoleAgent(name,role,agent);
  boolean first=roleAgent.isFirst();
  boolean last=roleAgent.isLast();
  String after=roleAgent.getAfter();
  if (first) {
    roleList.add(0,roleAgent);
  }
 else   if (last) {
    roleList.add(roleList.size(),roleAgent);
  }
 else   if (after != "String_Node_Str") {
    int afterIndex=findRole(after);
    if (afterIndex >= 0) {
      afterIndex++;
      if (afterIndex >= roleList.size()) {
        roleList.add(roleAgent);
      }
 else {
        roleList.add(afterIndex,roleAgent);
      }
    }
 else {
      roleList.add(roleAgent);
    }
  }
 else {
    int position=findRoleAfterMe(name);
    if (position >= 0) {
      roleList.add(position,roleAgent);
    }
 else {
      int size=roleList.size();
      boolean isLastRole=true;
      while (size > 0 && isLastRole) {
        RoleAgent lastRole=roleList.get(size - 1);
        isLastRole=lastRole.isLast();
        if (isLastRole)         size--;
      }
      roleList.add(size,roleAgent);
    }
  }
}

Fixed version (ground truth):
public void addRole(String name,Role<? extends Agent> role,Agent agent){
  RoleAgent roleAgent=new RoleAgent(name,role,agent);
  boolean first=roleAgent.isFirst();
  boolean last=roleAgent.isLast();
  String after=roleAgent.getAfter();
  if (first) {
    roleList.add(0,roleAgent);
  }
 else   if (last) {
    roleList.add(roleList.size(),roleAgent);
  }
 else   if (after != "String_Node_Str") {
    int afterIndex=findRole(after);
    if (afterIndex >= 0) {
      afterIndex++;
      if (afterIndex >= roleList.size()) {
        roleList.add(roleAgent);
      }
 else {
        roleList.add(afterIndex,roleAgent);
      }
    }
 else {
      int size=roleList.size();
      boolean isLastRole=true;
      while (size > 0 && isLastRole) {
        RoleAgent lastRole=roleList.get(size - 1);
        isLastRole=lastRole.isLast();
        if (isLastRole)         size--;
      }
      roleList.add(size,roleAgent);
    }
  }
 else {
    int position=findRoleAfterMe(name);
    if (position >= 0) {
      roleList.add(position,roleAgent);
    }
 else {
      int size=roleList.size();
      boolean isLastRole=true;
      while (size > 0 && isLastRole) {
        RoleAgent lastRole=roleList.get(size - 1);
        isLastRole=lastRole.isLast();
        if (isLastRole)         size--;
      }
      roleList.add(size,roleAgent);
    }
  }
  logger.info("String_Node_Str",name,roleList.indexOf(roleAgent));
}
Program: 81260
Project: 81260
Buggy source:
public List<Dependency> getLibraryDependencies(){
  List<Dependency> result=new ArrayList<Dependency>();
  for (int i=0; i < getContent().size(); i++) {
    String line=getContent().get(i);
    if (line.trim().startsWith("String_Node_Str")) {
      for (int braces=countBraces(line); braces > 0 && i < getContent().size(); i++) {
        line=line + getContent().get(i);
      }
      for (      String depString : line.split("String_Node_Str")) {
        result.add(getLibraryDependency(depString));
      }
    }
  }
  return result;
}

Fixed version (ground truth):
public List<Dependency> getLibraryDependencies(){
  List<Dependency> result=new ArrayList<Dependency>();
  for (int i=0; i < getContent().size(); i++) {
    String line=getContent().get(i);
    if (line.trim().startsWith("String_Node_Str")) {
      for (int braces=countBraces(line), j=0; braces > 0 && i < getContent().size(); i++, j++) {
        if (j > 0)         line=line + getContent().get(i);
      }
      String[] depStrings=line.split("String_Node_Str");
      if (depStrings.length > 0) {
        for (int count=countBraces(depStrings[0]); count > 0; count--) {
          depStrings[depStrings.length - 1]=removeLast(depStrings[depStrings.length - 1],')');
        }
        for (        String depString : depStrings) {
          result.add(getLibraryDependency(depString));
        }
      }
    }
  }
  return result;
}
Program: 81262
Project: 81262
Buggy source:
public boolean onKeyDown(int keyCode,KeyEvent event){
  if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
    Intent intent;
    intent=new Intent("String_Node_Str");
    getBaseContext().sendBroadcast(intent);
    return true;
  }
 else   if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
    Intent intent;
    intent=new Intent("String_Node_Str");
    getBaseContext().sendBroadcast(intent);
    return true;
  }
 else {
    return super.onKeyDown(keyCode,event);
  }
}

Fixed version (ground truth):
public boolean onKeyDown(int keyCode,KeyEvent event){
  Intent intent;
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
    intent=new Intent("String_Node_Str");
  getBaseContext().sendBroadcast(intent);
return true;
case KeyEvent.KEYCODE_VOLUME_UP:
intent=new Intent("String_Node_Str");
getBaseContext().sendBroadcast(intent);
return true;
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_HOME:
return true;
default :
return super.onKeyDown(keyCode,event);
}
}
Program: 81263
Project: 81263
Buggy source:
public void setCustomBackground(){
  if (utils.getCheckBoxPref(this,LockscreenSettings.KEY_SHOW_CUSTOM_BG,false)) {
    String BG_FILE=getFilesDir().toString() + File.separator + LockscreenSettings.BG_PHOTO_FILE;
    Bitmap bgBitmap=BitmapFactory.decodeFile(BG_FILE);
    BitmapDrawable background=new BitmapDrawable(getResources(),bgBitmap);
    background.setGravity(Gravity.CENTER);
    getWindow().setBackgroundDrawable(background);
  }
 else {
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  }
}

Fixed version (ground truth):
public void setCustomBackground(){
  if (utils.getCheckBoxPref(this,LockscreenSettings.KEY_SHOW_CUSTOM_BG,false)) {
    if (bgBitmap != null) {
      bgBitmap.recycle();
      bgBitmap=null;
      System.gc();
    }
    String BG_FILE=getFilesDir().toString() + File.separator + LockscreenSettings.BG_PHOTO_FILE;
    bgBitmap=BitmapFactory.decodeFile(BG_FILE);
    BitmapDrawable background=new BitmapDrawable(getResources(),bgBitmap);
    background.setGravity(Gravity.CENTER);
    getWindow().setBackgroundDrawable(background);
  }
 else {
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  }
}
Program: 81265
Project: 81265
Buggy source:
/** 
 * Adds the simple attribute content.
 * @param simpleAttributeContent the simple attribute content
 */
public void addSimpleAttributeContent(AttributeElement simpleAttributeContent){
  if (this.simpleAttributeContent == null) {
    this.simpleAttributeContent=new TreeSet<AttributeElement>();
  }
  this.simpleAttributeContent.add(simpleAttributeContent);
}

Fixed version (ground truth):
/** 
 * Adds the simple attribute content.
 * @param simpleAttributeContent the simple attribute content
 */
public void addSimpleAttributeContent(AttributeElement simpleAttributeContent){
  if (this.simpleAttributeContent == null) {
    this.simpleAttributeContent=new LinkedHashSet<AttributeElement>();
  }
  this.simpleAttributeContent.add(simpleAttributeContent);
}
Program: 81267
Project: 81267
Buggy source:
/** 
 * Parses the complex types.
 * @param tagName the tag name
 * @param srcDoc dom handle
 * @param xsdDocument handle parses the complex types, its annotations and populates the xsd
 * @throws XsdDocException 
 */
private void parseComplexTypes(Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{srcDoc,xsdDocument});
  NodeList ctypeElements=srcDoc.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  this.setCtypes(ctypeElements);
  int noOfDomElements=ctypeElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)ctypeElements.item(i);
    String name=obj.getAttribute("String_Node_Str");
    ComplexType cType=Context.getContext().getNewComplexType();
    cType.setName(name);
    cType.setAnnotationInfo(parseAnnotation(obj));
    NamedNodeMap nameNodeMap=obj.getAttributes();
    int size=nameNodeMap.getLength();
    for (int j=0; j < size; j++) {
      Attr attr=(Attr)nameNodeMap.item(j);
      if (attr != null) {
        Attribute attribute=new Attribute();
        attribute.setName(attr.getName());
        attribute.setValue(attr.getValue());
        cType.getAttributes().add(attribute);
      }
    }
    cType.setChildElements(this.parseChildElements(cType,ctypeElements,obj,xsdDocument));
    List<Element> instances=(List<Element>)typeElementsMap.get(name);
    if (instances != null) {
      cType.setInstanceElements(instances);
    }
    postProcessComplexType(cType,obj);
    xsdDocument.addComplexType(cType);
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
}

Fixed version (ground truth):
/** 
 * Parses the complex types.
 * @param tagName the tag name
 * @param srcDoc dom handle
 * @param xsdDocument handle parses the complex types, its annotations and populates the xsd
 * @throws XsdDocException 
 */
private void parseComplexTypes(Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{srcDoc,xsdDocument});
  NodeList ctypeElements=srcDoc.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  this.setCtypes(ctypeElements);
  int noOfDomElements=ctypeElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)ctypeElements.item(i);
    xsdDocument.addComplexType(processComplexType(xsdDocument,obj));
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
}
Program: 81273
Project: 81273
Buggy source:
public synchronized XSDDocInterface parse(String url) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",url);
  XSDDocument xsdDocument=Context.getContext().getNewXsdDocument();
  try {
    URL file=new URL(url);
    Document doc=initialize(file);
    xsdDocument.setDocumentURL(file);
    mergeImportedXsd(doc,xsdDocument,"String_Node_Str");
    if (doc != null) {
      this.visit(doc);
      this.parseAllNSElements(doc,xsdDocument);
      this.parseAllNSComplexTypes(doc,xsdDocument);
      this.linkChildTypes(xsdDocument);
      this.parseAllNSSimpleTypes(doc,xsdDocument);
      this.buildElementToTypeMap(xsdDocument);
      mergeImportedXsd(doc,xsdDocument,"String_Node_Str");
      handleAnonymous(doc,xsdDocument);
    }
  }
 catch (  SAXException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
    throw new ParserException("String_Node_Str" + url + "String_Node_Str"+ e.getMessage(),e);
  }
catch (  IOException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
    throw new ParserException("String_Node_Str" + url + "String_Node_Str"+ e.getMessage(),e);
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
  postProcessXsdDocument(xsdDocument,doc);
  return xsdDocument;
}

Fixed version (ground truth):
public synchronized XSDDocInterface parse(String url) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",url);
  XSDDocument xsdDocument=Context.getContext().getNewXsdDocument();
  try {
    URL file=new URL(url);
    Document doc=initialize(file);
    xsdDocument.setDocumentURL(file);
    if (doc != null) {
      this.visit(doc);
      this.parseAllNSElements(doc,xsdDocument);
      this.parseAllNSComplexTypes(doc,xsdDocument);
      this.linkChildTypes(xsdDocument);
      this.parseAllNSSimpleTypes(doc,xsdDocument);
      this.buildElementToTypeMap(xsdDocument);
      mergeImportedXsd(doc,xsdDocument,"String_Node_Str");
      mergeImportedXsd(doc,xsdDocument,"String_Node_Str");
      handleAnonymous(doc,xsdDocument);
    }
  }
 catch (  SAXException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
    throw new ParserException("String_Node_Str" + url + "String_Node_Str"+ e.getMessage(),e);
  }
catch (  IOException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
    throw new ParserException("String_Node_Str" + url + "String_Node_Str"+ e.getMessage(),e);
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
  postProcessXsdDocument(xsdDocument,doc);
  return xsdDocument;
}
Program: 81277
Project: 81277
Buggy source:
private SimpleType populateSimpleType(XSDDocument xsdDocument,org.w3c.dom.Element obj,boolean fromAttribute) throws ParserException {
  NodeList nodes=obj.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  String base=((org.w3c.dom.Element)nodes.item(0)).getAttribute("String_Node_Str");
  String name=obj.getAttribute("String_Node_Str");
  SimpleType sType=Context.getContext().getNewSimpleType();
  sType.setBase(base);
  sType.setName(name);
  List<Element> instances=(List<Element>)typeElementsMap.get(name);
  NamedNodeMap nameNodeMap=obj.getAttributes();
  int size=nameNodeMap.getLength();
  for (int j=0; j < size; j++) {
    Attr attr=(Attr)nameNodeMap.item(j);
    if (attr != null) {
      Attribute attribute=new Attribute();
      attribute.setName(attr.getName());
      attribute.setValue(attr.getValue());
      sType.getAttributes().add(attribute);
    }
  }
  sType.setAnnotationInfo(parseAnnotation(obj));
  sType.setEnums(this.parseEnumElements(obj,xsdDocument));
  if (instances != null) {
    sType.setInstanceElements(instances);
  }
  if (!fromAttribute) {
    org.w3c.dom.Element parent=(org.w3c.dom.Element)obj.getParentNode();
    if (!parent.getTagName().endsWith("String_Node_Str")) {
      xsdDocument.addSimpleType(sType);
    }
  }
 else {
    xsdDocument.addSimpleType(sType);
  }
  postProcessSimpleType(sType,obj);
  return sType;
}

Fixed version (ground truth):
private SimpleType populateSimpleType(XSDDocument xsdDocument,org.w3c.dom.Element obj,boolean fromAttribute) throws ParserException {
  NodeList nodes=obj.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  String base=((org.w3c.dom.Element)nodes.item(0)).getAttribute("String_Node_Str");
  String name=obj.getAttribute("String_Node_Str");
  SimpleType sType=Context.getContext().getNewSimpleType();
  sType.setBase(base);
  sType.setName(name);
  List<Element> instances=(List<Element>)typeElementsMap.get(name);
  NamedNodeMap nameNodeMap=obj.getAttributes();
  int size=nameNodeMap.getLength();
  for (int j=0; j < size; j++) {
    Attr attr=(Attr)nameNodeMap.item(j);
    if (attr != null) {
      Attribute attribute=new Attribute();
      attribute.setName(attr.getName());
      attribute.setValue(attr.getValue());
      sType.getAttributes().add(attribute);
    }
  }
  sType.setAnnotationInfo(parseAnnotation(obj));
  sType.setEnums(this.parseEnumElements(obj,xsdDocument));
  if (instances != null) {
    sType.setInstanceElements(instances);
  }
  postProcessSimpleType(sType,obj);
  return sType;
}
Program: 81278
Project: 81278
Buggy source:
/** 
 * Parses the simple types.
 * @param tagName the tag name
 * @param srcDoc the src doc
 * @param xsdDocument parses SimpleTypes within the document TBD: has to make it generic across namespaces
 * @throws XsdDocException 
 */
private void parseSimpleTypes(Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{srcDoc,xsdDocument});
  NodeList domElements=srcDoc.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  int noOfDomElements=domElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)domElements.item(i);
    populateSimpleType(xsdDocument,obj,false);
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
}

Fixed version (ground truth):
/** 
 * Parses the simple types.
 * @param tagName the tag name
 * @param srcDoc the src doc
 * @param xsdDocument parses SimpleTypes within the document TBD: has to make it generic across namespaces
 * @throws XsdDocException 
 */
private void parseSimpleTypes(Document srcDoc,XSDDocument xsdDocument) throws ParserException {
  logger.log(Level.FINER,"String_Node_Str",new Object[]{srcDoc,xsdDocument});
  NodeList domElements=srcDoc.getElementsByTagNameNS("String_Node_Str","String_Node_Str");
  int noOfDomElements=domElements.getLength();
  for (int i=0; i < noOfDomElements; i++) {
    org.w3c.dom.Element obj=(org.w3c.dom.Element)domElements.item(i);
    SimpleType sType=populateSimpleType(xsdDocument,obj,false);
    org.w3c.dom.Element parent=(org.w3c.dom.Element)obj.getParentNode();
    if (!parent.getTagName().endsWith("String_Node_Str")) {
      if (Utils.isEmpty(sType.getName())) {
        sType.setName("String_Node_Str" + i);
      }
      xsdDocument.addSimpleType(sType);
    }
  }
  logger.log(Level.FINER,"String_Node_Str",xsdDocument);
}