nus-yam/ex-repair huggingface dataset:
Program: 9055
Project: 9055
Buggy source:
private Node readNode(String path,Revision rev){
  String id=Node.convertPathToDocumentId(path);
  Map<String,Object> map=store.find(DocumentStore.Collection.NODES,id);
  if (map == null) {
    return null;
  }
  if (isDeleted(map,rev)) {
    return null;
  }
  Node n=new Node(path,rev);
  Long w=writeCountIncrements.get(path);
  long writeCount=w == null ? 0 : w;
  for (  String key : map.keySet()) {
    if (key.equals(UpdateOp.WRITE_COUNT)) {
      writeCount+=(Long)map.get(key);
    }
    if (key.startsWith("String_Node_Str")) {
      continue;
    }
    Object v=map.get(key);
    @SuppressWarnings("String_Node_Str") Map<String,String> valueMap=(Map<String,String>)v;
    if (valueMap != null) {
      Revision latestRev=null;
      for (      String r : valueMap.keySet()) {
        Revision propRev=Revision.fromString(r);
        if (includeRevision(propRev,rev)) {
          if (latestRev == null || isRevisionNewer(propRev,latestRev)) {
            latestRev=propRev;
            n.setProperty(key,valueMap.get(r));
          }
        }
      }
    }
  }
  n.setWriteCount(writeCount);
  return n;
}

Fixed version (ground truth):
private Node readNode(String path,Revision rev){
  String id=Node.convertPathToDocumentId(path);
  Map<String,Object> map=store.find(DocumentStore.Collection.NODES,id);
  if (map == null) {
    return null;
  }
  if (isDeleted(map,rev)) {
    return null;
  }
  Node n=new Node(path,rev);
  Long w=writeCountIncrements.get(path);
  long writeCount=w == null ? 0 : w;
  for (  String key : map.keySet()) {
    if (key.equals(UpdateOp.WRITE_COUNT)) {
      writeCount+=(Long)map.get(key);
    }
    if (key.startsWith("String_Node_Str")) {
      continue;
    }
    Object v=map.get(key);
    @SuppressWarnings("String_Node_Str") Map<String,String> valueMap=(Map<String,String>)v;
    if (valueMap != null) {
      String value=getLatestValue(valueMap,rev);
      n.setProperty(key,value);
    }
  }
  n.setWriteCount(writeCount);
  return n;
}
Program: 9056
Project: 9056
Buggy source:
/** 
 * Create an update operation for the given document. The commit root is assumed to be the path, unless this is changed later on.
 * @param path the node path (for nodes)
 * @param key the primary key
 * @param isNew whether this is a new document
 * @param rev the revision
 */
UpdateOp(String path,String key,boolean isNew){
  this.path=path;
  this.key=key;
  this.isNew=isNew;
}

Fixed version (ground truth):
/** 
 * Create an update operation for the given document. The commit root is assumed to be the path, unless this is changed later on.
 * @param path the node path (for nodes)
 * @param key the primary key
 * @param isNew whether this is a new document
 * @param isDelete whether the _deleted property is set 
 * @param rev the revision
 */
UpdateOp(String path,String key,boolean isNew){
  this.path=path;
  this.key=key;
  this.isNew=isNew;
}
Program: 9057
Project: 9057
Buggy source:
@Override public Map<String,Object> createOrUpdate(Collection collection,UpdateOp updateOp){
  log("String_Node_Str",updateOp);
  DBCollection dbCollection=getDBCollection(collection);
  BasicDBObject setUpdates=new BasicDBObject();
  BasicDBObject incUpdates=new BasicDBObject();
  for (  Entry<String,Operation> entry : updateOp.changes.entrySet()) {
    String k=entry.getKey();
    Operation op=entry.getValue();
switch (op.type) {
case SET:
{
        setUpdates.append(k,op.value);
        break;
      }
case INCREMENT:
{
      incUpdates.append(k,op.value);
      break;
    }
case ADD_MAP_ENTRY:
{
    setUpdates.append(k,op.value.toString());
    break;
  }
case REMOVE_MAP_ENTRY:
{
  break;
}
case SET_MAP_ENTRY:
{
String[] kv=k.split("String_Node_Str");
BasicDBObject sub=new BasicDBObject();
sub.put(kv[1],op.value.toString());
setUpdates.append(kv[0],sub);
break;
}
}
}
DBObject query=getByPathQuery(updateOp.key);
BasicDBObject update=new BasicDBObject();
if (!setUpdates.isEmpty()) {
update.append("String_Node_Str",setUpdates);
}
if (!incUpdates.isEmpty()) {
update.append("String_Node_Str",incUpdates);
}
long start=start();
try {
DBObject oldNode=dbCollection.findAndModify(query,null,null,false,update,true,true);
Map<String,Object> map=convertFromDBObject(oldNode);
String path=(String)map.get(UpdateOp.ID);
synchronized (cache) {
cache.put(path,map);
}
log("String_Node_Str",map);
return map;
}
 catch (Exception e) {
throw new MicroKernelException(e);
}
 finally {
end(start);
}
}

Fixed version (ground truth):
@Override public Map<String,Object> createOrUpdate(Collection collection,UpdateOp updateOp){
  log("String_Node_Str",updateOp);
  DBCollection dbCollection=getDBCollection(collection);
  BasicDBObject setUpdates=new BasicDBObject();
  BasicDBObject incUpdates=new BasicDBObject();
  for (  Entry<String,Operation> entry : updateOp.changes.entrySet()) {
    String k=entry.getKey();
    Operation op=entry.getValue();
switch (op.type) {
case SET:
{
        setUpdates.append(k,op.value);
        break;
      }
case INCREMENT:
{
      incUpdates.append(k,op.value);
      break;
    }
case ADD_MAP_ENTRY:
{
    setUpdates.append(k,op.value);
    break;
  }
case REMOVE_MAP_ENTRY:
{
  break;
}
case SET_MAP_ENTRY:
{
String[] kv=k.split("String_Node_Str");
BasicDBObject sub=new BasicDBObject();
sub.put(kv[1],op.value);
setUpdates.append(kv[0],sub);
break;
}
}
}
DBObject query=getByPathQuery(updateOp.key);
BasicDBObject update=new BasicDBObject();
if (!setUpdates.isEmpty()) {
update.append("String_Node_Str",setUpdates);
}
if (!incUpdates.isEmpty()) {
update.append("String_Node_Str",incUpdates);
}
long start=start();
try {
DBObject oldNode=dbCollection.findAndModify(query,null,null,false,update,true,true);
Map<String,Object> map=convertFromDBObject(oldNode);
String path=(String)map.get(UpdateOp.ID);
synchronized (cache) {
cache.put(path,map);
}
log("String_Node_Str",map);
return map;
}
 catch (Exception e) {
throw new MicroKernelException(e);
}
 finally {
end(start);
}
}
Program: 9058
Project: 9058
Buggy source:
@Override public void create(Collection collection,List<UpdateOp> updateOps){
  log("String_Node_Str",updateOps);
  ArrayList<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
  DBObject[] inserts=new DBObject[updateOps.size()];
  for (int i=0; i < updateOps.size(); i++) {
    inserts[i]=new BasicDBObject();
    UpdateOp update=updateOps.get(i);
    Map<String,Object> target=Utils.newMap();
    MemoryDocumentStore.applyChanges(target,update);
    maps.add(target);
    for (    Entry<String,Operation> entry : update.changes.entrySet()) {
      String k=entry.getKey();
      Operation op=entry.getValue();
switch (op.type) {
case SET:
{
          inserts[i].put(k,op.value);
          break;
        }
case INCREMENT:
{
        inserts[i].put(k,op.value);
        break;
      }
case SET_MAP_ENTRY:
case ADD_MAP_ENTRY:
{
      String[] kv=k.split("String_Node_Str");
      DBObject value=new BasicDBObject(kv[1],op.value.toString());
      inserts[i].put(kv[0],value);
      break;
    }
case REMOVE_MAP_ENTRY:
{
  }
}
}
}
DBCollection dbCollection=getDBCollection(collection);
long start=start();
try {
WriteResult writeResult=dbCollection.insert(inserts,WriteConcern.SAFE);
if (writeResult.getError() != null) {
throw new MicroKernelException("String_Node_Str" + writeResult.getError());
}
synchronized (cache) {
for (Map<String,Object> map : maps) {
String path=(String)map.get(UpdateOp.ID);
synchronized (cache) {
  cache.put(path,map);
}
}
}
}
  finally {
end(start);
}
}

Fixed version (ground truth):
@Override public void create(Collection collection,List<UpdateOp> updateOps){
  log("String_Node_Str",updateOps);
  ArrayList<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
  DBObject[] inserts=new DBObject[updateOps.size()];
  for (int i=0; i < updateOps.size(); i++) {
    inserts[i]=new BasicDBObject();
    UpdateOp update=updateOps.get(i);
    Map<String,Object> target=Utils.newMap();
    MemoryDocumentStore.applyChanges(target,update);
    maps.add(target);
    for (    Entry<String,Operation> entry : update.changes.entrySet()) {
      String k=entry.getKey();
      Operation op=entry.getValue();
switch (op.type) {
case SET:
{
          inserts[i].put(k,op.value);
          break;
        }
case INCREMENT:
{
        inserts[i].put(k,op.value);
        break;
      }
case SET_MAP_ENTRY:
case ADD_MAP_ENTRY:
{
      String[] kv=k.split("String_Node_Str");
      DBObject value=new BasicDBObject(kv[1],op.value.toString());
      inserts[i].put(kv[0],value);
      break;
    }
case REMOVE_MAP_ENTRY:
{
  }
}
}
}
DBCollection dbCollection=getDBCollection(collection);
long start=start();
try {
try {
WriteResult writeResult=dbCollection.insert(inserts,WriteConcern.SAFE);
if (writeResult.getError() != null) {
throw new MicroKernelException("String_Node_Str" + writeResult.getError());
}
synchronized (cache) {
for (Map<String,Object> map : maps) {
  String path=(String)map.get(UpdateOp.ID);
synchronized (cache) {
    cache.put(path,map);
  }
}
}
}
 catch (MongoException e) {
throw new MicroKernelException("String_Node_Str",e);
}
}
  finally {
end(start);
}
}
Program: 9059
Project: 9059
Buggy source:
void setProperty(String propertyName,String value){
  properties.put(propertyName,value);
}

Fixed version (ground truth):
void setProperty(String propertyName,String value){
  if (value == null) {
    properties.remove(propertyName);
  }
 else {
    properties.put(propertyName,value);
  }
}
Program: 9060
Project: 9060
Buggy source:
@Override public String getNodes(String path,String revisionId,int depth,long offset,int maxChildNodes,String filter) throws MicroKernelException {
  NodeFilter nodeFilter=filter == null || filter.isEmpty() ? null : NodeFilter.parse(filter);
  if (offset > 0 && nodeFilter != null && nodeFilter.getChildNodeFilter() != null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    Node rootNode=nodeStore.getNodes(path,revisionId,depth,offset,maxChildNodes,filter);
    if (rootNode == null) {
      return null;
    }
    JsopBuilder builder=new JsopBuilder().object();
    JsonUtil.toJson(builder,new MongoNodeState(rootNode),depth,(int)offset,maxChildNodes,true,nodeFilter);
    return builder.endObject().toString();
  }
 catch (  Exception e) {
    throw new MicroKernelException(e);
  }
}

Fixed version (ground truth):
@Override public String getNodes(String path,String revisionId,int depth,long offset,int maxChildNodes,String filter) throws MicroKernelException {
  NodeFilter nodeFilter=filter == null || filter.isEmpty() ? null : NodeFilter.parse(filter);
  if (offset > 0 && nodeFilter != null && nodeFilter.getChildNodeFilter() != null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  try {
    Node rootNode=nodeStore.getNodes(path,revisionId,depth,offset,maxChildNodes,filter);
    if (rootNode == null) {
      return null;
    }
    JsopBuilder builder=new JsopBuilder().object();
    depth=depth == -1 ? Integer.MAX_VALUE : depth;
    JsonUtil.toJson(builder,new MongoNodeState(rootNode),depth,(int)offset,maxChildNodes,true,nodeFilter);
    return builder.endObject().toString();
  }
 catch (  Exception e) {
    throw new MicroKernelException(e);
  }
}
Program: 9061
Project: 9061
Buggy source:
@Test public void depthLimitless() throws Exception {
  SimpleNodeScenario scenario=new SimpleNodeScenario(mk);
  scenario.create();
  JSONObject root=parseJSONObject(mk.getNodes("String_Node_Str",null,3449,0,-1,null));
  assertPropertyValue(root,"String_Node_Str",1L);
  JSONObject a=resolveObjectValue(root,"String_Node_Str");
  assertPropertyValue(a,"String_Node_Str",2L);
  assertPropertyValue(a,"String_Node_Str",1L);
  JSONObject b=resolveObjectValue(a,"String_Node_Str");
  assertPropertyValue(b,"String_Node_Str","String_Node_Str");
  JSONObject c=resolveObjectValue(a,"String_Node_Str");
  assertPropertyValue(c,"String_Node_Str",true);
}

Fixed version (ground truth):
@Test public void depthLimitless() throws Exception {
  SimpleNodeScenario scenario=new SimpleNodeScenario(mk);
  scenario.create();
  JSONObject root=parseJSONObject(mk.getNodes("String_Node_Str",null,-1,0,-1,null));
  assertPropertyValue(root,"String_Node_Str",1L);
  JSONObject a=resolveObjectValue(root,"String_Node_Str");
  assertPropertyValue(a,"String_Node_Str",2L);
  assertPropertyValue(a,"String_Node_Str",1L);
  JSONObject b=resolveObjectValue(a,"String_Node_Str");
  assertPropertyValue(b,"String_Node_Str","String_Node_Str");
  JSONObject c=resolveObjectValue(a,"String_Node_Str");
  assertPropertyValue(c,"String_Node_Str",true);
}
Program: 9062
Project: 9062
Buggy source:
private MongoNode getStoredNode(String path){
  MongoNode node=pathNodeMap.get(path);
  if (node != null) {
    return node;
  }
  NodeExistsCommand existCommand=new NodeExistsCommand(nodeStore,path,headRevisionId);
  existCommand.setBranchId(branchId);
  existCommand.setValidCommits(validCommits);
  boolean exists=false;
  try {
    exists=existCommand.execute();
  }
 catch (  Exception ignore) {
  }
  if (!exists) {
    throw new NotFoundException(path + "String_Node_Str" + headRevisionId);
  }
  node=existCommand.getNode();
  node.removeField("String_Node_Str");
  pathNodeMap.put(path,node);
  return node;
}

Fixed version (ground truth):
private MongoNode getStoredNode(String path,boolean addToMap){
  MongoNode node=pathNodeMap.get(path);
  if (node != null) {
    return node;
  }
  NodeExistsCommand existCommand=new NodeExistsCommand(nodeStore,path,headRevisionId);
  existCommand.setBranchId(branchId);
  boolean exists=false;
  try {
    exists=existCommand.execute();
  }
 catch (  Exception ignore) {
  }
  if (!exists) {
    throw new NotFoundException(path + "String_Node_Str" + headRevisionId);
  }
  node=existCommand.getNode();
  node.removeField("String_Node_Str");
  if (addToMap) {
    pathNodeMap.put(path,node);
  }
  return node;
}
Program: 9063
Project: 9063
Buggy source:
@Override public void visit(MoveNodeInstruction instruction){
  String srcPath=instruction.getSourcePath();
  String destPath=instruction.getDestPath();
  if (PathUtils.isAncestor(srcPath,destPath)) {
    throw new RuntimeException("String_Node_Str" + destPath);
  }
  String srcParentPath=PathUtils.getParentPath(srcPath);
  String srcNodeName=PathUtils.getName(srcPath);
  String destParentPath=PathUtils.getParentPath(destPath);
  String destNodeName=PathUtils.getName(destPath);
  MongoNode srcParent=getStoredNode(srcParentPath);
  if (!srcParent.childExists(srcNodeName)) {
    throw new NotFoundException(srcPath);
  }
  MongoNode destParent=getStoredNode(destParentPath);
  if (destParent.childExists(destNodeName)) {
    throw new RuntimeException("String_Node_Str" + destPath);
  }
  Map<String,MongoNode> nodesToCopy=new FetchNodesActionNew(nodeStore,srcPath,FetchNodesActionNew.LIMITLESS_DEPTH,headRevisionId).execute();
  for (  MongoNode nodeMongo : nodesToCopy.values()) {
    String oldPath=nodeMongo.getPath();
    String oldPathRel=PathUtils.relativize(srcPath,oldPath);
    String newPath=PathUtils.concat(destPath,oldPathRel);
    nodeMongo.setPath(newPath);
    nodeMongo.removeField("String_Node_Str");
    pathNodeMap.put(newPath,nodeMongo);
  }
  MongoNode srcNode=getStoredNode(srcPath);
  MongoNode destNode=getStagedNode(destPath);
  copyStagedChanges(srcNode,destNode);
  getStagedNode(destPath);
  destParent.addChild(destNodeName);
  srcParent.removeChild(srcNodeName);
}

Fixed version (ground truth):
@Override public void visit(MoveNodeInstruction instruction){
  String srcPath=instruction.getSourcePath();
  String destPath=instruction.getDestPath();
  if (PathUtils.isAncestor(srcPath,destPath)) {
    throw new RuntimeException("String_Node_Str" + destPath);
  }
  String srcParentPath=PathUtils.getParentPath(srcPath);
  String srcNodeName=PathUtils.getName(srcPath);
  String destParentPath=PathUtils.getParentPath(destPath);
  String destNodeName=PathUtils.getName(destPath);
  MongoNode srcParent=getStoredNode(srcParentPath);
  if (!srcParent.childExists(srcNodeName)) {
    throw new NotFoundException(srcPath);
  }
  MongoNode destParent=getStoredNode(destParentPath);
  if (destParent.childExists(destNodeName)) {
    throw new RuntimeException("String_Node_Str" + destPath);
  }
  Map<String,MongoNode> nodesToCopy=new FetchNodesActionNew(nodeStore,srcPath,FetchNodesActionNew.LIMITLESS_DEPTH,headRevisionId).execute();
  for (  MongoNode nodeMongo : nodesToCopy.values()) {
    String oldPath=nodeMongo.getPath();
    String oldPathRel=PathUtils.relativize(srcPath,oldPath);
    String newPath=PathUtils.concat(destPath,oldPathRel);
    nodeMongo.setPath(newPath);
    nodeMongo.removeField("String_Node_Str");
    pathNodeMap.put(newPath,nodeMongo);
  }
  MongoNode srcNode=getStoredNode(srcPath,false);
  MongoNode destNode=getStagedNode(destPath);
  copyStagedChanges(srcNode,destNode);
  destParent.addChild(destNodeName);
  srcParent.removeChild(srcNodeName);
}
Program: 9064
Project: 9064
Buggy source:
/** 
 * Read a value and return the raw Json representation.
 * @return the Json representation of the value
 */
public String readRawValue(){
  int start=lastPos;
  while (jsop.charAt(start) <= ' ') {
    start++;
  }
  skipRawValue();
  return jsop.substring(start,lastPos);
}

Fixed version (ground truth):
/** 
 * Read a value and return the raw Json representation. This includes arrays and nested arrays.
 * @return the Json representation of the value
 */
public String readRawValue(){
  int start=lastPos;
  while (start < length && jsop.charAt(start) <= ' ') {
    start++;
  }
  skipRawValue();
  return jsop.substring(start,lastPos);
}
Program: 9065
Project: 9065
Buggy source:
private void skipRawValue(){
switch (currentType) {
case '[':
{
      read();
      int level=0;
      while (true) {
        if (matches(']') && level-- == 0) {
          break;
        }
 else         if (matches('[')) {
          level++;
        }
 else {
          read();
        }
      }
      break;
    }
case '{':
  read();
if (!matches('}')) {
  do {
    skip(STRING);
    read(':');
    skipRawValue();
  }
 while (matches(','));
  read('}');
}
break;
case NULL:
case NUMBER:
case TRUE:
case FALSE:
case COMMENT:
case STRING:
case IDENTIFIER:
read();
break;
default :
throw getFormatException(jsop,pos,"String_Node_Str");
}
}

Fixed version (ground truth):
private void skipRawValue(){
switch (currentType) {
case '[':
{
      int level=0;
      while (true) {
        if (matches(']')) {
          if (--level == 0) {
            break;
          }
        }
 else         if (matches('[')) {
          level++;
        }
 else         if (matches(JsopReader.END)) {
          throw getFormatException(jsop,pos,"String_Node_Str");
        }
 else {
          read();
        }
      }
      break;
    }
case '{':
  read();
if (!matches('}')) {
  do {
    skip(STRING);
    read(':');
    skipRawValue();
  }
 while (matches(','));
  read('}');
}
break;
case NULL:
case NUMBER:
case TRUE:
case FALSE:
case COMMENT:
case STRING:
case IDENTIFIER:
read();
break;
default :
throw getFormatException(jsop,pos,"String_Node_Str");
}
}
Program: 9066
Project: 9066
Buggy source:
/** 
 * Add an asterisk ('[*]') at the given position. This format is used to show where parsing failed in a statement.
 * @param s     the text
 * @param index the position
 * @return the text with asterisk
 */
private static String addAsterisk(String s,int index){
  if (s != null) {
    index=Math.min(index,s.length());
    s=s.substring(0,index) + "String_Node_Str" + s.substring(index);
  }
  return s;
}

Fixed version (ground truth):
/** 
 * Add an asterisk ('[*]') at the given position. This format is used to show where parsing failed in a statement.
 * @param s the text
 * @param index the position
 * @return the text with asterisk
 */
private static String addAsterisk(String s,int index){
  if (s != null) {
    index=Math.min(index,s.length());
    s=s.substring(0,index) + "String_Node_Str" + s.substring(index);
  }
  return s;
}
Program: 9067
Project: 9067
Buggy source:
public static void main(String... args){
  for (int k=0; k < 5; k++) {
    String s="String_Node_Str";
    StopWatch timer=new StopWatch();
    int t2=0;
    for (int i=0; i < 10000000; i++) {
      t2+=JsopBuilder.encode(s).length();
    }
    System.out.println(timer.seconds() + "String_Node_Str" + t2);
  }
}

Fixed version (ground truth):
public static void main(String... args){
  for (int k=0; k < 5; k++) {
    String s="String_Node_Str";
    StopWatch timer=new StopWatch();
    int t2=0;
    for (int i=0; i < 1000000; i++) {
      t2+=JsopBuilder.encode(s).length();
    }
    System.out.println(timer.seconds() + "String_Node_Str" + t2);
  }
}
Program: 9068
Project: 9068
Buggy source:
public void testRawValue(){
  JsopTokenizer t=new JsopTokenizer("String_Node_Str");
  t.read('{');
  assertEquals("String_Node_Str",t.readString());
  t.read(':');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  try {
    t.readRawValue();
    fail();
  }
 catch (  IllegalArgumentException e) {
  }
}

Fixed version (ground truth):
public void testRawValue(){
  JsopTokenizer t;
  t=new JsopTokenizer("String_Node_Str");
  try {
    t.readRawValue();
    fail();
  }
 catch (  IllegalArgumentException e) {
  }
  t=new JsopTokenizer("String_Node_Str");
  try {
    t.readRawValue();
    fail();
  }
 catch (  IllegalArgumentException e) {
  }
  t=new JsopTokenizer("String_Node_Str");
  t.read('{');
  assertEquals("String_Node_Str",t.readString());
  t.read(':');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  assertEquals("String_Node_Str",t.readRawValue());
  t.read(',');
  try {
    t.readRawValue();
    fail();
  }
 catch (  IllegalArgumentException e) {
  }
}
Program: 9069
Project: 9069
Buggy source:
@Override public NodeTypeIterator getDeclaredSubtypes(){
  try {
    Collection<NodeType> types=new ArrayList<NodeType>();
    NodeTypeIterator iterator=manager.getAllNodeTypes();
    while (iterator.hasNext()) {
      NodeType type=iterator.nextNodeType();
      if (type.isNodeType(getName()) && !isNodeType(type.getName())) {
        List<String> declaredSuperTypeNames=Arrays.asList(type.getDeclaredSupertypeNames());
        if (declaredSuperTypeNames.contains(type)) {
          types.add(type);
        }
      }
    }
    return new NodeTypeIteratorAdapter(types);
  }
 catch (  RepositoryException e) {
    throw new IllegalStateException("String_Node_Str" + this,e);
  }
}

Fixed version (ground truth):
@Override public NodeTypeIterator getDeclaredSubtypes(){
  try {
    Collection<NodeType> types=new ArrayList<NodeType>();
    NodeTypeIterator iterator=manager.getAllNodeTypes();
    while (iterator.hasNext()) {
      NodeType type=iterator.nextNodeType();
      String name=type.getName();
      if (type.isNodeType(getName()) && !isNodeType(name)) {
        List<String> declaredSuperTypeNames=Arrays.asList(type.getDeclaredSupertypeNames());
        if (declaredSuperTypeNames.contains(name)) {
          types.add(type);
        }
      }
    }
    return new NodeTypeIteratorAdapter(types);
  }
 catch (  RepositoryException e) {
    throw new IllegalStateException("String_Node_Str" + this,e);
  }
}
Program: 9071
Project: 9071
Buggy source:
/** 
 * Classifies the given set of features.
 * @return The category the set of features is classified as.
 */
@Override public K classify(Collection<T> features){
  SortedSet<Entry<K,Float>> probabilites=this.categoryProbabilities(features);
  if (probabilites.size() > 0)   return probabilites.last().getKey();
  return null;
}

Fixed version (ground truth):
/** 
 * Classifies the given set of features.
 * @return The category the set of features is classified as.
 */
@Override public K classify(Collection<T> features){
  SortedSet<Classification<T,K>> probabilites=this.categoryProbabilities(features);
  System.out.println("String_Node_Str");
  for (  Classification<T,K> prob : probabilites)   System.out.println(prob);
  if (probabilites.size() > 0) {
    System.out.println("String_Node_Str" + probabilites.last().getCategory());
    return probabilites.last().getCategory();
  }
 else {
    System.out.println("String_Node_Str");
  }
  return null;
}
Program: 9072
Project: 9072
Buggy source:
@Override public int compare(Entry<K,Float> o1,Entry<K,Float> o2){
  int toReturn=o1.getValue().compareTo(o2.getValue());
  if ((toReturn == 0) && (o1.getKey() != o2.getKey())) {
    toReturn=-1;
  }
  return toReturn;
}

Fixed version (ground truth):
@Override public int compare(Classification<T,K> o1,Classification<T,K> o2){
  int toReturn=Float.compare(o1.getProbability(),o2.getProbability());
  if ((toReturn == 0) && !o1.getCategory().equals(o2.getCategory()))   toReturn=-1;
  return toReturn;
}
Program: 9073
Project: 9073
Buggy source:
/** 
 * Retrieves a sorted <code>Set</code> of probabilities that the given set of features is classified as the available categories.
 * @param features The set of features to use.
 * @return A sorted <code>Set</code> of category-probability-entries.
 */
private SortedSet<Entry<K,Float>> categoryProbabilities(Collection<T> features){
  SortedSet<Entry<K,Float>> probabilities=new TreeSet<Entry<K,Float>>(new Comparator<Entry<K,Float>>(){
    @Override public int compare(    Entry<K,Float> o1,    Entry<K,Float> o2){
      int toReturn=o1.getValue().compareTo(o2.getValue());
      if ((toReturn == 0) && (o1.getKey() != o2.getKey())) {
        toReturn=-1;
      }
      return toReturn;
    }
  }
);
  for (  K category : this.getCategories())   probabilities.add(new SimpleEntry<K,Float>(category,this.categoryProbability(features,category)));
  return probabilities;
}

Fixed version (ground truth):
/** 
 * Retrieves a sorted <code>Set</code> of probabilities that the given set of features is classified as the available categories.
 * @param features The set of features to use.
 * @return A sorted <code>Set</code> of category-probability-entries.
 */
private SortedSet<Classification<T,K>> categoryProbabilities(Collection<T> features){
  SortedSet<Classification<T,K>> probabilities=new TreeSet<Classification<T,K>>(new Comparator<Classification<T,K>>(){
    @Override public int compare(    Classification<T,K> o1,    Classification<T,K> o2){
      int toReturn=Float.compare(o1.getProbability(),o2.getProbability());
      if ((toReturn == 0) && !o1.getCategory().equals(o2.getCategory()))       toReturn=-1;
      return toReturn;
    }
  }
);
  for (  K category : this.getCategories())   probabilities.add(new Classification<T,K>(features,category,this.categoryProbability(features,category)));
  return probabilities;
}
Program: 9074
Project: 9074
Buggy source:
/** 
 * Train the classifier by telling it that the given features resulted in the given category.
 * @param category The category the features belong to.
 * @param features The features that resulted in the given category.
 */
public void learn(K category,Collection<T> features){
  for (  T feature : features)   this.incrementFeature(feature,category);
  this.incrementCategory(category);
  this.memoryQueue.offer(new Classification<T,K>(features,category));
  if (this.memoryQueue.size() > Classifier.MEMORY_CAPACITY) {
    Classification<T,K> toForget=this.memoryQueue.remove();
    for (    T feature : toForget.getFeatureset())     this.decrementFeature(feature,toForget.getCategory());
    this.decrementCategory(toForget.getCategory());
  }
}

Fixed version (ground truth):
/** 
 * Train the classifier by telling it that the given features resulted in the given category.
 * @param classification The classification to learn.
 */
public void learn(Classification<T,K> classification){
  System.out.println("String_Node_Str" + classification);
  for (  T feature : classification.getFeatureset())   this.incrementFeature(feature,classification.getCategory());
  this.incrementCategory(classification.getCategory());
  this.memoryQueue.offer(classification);
  if (this.memoryQueue.size() > Classifier.MEMORY_CAPACITY) {
    Classification<T,K> toForget=this.memoryQueue.remove();
    System.out.println("String_Node_Str" + toForget);
    for (    T feature : toForget.getFeatureset())     this.decrementFeature(feature,toForget.getCategory());
    this.decrementCategory(toForget.getCategory());
  }
}
Program: 9075
Project: 9075
Buggy source:
/** 
 * Increments the count of a given feature in the given category.  This is equal to telling the classifier, that this feature has occurred in this category.
 * @param feature The feature, which count to increase.
 * @param category The category the feature occurred in.
 */
public void incrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    this.featureCountPerCategory.put(category,new Hashtable<T,Integer>(Classifier.INITIAL_FEATURE_DICTIONARY_CAPACITY));
    features=this.featureCountPerCategory.get(category);
  }
  Integer count=features.get(feature);
  if (count == null) {
    features.put(feature,1);
    count=features.get(feature);
  }
  count++;
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    this.totalFeatureCount.put(feature,1);
    totalCount=this.totalFeatureCount.get(feature);
  }
  totalCount++;
}

Fixed version (ground truth):
/** 
 * Increments the count of a given feature in the given category.  This is equal to telling the classifier, that this feature has occurred in this category.
 * @param feature The feature, which count to increase.
 * @param category The category the feature occurred in.
 */
public void incrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    this.featureCountPerCategory.put(category,new Hashtable<T,Integer>(Classifier.INITIAL_FEATURE_DICTIONARY_CAPACITY));
    features=this.featureCountPerCategory.get(category);
  }
  Integer count=features.get(feature);
  if (count == null) {
    features.put(feature,0);
    count=features.get(feature);
  }
  features.put(feature,++count);
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    this.totalFeatureCount.put(feature,1);
    totalCount=this.totalFeatureCount.get(feature);
  }
  this.totalFeatureCount.put(feature,++totalCount);
}
Program: 9076
Project: 9076
Buggy source:
/** 
 * Increments the count of a given category.  This is equal to telling the classifier, that this category has occurred once more.
 * @param category The category, which count to increase.
 */
public void incrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    this.totalCategoryCount.put(category,1);
    count=this.totalCategoryCount.get(category);
  }
  count++;
}

Fixed version (ground truth):
/** 
 * Increments the count of a given category.  This is equal to telling the classifier, that this category has occurred once more.
 * @param category The category, which count to increase.
 */
public void incrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    this.totalCategoryCount.put(category,1);
    count=this.totalCategoryCount.get(category);
  }
  this.totalCategoryCount.put(category,++count);
}
Program: 9077
Project: 9077
Buggy source:
/** 
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
  BayesClassifier<String,String> classifier=new BayesClassifier<String,String>();
  BufferedReader io=new BufferedReader(new InputStreamReader(System.in));
  String line="String_Node_Str";
  System.out.print("String_Node_Str");
  while ((line=io.readLine()) != null) {
    String[] tokens=line.split("String_Node_Str");
    if (tokens.length < 3) {
      System.out.println("String_Node_Str");
      continue;
    }
    if (tokens[0].startsWith("String_Node_Str")) {
      Collection<String> context=Arrays.asList(Arrays.copyOfRange(tokens,2,tokens.length));
      classifier.learn(tokens[1],context);
      System.out.println("String_Node_Str" + classifier.getCategoriesTotal());
    }
 else     if (tokens[0].startsWith("String_Node_Str")) {
      Collection<String> context=Arrays.asList(Arrays.copyOfRange(tokens,1,tokens.length));
      System.out.println(classifier.classify(context));
    }
    System.out.print("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
  BayesClassifier<String,String> classifier=new BayesClassifier<String,String>();
  BufferedReader io=new BufferedReader(new InputStreamReader(System.in));
  String line="String_Node_Str";
  System.out.print("String_Node_Str");
  while ((line=io.readLine()) != null) {
    String[] tokens=line.split("String_Node_Str");
    if (tokens.length < 3) {
      System.out.println("String_Node_Str");
      continue;
    }
    if (tokens[0].startsWith("String_Node_Str")) {
      Collection<String> context=Arrays.asList(Arrays.copyOfRange(tokens,2,tokens.length));
      classifier.learn(tokens[1],context);
    }
 else     if (tokens[0].startsWith("String_Node_Str")) {
      Collection<String> context=Arrays.asList(Arrays.copyOfRange(tokens,1,tokens.length));
      classifier.classify(context);
    }
    System.out.print("String_Node_Str");
  }
}
Program: 9078
Project: 9078
Buggy source:
/** 
 * Classifies the given set of features.
 * @return The category the set of features is classified as.
 */
@Override public K classify(Collection<T> features){
  SortedSet<Classification<T,K>> probabilites=this.categoryProbabilities(features);
  System.out.println("String_Node_Str");
  for (  Classification<T,K> prob : probabilites)   System.out.println(prob);
  if (probabilites.size() > 0) {
    System.out.println("String_Node_Str" + probabilites.last().getCategory());
    return probabilites.last().getCategory();
  }
 else {
    System.out.println("String_Node_Str");
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Classifies the given set of features.
 * @return The category the set of features is classified as.
 */
@Override public Classification<T,K> classify(Collection<T> features){
  SortedSet<Classification<T,K>> probabilites=this.categoryProbabilities(features);
  if (probabilites.size() > 0) {
    return probabilites.last();
  }
  return null;
}
Program: 9079
Project: 9079
Buggy source:
/** 
 * The classify method.  It will retrieve the most likely category for the features given and depends on the concrete classifier implementation.
 * @param features The features to classify.
 * @return The category most likely.
 */
public abstract K classify(Collection<T> features);

Fixed version (ground truth):
/** 
 * The classify method.  It will retrieve the most likely category for the features given and depends on the concrete classifier implementation.
 * @param features The features to classify.
 * @return The category most likely.
 */
public abstract Classification<T,K> classify(Collection<T> features);
Program: 9080
Project: 9080
Buggy source:
/** 
 * Train the classifier by telling it that the given features resulted in the given category.
 * @param classification The classification to learn.
 */
public void learn(Classification<T,K> classification){
  System.out.println("String_Node_Str" + classification);
  for (  T feature : classification.getFeatureset())   this.incrementFeature(feature,classification.getCategory());
  this.incrementCategory(classification.getCategory());
  this.memoryQueue.offer(classification);
  if (this.memoryQueue.size() > Classifier.MEMORY_CAPACITY) {
    Classification<T,K> toForget=this.memoryQueue.remove();
    System.out.println("String_Node_Str" + toForget);
    for (    T feature : toForget.getFeatureset())     this.decrementFeature(feature,toForget.getCategory());
    this.decrementCategory(toForget.getCategory());
  }
}

Fixed version (ground truth):
/** 
 * Train the classifier by telling it that the given features resulted in the given category.
 * @param classification The classification to learn.
 */
public void learn(Classification<T,K> classification){
  for (  T feature : classification.getFeatureset())   this.incrementFeature(feature,classification.getCategory());
  this.incrementCategory(classification.getCategory());
  this.memoryQueue.offer(classification);
  if (this.memoryQueue.size() > this.memoryCapacity) {
    Classification<T,K> toForget=this.memoryQueue.remove();
    for (    T feature : toForget.getFeatureset())     this.decrementFeature(feature,toForget.getCategory());
    this.decrementCategory(toForget.getCategory());
  }
}
Program: 9081
Project: 9081
Buggy source:
/** 
 * Decrements the count of a given feature in the given category.  This is equal to telling the classifier that this feature was classified once in the category.
 * @param feature The feature to decrement the count for.
 * @param category The category.
 */
public void decrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    return;
  }
  Integer count=features.get(feature);
  if (count == null) {
    return;
  }
  if (count == 1) {
    features.remove(feature);
  }
 else {
    count--;
  }
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    return;
  }
  if (totalCount == 1) {
    this.totalFeatureCount.remove(feature);
  }
 else {
    totalCount--;
  }
}

Fixed version (ground truth):
/** 
 * Decrements the count of a given feature in the given category.  This is equal to telling the classifier that this feature was classified once in the category.
 * @param feature The feature to decrement the count for.
 * @param category The category.
 */
public void decrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    return;
  }
  Integer count=features.get(feature);
  if (count == null) {
    return;
  }
  if (count.intValue() == 1) {
    features.remove(feature);
    if (features.size() == 0) {
      this.featureCountPerCategory.remove(category);
    }
  }
 else {
    features.put(feature,--count);
  }
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    return;
  }
  if (totalCount.intValue() == 1) {
    this.totalFeatureCount.remove(feature);
  }
 else {
    this.totalFeatureCount.put(feature,--totalCount);
  }
}
Program: 9082
Project: 9082
Buggy source:
/** 
 * Increments the count of a given feature in the given category.  This is equal to telling the classifier, that this feature has occurred in this category.
 * @param feature The feature, which count to increase.
 * @param category The category the feature occurred in.
 */
public void incrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    this.featureCountPerCategory.put(category,new Hashtable<T,Integer>(Classifier.INITIAL_FEATURE_DICTIONARY_CAPACITY));
    features=this.featureCountPerCategory.get(category);
  }
  Integer count=features.get(feature);
  if (count == null) {
    features.put(feature,0);
    count=features.get(feature);
  }
  features.put(feature,++count);
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    this.totalFeatureCount.put(feature,1);
    totalCount=this.totalFeatureCount.get(feature);
  }
  this.totalFeatureCount.put(feature,++totalCount);
}

Fixed version (ground truth):
/** 
 * Increments the count of a given feature in the given category.  This is equal to telling the classifier, that this feature has occurred in this category.
 * @param feature The feature, which count to increase.
 * @param category The category the feature occurred in.
 */
public void incrementFeature(T feature,K category){
  Dictionary<T,Integer> features=this.featureCountPerCategory.get(category);
  if (features == null) {
    this.featureCountPerCategory.put(category,new Hashtable<T,Integer>(Classifier.INITIAL_FEATURE_DICTIONARY_CAPACITY));
    features=this.featureCountPerCategory.get(category);
  }
  Integer count=features.get(feature);
  if (count == null) {
    features.put(feature,0);
    count=features.get(feature);
  }
  features.put(feature,++count);
  Integer totalCount=this.totalFeatureCount.get(feature);
  if (totalCount == null) {
    this.totalFeatureCount.put(feature,0);
    totalCount=this.totalFeatureCount.get(feature);
  }
  this.totalFeatureCount.put(feature,++totalCount);
}
Program: 9083
Project: 9083
Buggy source:
/** 
 * Decrements the count of a given category.  This is equal to telling the classifier, that this category has occurred once less.
 * @param category The category, which count to increase.
 */
public void decrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    return;
  }
  if (count == 1) {
    this.totalCategoryCount.remove(category);
  }
 else {
    count--;
  }
}

Fixed version (ground truth):
/** 
 * Decrements the count of a given category.  This is equal to telling the classifier, that this category has occurred once less.
 * @param category The category, which count to increase.
 */
public void decrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    return;
  }
  if (count.intValue() == 1) {
    this.totalCategoryCount.remove(category);
  }
 else {
    this.totalCategoryCount.put(category,--count);
  }
}
Program: 9084
Project: 9084
Buggy source:
/** 
 * Increments the count of a given category.  This is equal to telling the classifier, that this category has occurred once more.
 * @param category The category, which count to increase.
 */
public void incrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    this.totalCategoryCount.put(category,1);
    count=this.totalCategoryCount.get(category);
  }
  this.totalCategoryCount.put(category,++count);
}

Fixed version (ground truth):
/** 
 * Increments the count of a given category.  This is equal to telling the classifier, that this category has occurred once more.
 * @param category The category, which count to increase.
 */
public void incrementCategory(K category){
  Integer count=this.totalCategoryCount.get(category);
  if (count == null) {
    this.totalCategoryCount.put(category,0);
    count=this.totalCategoryCount.get(category);
  }
  this.totalCategoryCount.put(category,++count);
}
Program: 9085
Project: 9085
Buggy source:
public static boolean isFormattedWritable(Application application) throws IOException {
  try {
    TrailerBlock trailerBlock=application.readTrailer(MfClassicConstants.TRANSPORT_KEY);
    for (int dataArea=0; dataArea < 3; dataArea++) {
      if (!trailerBlock.canWriteDataBlock(MfClassicConstants.TRANSPORT_KEY.getKey(),dataArea))       return false;
    }
    if (NfcUtils.getLeastSignificantNibble(trailerBlock.getGeneralPurposeByte()) != 0)     return false;
    return true;
  }
 catch (  MfLoginException e) {
    return false;
  }
}

Fixed version (ground truth):
public static boolean isFormattedWritable(Application application,KeyValue keyValue) throws IOException {
  try {
    TrailerBlock trailerBlock=application.readTrailer(keyValue);
    for (int dataArea=0; dataArea < 3; dataArea++) {
      if (!trailerBlock.canWriteDataBlock(keyValue.getKey(),dataArea))       return false;
    }
    if (NfcUtils.getLeastSignificantNibble(trailerBlock.getGeneralPurposeByte()) != 0)     return false;
    return true;
  }
 catch (  MfLoginException e) {
    return false;
  }
}
Program: 9086
Project: 9086
Buggy source:
protected MfClassicNdefOperations createNdefOperations(ApduTag tag,MemoryLayout memoryLayout){
  boolean formatted=false;
  boolean writable=false;
  MfClassicReaderWriter readerWriter=new AcrMfClassicReaderWriter(tag,memoryLayout);
  try {
    if (readerWriter.hasApplicationDirectory()) {
      ApplicationDirectory applicationDirectory=readerWriter.getApplicationDirectory();
      if (applicationDirectory.hasApplication(MfConstants.NDEF_APP_ID)) {
        formatted=true;
        Application application=applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
        writable=ClassicHandler.isFormattedWritable(application);
      }
 else {
        throw new NfcException("String_Node_Str");
      }
    }
 else {
      if (ClassicHandler.isBlank(readerWriter)) {
        writable=true;
      }
 else       throw new NfcException("String_Node_Str");
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return new MfClassicNdefOperations(readerWriter,formatted,writable);
}

Fixed version (ground truth):
protected MfClassicNdefOperations createNdefOperations(ApduTag tag,MemoryLayout memoryLayout){
  boolean formatted=false;
  boolean writable=false;
  MfClassicReaderWriter readerWriter=new AcrMfClassicReaderWriter(tag,memoryLayout);
  try {
    if (readerWriter.hasApplicationDirectory()) {
      ApplicationDirectory applicationDirectory=readerWriter.getApplicationDirectory();
      if (applicationDirectory.hasApplication(MfConstants.NDEF_APP_ID)) {
        formatted=true;
        Application application=applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
        writable=ClassicHandler.isFormattedWritable(application,MfClassicConstants.NDEF_KEY);
      }
 else {
        throw new NfcException("String_Node_Str");
      }
    }
 else {
      if (ClassicHandler.isBlank(readerWriter)) {
        writable=true;
      }
 else       throw new NfcException("String_Node_Str");
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return new MfClassicNdefOperations(readerWriter,formatted,writable);
}
Program: 9087
Project: 9087
Buggy source:
@Test public void testIsFormattedWritable() throws Exception {
  ApplicationDirectory applicationDirectory=ReaderWriterCreator.createReadWriter("String_Node_Str",MemoryLayout.CLASSIC_1K).getApplicationDirectory();
  assertTrue(ClassicHandler.isFormattedWritable(applicationDirectory.openApplication(MfConstants.NDEF_APP_ID)));
  ApplicationDirectory applicationDirectory2=ReaderWriterCreator.createReadWriter("String_Node_Str",MemoryLayout.CLASSIC_4K).getApplicationDirectory();
  assertTrue(ClassicHandler.isFormattedWritable(applicationDirectory2.openApplication(MfConstants.NDEF_APP_ID)));
}

Fixed version (ground truth):
@Test public void testIsFormattedWritable() throws Exception {
  ApplicationDirectory applicationDirectory=ReaderWriterCreator.createReadWriter("String_Node_Str",MemoryLayout.CLASSIC_1K).getApplicationDirectory();
  assertTrue(ClassicHandler.isFormattedWritable(applicationDirectory.openApplication(MfConstants.NDEF_APP_ID),MfClassicConstants.TRANSPORT_KEY));
  ApplicationDirectory applicationDirectory2=ReaderWriterCreator.createReadWriter("String_Node_Str",MemoryLayout.CLASSIC_4K).getApplicationDirectory();
  assertTrue(ClassicHandler.isFormattedWritable(applicationDirectory2.openApplication(MfConstants.NDEF_APP_ID),MfClassicConstants.NDEF_KEY));
}
Program: 9088
Project: 9088
Buggy source:
@Override public WellKnownRecord decodePayload(byte[] payload,NdefMessageDecoder messageDecoder){
  CollisionResolutionRecord collisionResolutionRecord=new CollisionResolutionRecord();
  collisionResolutionRecord.setRandomNumber((((payload[0] << 8) | payload[1]) & 0xFFFF));
  return collisionResolutionRecord;
}

Fixed version (ground truth):
@Override public WellKnownRecord decodePayload(byte[] payload,NdefMessageDecoder messageDecoder){
  CollisionResolutionRecord collisionResolutionRecord=new CollisionResolutionRecord();
  collisionResolutionRecord.setRandomNumber(((payload[0] & 0xFF) << 8) | (payload[1] & 0xFF));
  return collisionResolutionRecord;
}