nus-yam/ex-repair huggingface dataset:
Program: 19880
Project: 19880
Buggy source:
@Override protected void appendCachedData(){
  if (gameListToLoad.size() > 0) {
    @SuppressWarnings("String_Node_Str") ArrayAdapter<Game> wrappedAdapter=(ArrayAdapter<Game>)getWrappedAdapter();
    for (int i=0; i < gameListToLoad.size(); i++) {
      wrappedAdapter.add(gameListToLoad.get(i));
    }
  }
 else   if (searchResultsLoaded) {
    AlertDialog alertDialog=new AlertDialog.Builder(SearchListActivity.this).create();
    alertDialog.setMessage("String_Node_Str");
    alertDialog.setButton("String_Node_Str",new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        finish();
        return;
      }
    }
);
    alertDialog.show();
  }
  if (nextPage >= numPages && numPages != -1)   findViewById(R.id.search_progress).setVisibility(View.GONE);
}

Fixed version (ground truth):
@Override protected void appendCachedData(){
  @SuppressWarnings("String_Node_Str") ArrayAdapter<Game> wrappedAdapter=(ArrayAdapter<Game>)getWrappedAdapter();
  if (gameListToLoad.size() > 0) {
    for (int i=0; i < gameListToLoad.size(); i++) {
      wrappedAdapter.add(gameListToLoad.get(i));
    }
  }
 else   if (searchResultsLoaded && wrappedAdapter.getCount() == 0) {
    AlertDialog alertDialog=new AlertDialog.Builder(SearchListActivity.this).create();
    alertDialog.setMessage("String_Node_Str");
    alertDialog.setButton("String_Node_Str",new DialogInterface.OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        finish();
        return;
      }
    }
);
    alertDialog.show();
  }
  if (nextPage >= numPages && numPages != -1)   findViewById(R.id.search_progress).setVisibility(View.GONE);
}
Program: 19882
Project: 19882
Buggy source:
@Override protected void appendCachedData(){
  if (gameListToLoad.size() > 0) {
    @SuppressWarnings("String_Node_Str") ArrayAdapter<Game> a=(ArrayAdapter<Game>)getWrappedAdapter();
    for (int i=0; i < gameListToLoad.size(); i++) {
      a.add(gameListToLoad.get(i));
      items.add(gameListToLoad.get(i));
    }
  }
}

Fixed version (ground truth):
@Override protected void appendCachedData(){
  if (gameListToLoad.size() > 0) {
    @SuppressWarnings("String_Node_Str") ArrayAdapter<Game> a=(ArrayAdapter<Game>)getWrappedAdapter();
    for (int i=0; i < gameListToLoad.size(); i++) {
      a.add(gameListToLoad.get(i));
    }
  }
}
Program: 19883
Project: 19883
Buggy source:
public SearchAdapter(ArrayList<Game> list){
  super(new ArrayAdapter<Game>(SearchList.this,R.layout.gamerow,android.R.id.text1,list));
  rotate=new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
  rotate.setDuration(600);
  rotate.setRepeatMode(Animation.RESTART);
  rotate.setRepeatCount(Animation.INFINITE);
  items=list;
}

Fixed version (ground truth):
public SearchAdapter(ArrayList<Game> list){
  super(new ArrayAdapter<Game>(SearchList.this,R.layout.pending,android.R.id.text1,list));
  rotate=new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
  rotate.setDuration(600);
  rotate.setRepeatMode(Animation.RESTART);
  rotate.setRepeatCount(Animation.INFINITE);
  items=list;
}
Program: 19886
Project: 19886
Buggy source:
private List<String> stringListFromJson(JSONObject json,String... path) throws JSONException {
  for (int i=0; i < path.length - 1; i++) {
    if (!json.has(path[i])) {
      return null;
    }
    json=json.getJSONObject(path[i]);
  }
  JSONArray playersJSON=json.getJSONArray(path[path.length - 1]);
  List<String> strs=new ArrayList<String>(playersJSON.length());
  for (int i=0; i < playersJSON.length(); i++) {
    strs.add(playersJSON.getString(i));
  }
  return null;
}

Fixed version (ground truth):
private List<String> stringListFromJson(JSONObject json,String... path) throws JSONException {
  for (int i=0; i < path.length - 1; i++) {
    if (!json.has(path[i])) {
      return null;
    }
    json=json.getJSONObject(path[i]);
  }
  JSONArray playersJSON=json.getJSONArray(path[path.length - 1]);
  List<String> strs=new ArrayList<String>(playersJSON.length());
  for (int i=0; i < playersJSON.length(); i++) {
    strs.add(playersJSON.getString(i));
  }
  return strs;
}
Program: 19887
Project: 19887
Buggy source:
public static void main(String[] args){
  if (args.length < 2) {
    System.err.println("String_Node_Str");
    System.exit(1);
  }
  String botName=args[0];
  String devkey=args[1];
  String host=(args.length >= 2) ? args[2] : "String_Node_Str";
  Bot bot=new SimpleBot();
  GameHost gameHost=new RemoteGameHost(botName,devkey,host);
  BotRunner runner=new BotRunner(gameHost,bot);
  runner.play(1);
}

Fixed version (ground truth):
public static void main(String[] args){
  if (args.length < 2) {
    System.err.println("String_Node_Str");
    System.exit(1);
  }
  String botName=args[0];
  String devkey=args[1];
  String host=(args.length > 2) ? args[2] : "String_Node_Str";
  Bot bot=new SimpleBot();
  GameHost gameHost=new RemoteGameHost(botName,devkey,host);
  BotRunner runner=new BotRunner(gameHost,bot);
  runner.play(1);
}
Program: 19888
Project: 19888
Buggy source:
public boolean isTestResult(Object tapResult){
  return (tapResult != null && tapResult instanceof TestResult);
}

Fixed version (ground truth):
/** 
 * @param tapResult the tap result object
 * @return {@code true} if the object is not null and an instance of {@link TestResult}
 */
public boolean isTestResult(Object tapResult){
  return (tapResult != null && tapResult instanceof TestResult);
}
Program: 19889
Project: 19889
Buggy source:
public boolean isBailOut(Object tapResult){
  return (tapResult != null && tapResult instanceof BailOut);
}

Fixed version (ground truth):
/** 
 * @param tapResult the tap result object
 * @return {@code true} if the object is not null and an instance of {@link BailOut}
 */
public boolean isBailOut(Object tapResult){
  return (tapResult != null && tapResult instanceof BailOut);
}
Program: 19890
Project: 19890
Buggy source:
/** 
 * Called from TapResult/index.jelly
 */
public String createDiagnosticTable(String tapFile,Map<String,Object> diagnostic){
  return DiagnosticUtil.createDiagnosticTable(tapFile,diagnostic);
}

Fixed version (ground truth):
/** 
 * Called from TapResult/index.jelly
 * @param tapFile location of TAP file
 * @param diagnostic TAP diagnostics
 * @return diagnostic table
 */
public String createDiagnosticTable(String tapFile,Map<String,Object> diagnostic){
  return DiagnosticUtil.createDiagnosticTable(tapFile,diagnostic);
}
Program: 19891
Project: 19891
Buggy source:
/** 
 * @param fileName
 * @param testSet
 */
public ParseErrorTestSetMap(String fileName,Throwable cause){
  super(fileName,null);
  this.cause=cause;
}

Fixed version (ground truth):
/** 
 * @param fileName TAP file name
 * @param cause {@link Throwable} that caused the TAP parse error
 */
public ParseErrorTestSetMap(String fileName,Throwable cause){
  super(fileName,null);
  this.cause=cause;
}
Program: 19892
Project: 19892
Buggy source:
@Override public float getDuration(){
  Map<String,Object> diagnostic=this.tapTestResult.getDiagnostic();
  if (diagnostic != null && !diagnostic.isEmpty()) {
    Object duration=diagnostic.get(DURATION_KEY);
    if (duration != null) {
      Float durationMS=Float.parseFloat(duration.toString());
      return durationMS.floatValue();
    }
  }
  return super.getDuration();
}

Fixed version (ground truth):
@Override public float getDuration(){
  Map<String,Object> diagnostic=this.tapTestResult.getDiagnostic();
  if (diagnostic != null && !diagnostic.isEmpty()) {
    Object duration=diagnostic.get(DURATION_KEY);
    if (duration != null) {
      Float durationMS=Float.parseFloat(duration.toString());
      return durationMS.floatValue() / 1000;
    }
  }
  return super.getDuration();
}
Program: 19894
Project: 19894
Buggy source:
/** 
 * @param tapDir
 * @param reports
 * @param logger
 * @return
 */
private boolean saveReports(FilePath tapDir,FilePath[] reports,PrintStream logger){
  logger.println("String_Node_Str");
  try {
    tapDir.mkdirs();
    for (    FilePath report : reports) {
      FilePath dst=tapDir.child(report.getName());
      report.copyTo(dst);
    }
  }
 catch (  Exception e) {
    e.printStackTrace(logger);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * @param workspace 
 * @param tapDir
 * @param reports
 * @param logger
 * @return
 */
private boolean saveReports(FilePath workspace,FilePath tapDir,FilePath[] reports,PrintStream logger){
  logger.println("String_Node_Str");
  try {
    tapDir.mkdirs();
    for (    FilePath report : reports) {
      FilePath dst=getDistDir(workspace,tapDir,report);
      report.copyTo(dst);
    }
  }
 catch (  Exception e) {
    e.printStackTrace(logger);
    return false;
  }
  return true;
}
Program: 19895
Project: 19895
Buggy source:
/** 
 * Retrieve index information for a table.
 * @param table the table.
 * @return list of indices.
 * @throws SQLException if thrown by the jdbc driver.
 */
private List<RelationalIndex> getIndices(RelationalTable table) throws SQLException {
  List<RelationalIndex> indices=new ArrayList<>();
  Multimap<String,String> idxColumns=ArrayListMultimap.create();
  ResultSet rs=m_metadataFactory.getMetadata().getIndexInfo(table.getCatalogSchema().getCatalog(),table.getCatalogSchema().getSchema(),table.getName(),false,false);
  while (rs.next()) {
    String idxName=rs.getString(6);
    Collection<String> columns=idxColumns.get(idxName);
    if (columns.isEmpty()) {
      RelationalIndex index=new RelationalIndex(table.getCatalogSchema(),rs.getString(6));
      indices.add(index);
    }
    columns.add(rs.getString(9));
  }
  for (  RelationalIndex index : indices) {
    List<Column> columns=new ArrayList<>(idxColumns.size());
    for (    String columnName : idxColumns.get(index.getName())) {
      Column column=table.getColumnByName(columnName);
      if (column == null) {
        throw new InconsistentSchemaException("String_Node_Str" + columnName + "String_Node_Str"+ index.getName()+ "String_Node_Str"+ table.getName());
      }
      columns.add(column);
    }
    index.setColumns(columns);
  }
  return indices;
}

Fixed version (ground truth):
/** 
 * Retrieve index information for a table.
 * @param table the table.
 * @return list of indices.
 * @throws SQLException if thrown by the jdbc driver.
 */
private List<RelationalIndex> getIndices(RelationalTable table) throws SQLException {
  List<RelationalIndex> indices=new ArrayList<>();
  Multimap<String,String> idxColumns=ArrayListMultimap.create();
  ResultSet rs=m_metadataFactory.getMetadata().getIndexInfo(table.getCatalogSchema().getCatalog(),table.getCatalogSchema().getSchema(),table.getName(),false,false);
  while (rs.next()) {
    String idxName=rs.getString(6);
    Collection<String> columns=idxColumns.get(idxName);
    if (columns.isEmpty()) {
      RelationalIndex index=new RelationalIndex(table.getCatalogSchema(),rs.getString(6));
      indices.add(index);
    }
    columns.add(rs.getString(9));
  }
  for (  RelationalIndex index : indices) {
    List<Column> columns=new ArrayList<>(idxColumns.size());
    for (    String idxColumnName : idxColumns.get(index.getName())) {
      String columnName=idxColumnName.replaceAll("String_Node_Str","String_Node_Str");
      Column column=table.getColumnByName(columnName);
      if (column == null) {
        throw new InconsistentSchemaException("String_Node_Str" + columnName + "String_Node_Str"+ index.getName()+ "String_Node_Str"+ table.getName());
      }
      columns.add(column);
    }
    index.setColumns(columns);
  }
  return indices;
}
Program: 19896
Project: 19896
Buggy source:
/** 
 * Convert a Hibernate foreign key object to a   {@link ForeignKey}.
 * @param mappedKey hibernate foreign key.
 * @return a {@link ForeignKey} representation of the same foreign key.
 */
private ForeignKey convertForeignKey(org.hibernate.mapping.ForeignKey mappedKey){
  org.hibernate.mapping.Column column=mappedKey.getColumn(0);
  org.hibernate.mapping.Table table=mappedKey.getTable();
  org.hibernate.mapping.Table referencedTable=mappedKey.getReferencedTable();
  org.hibernate.mapping.Column referencedColumn;
  if (mappedKey.getReferencedColumns().size() == 0) {
    referencedColumn=referencedTable.getPrimaryKey().getColumn(0);
  }
 else {
    referencedColumn=(org.hibernate.mapping.Column)mappedKey.getReferencedColumns().get(0);
  }
  ForeignKey fkey=new ForeignKey();
  fkey.setFkCatalogSchema(m_catalogSchema);
  fkey.setFkColumn(getColumnName(column));
  fkey.setFkName(mappedKey.getName().toLowerCase());
  fkey.setFkTable(getTableName(table));
  fkey.setKeySeq(DEFAULT_KEY_SEQ);
  fkey.setPkCatalogSchema(m_catalogSchema);
  fkey.setPkColumn(getColumnName(referencedColumn));
  fkey.setPkTable(getTableName(referencedTable));
  return fkey;
}

Fixed version (ground truth):
/** 
 * Convert a Hibernate foreign key object to a   {@link ForeignKey}
 * @param mappedKey hibernate foreign key.
 * @param columnIndex 0-based index of the column in a foreign key.
 * @return a {@link ForeignKey} representation of the same foreign key.
 */
private ForeignKey convertForeignKey(org.hibernate.mapping.ForeignKey mappedKey,int columnIndex){
  org.hibernate.mapping.Column column=mappedKey.getColumn(columnIndex);
  org.hibernate.mapping.Table table=mappedKey.getTable();
  org.hibernate.mapping.Table referencedTable=mappedKey.getReferencedTable();
  org.hibernate.mapping.Column referencedColumn;
  if (mappedKey.getReferencedColumns().size() == 0) {
    referencedColumn=referencedTable.getPrimaryKey().getColumn(columnIndex);
  }
 else {
    referencedColumn=(org.hibernate.mapping.Column)mappedKey.getReferencedColumns().get(columnIndex);
  }
  ForeignKey fkey=new ForeignKey();
  fkey.setFkCatalogSchema(m_catalogSchema);
  fkey.setFkColumn(getColumnName(column));
  fkey.setFkName(mappedKey.getName().toLowerCase());
  fkey.setFkTable(getTableName(table));
  fkey.setKeySeq(String.valueOf(DEFAULT_KEY_SEQ + columnIndex));
  fkey.setPkCatalogSchema(m_catalogSchema);
  fkey.setPkColumn(getColumnName(referencedColumn));
  fkey.setPkTable(getTableName(referencedTable));
  return fkey;
}
Program: 19898
Project: 19898
Buggy source:
public String toString(){
  StringBuilder sb=new StringBuilder();
  if (parentContext != null) {
    sb.append(parentContext.toString());
    sb.append("String_Node_Str");
  }
  if (parentField != null) {
    sb.append(parentField.getId());
    sb.append("String_Node_Str");
  }
  sb.append(topic.getId());
  sb.append("String_Node_Str");
  sb.append(view.getId());
  return sb.toString();
}

Fixed version (ground truth):
public String toString(){
  StringBuilder sb=new StringBuilder();
  if (parentContext != null) {
    sb.append(parentContext.toString());
    sb.append("String_Node_Str");
  }
  if (parentField != null) {
    sb.append(parentField.getId());
    sb.append("String_Node_Str");
  }
  sb.append(topicId);
  sb.append("String_Node_Str");
  sb.append(view.getId());
  return sb.toString();
}
Program: 19899
Project: 19899
Buggy source:
public FieldDataValues setFieldDataValues(PrestoContextRules rules,final PrestoField field,FieldData fieldData,FieldValues fieldValues){
  List<? extends Object> values=fieldValues.getValues();
  if (rules.isSortedField(field)) {
    sortFieldValues(rules,field,values,rules.isSortedAscendingField(field));
  }
  ValueFactory valueFactory=createValueFactory(rules,field);
  int size=values.size();
  int start=0;
  int end=size;
  List<Object> inputValues=new ArrayList<Object>(size);
  List<Value> outputValues=new ArrayList<Value>(size);
  for (int i=start; i < end; i++) {
    Object value=values.get(i);
    if (value != null) {
      Value efv=getExistingFieldValue(valueFactory,rules,field,value);
      outputValues.add(efv);
      inputValues.add(value);
    }
 else {
      size--;
    }
  }
  if (fieldData != null) {
    fieldData.setValues(outputValues);
    if (fieldValues.isPaging() && rules.isPageableField(field) && rules.isSortedField(field)) {
      fieldData.setValuesOffset(fieldValues.getOffset());
      fieldData.setValuesLimit(fieldValues.getLimit());
      fieldData.setValuesTotal(fieldValues.getTotal());
    }
  }
  return new FieldDataValues(inputValues,outputValues);
}

Fixed version (ground truth):
public FieldDataValues setFieldDataValues(PrestoContextRules rules,final PrestoField field,FieldData fieldData,FieldValues fieldValues){
  List<? extends Object> values=fieldValues.getValues();
  if (rules.isSortedField(field)) {
    sortFieldValues(rules,field,values,rules.isSortedAscendingField(field));
  }
  ValueFactory valueFactory=createValueFactory(rules,field);
  int size=values.size();
  int start=0;
  int end=size;
  List<Object> inputValues=new ArrayList<Object>(size);
  List<Value> outputValues=new ArrayList<Value>(size);
  for (int i=start; i < end; i++) {
    Object value=values.get(i);
    if (value != null) {
      Value efv=getExistingFieldValue(valueFactory,rules,field,value);
      outputValues.add(efv);
      inputValues.add(value);
    }
 else {
      size--;
    }
  }
  if (fieldData != null) {
    fieldData.setValues(outputValues);
    if (fieldValues.isPaging() && rules.isPageableField(field) && !rules.isSortedField(field)) {
      fieldData.setValuesOffset(fieldValues.getOffset());
      fieldData.setValuesLimit(fieldValues.getLimit());
      fieldData.setValuesTotal(fieldValues.getTotal());
    }
  }
  return new FieldDataValues(inputValues,outputValues);
}
Program: 19901
Project: 19901
Buggy source:
private static boolean containsAllValues(List<? extends Object> fieldValues,Collection<String> testValues){
  if (fieldValues.isEmpty()) {
    return testValues.isEmpty();
  }
  for (  Object value : fieldValues) {
    String v;
    if (value instanceof PrestoTopic) {
      v=((PrestoTopic)value).getId();
    }
 else {
      v=value.toString();
    }
    if (!testValues.contains(v)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public static boolean containsAllValues(Collection<? extends Object> values,Collection<? extends Object> configValues){
  if (values.isEmpty()) {
    return configValues.isEmpty();
  }
  for (  Object value : values) {
    String v;
    if (value instanceof PrestoTopic) {
      v=((PrestoTopic)value).getId();
    }
 else {
      v=value.toString();
    }
    if (!configValues.contains(v)) {
      return false;
    }
  }
  return true;
}
Program: 19902
Project: 19902
Buggy source:
public static boolean containsFieldValues(PrestoDataProvider dataProvider,PrestoSchemaProvider schemaProvider,PrestoContextRules rules,PrestoField defaultField,ObjectNode config){
  List<? extends Object> values=HasFieldValues.getValues(dataProvider,schemaProvider,rules,defaultField,config);
  Set<String> testValues=getTestValues(config);
  return ContainsFieldValues.containsAllValues(values,testValues);
}

Fixed version (ground truth):
public static boolean containsFieldValues(PrestoDataProvider dataProvider,PrestoSchemaProvider schemaProvider,PrestoContextRules rules,PrestoField defaultField,ObjectNode config){
  List<? extends Object> values=HasFieldValues.getValues(dataProvider,schemaProvider,rules,defaultField,config);
  Set<String> configValues=getConfigValues(config);
  return ContainsFieldValues.containsAllValues(values,configValues);
}
Program: 19903
Project: 19903
Buggy source:
protected PrestoAttributes getAttributes(){
  return new PrestoAttributes(){
    @Override public Object getAttribute(    String name){
      return request.getAttribute(name);
    }
  }
;
}

Fixed version (ground truth):
protected PrestoAttributes getAttributes(){
  return this;
}
Program: 19904
Project: 19904
Buggy source:
@Override public FieldData processFieldData(FieldData fieldData,PrestoContextRules rules,PrestoField field){
  Collection<PrestoType> availableFieldValueTypes=field.getAvailableFieldValueTypes();
  if (availableFieldValueTypes.isEmpty()) {
    throw new RuntimeException("String_Node_Str" + field.getId() + "String_Node_Str");
  }
  PrestoType type=availableFieldValueTypes.iterator().next();
  PrestoView valueView=field.getValueView(type);
  List<PrestoField> fields=type.getFields(valueView);
  List<FieldData> valueFields=new ArrayList<FieldData>();
  for (  PrestoField valueField : fields) {
    FieldData fd=getPresto().getFieldDataNoValues(rules,valueField);
    fd=getPresto().getProcessor().processFieldData(fd,rules,valueField,getType(),getStatus());
    valueFields.add(fd);
  }
  fieldData.setValueFields(valueFields);
  FieldDataValues fieldDataValues=setFieldDataValues(rules,field,fieldData);
  int size=fieldDataValues.size();
  Collection<Value> newValues=new ArrayList<Value>(size);
  for (int i=0; i < size; i++) {
    Object inputValue=fieldDataValues.getInputValue(i);
    Value outputValue=fieldDataValues.getOutputValue(i);
    newValues.add(postProcessValue(rules,field,inputValue,outputValue,fields));
  }
  fieldData.setValues(newValues);
  return fieldData;
}

Fixed version (ground truth):
@Override public FieldData processFieldData(FieldData fieldData,PrestoContextRules rules,PrestoField field){
  Collection<PrestoType> availableFieldValueTypes=field.getAvailableFieldValueTypes();
  if (availableFieldValueTypes.isEmpty()) {
    throw new RuntimeException("String_Node_Str" + field.getId() + "String_Node_Str");
  }
  PrestoType type=availableFieldValueTypes.iterator().next();
  PrestoView valueView=field.getValueView(type);
  List<PrestoField> fields=type.getFields(valueView);
  PrestoContext context=rules.getContext();
  PrestoContext subcontext=PrestoContext.createSubContext(context,context.getParentField(),type,valueView);
  PrestoContextRules subrules=rules.getPrestoContextRules(subcontext);
  List<FieldData> valueFields=new ArrayList<FieldData>();
  for (  PrestoField valueField : fields) {
    if (!subrules.isHiddenField(valueField)) {
      FieldData fd=getPresto().getFieldDataNoValues(rules,valueField);
      fd=getPresto().getProcessor().processFieldData(fd,rules,valueField,getType(),getStatus());
      valueFields.add(fd);
    }
  }
  fieldData.setValueFields(valueFields);
  FieldDataValues fieldDataValues=setFieldDataValues(rules,field,fieldData);
  int size=fieldDataValues.size();
  Collection<Value> newValues=new ArrayList<Value>(size);
  for (int i=0; i < size; i++) {
    Object inputValue=fieldDataValues.getInputValue(i);
    Value outputValue=fieldDataValues.getOutputValue(i);
    newValues.add(postProcessValue(rules,field,inputValue,outputValue,fields));
  }
  fieldData.setValues(newValues);
  return fieldData;
}
Program: 19905
Project: 19905
Buggy source:
@Override public void updateBulk(List<Change> changes){
  for (  Change c : changes) {
switch (c.getType()) {
case CREATE:
      create(c.getTopic());
    break;
case UPDATE:
  update(c.getTopic());
break;
case DELETE:
delete(c.getTopic());
break;
}
}
}

Fixed version (ground truth):
@Override public void updateBulk(List<Change> changes){
  for (  Change c : changes) {
    PrestoTopic topic=c.getTopic();
    if (topic.isInline()) {
      throw new RuntimeException("String_Node_Str" + topic);
    }
switch (c.getType()) {
case CREATE:
      create(topic);
    break;
case UPDATE:
  update(topic);
break;
case DELETE:
delete(topic);
break;
}
}
}
Program: 19906
Project: 19906
Buggy source:
@Override public void save(){
  if (saved) {
    log.warn("String_Node_Str");
    return;
  }
  if (handler != null) {
    handler.onBeforeSave(this,this.getPrestoChanges());
  }
  this.saved=true;
  if (changes.size() == 1) {
    Change change=changes.get(0);
    if (change.isTopicUpdated()) {
      PrestoTopic topic=change.getTopic();
      if (change.getType().equals(Change.Type.CREATE)) {
        dataProvider.create(topic);
      }
 else       if (change.getType().equals(Change.Type.UPDATE)) {
        if (!deleted.contains(topic)) {
          dataProvider.update(topic);
        }
      }
 else       if (change.getType().equals(Change.Type.DELETE)) {
        dataProvider.delete(topic);
      }
    }
  }
 else   if (changes.size() > 1) {
    dataProvider.updateBulk(changes);
  }
  if (handler != null) {
    handler.onAfterSave(this,this.getPrestoChanges());
  }
}

Fixed version (ground truth):
@Override public void save(){
  if (saved) {
    log.warn("String_Node_Str");
    return;
  }
  if (handler != null) {
    handler.onBeforeSave(this,this.getPrestoChanges());
  }
  this.saved=true;
  if (changes.size() == 1) {
    Change change=changes.get(0);
    if (change.isTopicUpdated()) {
      PrestoTopic topic=change.getTopic();
      if (topic.isInline()) {
        throw new RuntimeException("String_Node_Str" + topic);
      }
      if (change.getType().equals(Change.Type.CREATE)) {
        dataProvider.create(topic);
      }
 else       if (change.getType().equals(Change.Type.UPDATE)) {
        if (!deleted.contains(topic)) {
          dataProvider.update(topic);
        }
      }
 else       if (change.getType().equals(Change.Type.DELETE)) {
        dataProvider.delete(topic);
      }
    }
  }
 else   if (changes.size() > 1) {
    dataProvider.updateBulk(changes);
  }
  if (handler != null) {
    handler.onAfterSave(this,this.getPrestoChanges());
  }
}
Program: 19907
Project: 19907
Buggy source:
public Object updateTopicView(PrestoContext context,TopicView topicView,boolean returnParent){
  PrestoContextRules rules=getPrestoContextRules(context);
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,rules,status);
  if (status.isValid()) {
    PrestoTopic updatedTopic=updatePrestoTopic(rules,topicView);
    PrestoContext newContext=updateParentContext(context,updatedTopic);
    if (returnParent) {
      PrestoContext parentContext=context.getParentContext();
      if (parentContext != null) {
        newContext=parentContext;
      }
    }
    PrestoContext parentContext=context.getParentContext();
    if (context.isNewTopic() && parentContext == null) {
      return getTopicAndProcess(newContext);
    }
 else {
      return getTopicViewAndProcess(newContext);
    }
  }
 else {
    return processor.postProcessTopicView(topicView,rules,null);
  }
}

Fixed version (ground truth):
public Object updateTopicView(PrestoContext context,TopicView topicView,boolean returnParent){
  PrestoContextRules rules=getPrestoContextRules(context);
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,rules,status);
  if (status.isValid()) {
    PrestoTopic updatedTopic=updatePrestoTopic(rules,topicView);
    PrestoContext newContext=updateParentContext(context,updatedTopic);
    if (returnParent) {
      PrestoContext parentContext=newContext.getParentContext();
      if (parentContext != null) {
        newContext=parentContext;
      }
    }
    PrestoContext parentContext=context.getParentContext();
    if (context.isNewTopic() && parentContext == null) {
      return getTopicAndProcess(newContext);
    }
 else {
      return getTopicViewAndProcess(newContext);
    }
  }
 else {
    return processor.postProcessTopicView(topicView,rules,null);
  }
}
Program: 19908
Project: 19908
Buggy source:
private PrestoTopic updateContextFieldValues(PrestoContext context,PrestoFieldUsage field,List<? extends Object> updateableValues){
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoUpdate update=changeSet.updateTopic(topic,type);
  PrestoContextRules rules=getPrestoContextRules(context);
  List<? extends Object> existingValues=topic.getValues(field);
  boolean includeExisting=true;
  Collection<? extends Object> newValues=mergeInlineTopics(updateableValues,existingValues,includeExisting);
  filterNonStorableFieldValues(rules,field,newValues);
  update.setValues(field,newValues);
  changeSet.save();
  return update.getTopicAfterSave();
}

Fixed version (ground truth):
private PrestoTopic updateContextFieldValues(PrestoContext context,PrestoFieldUsage field,List<? extends Object> updateableValues){
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoContextRules rules=getPrestoContextRules(context);
  List<? extends Object> existingValues=topic.getValues(field);
  boolean includeExisting=true;
  Collection<? extends Object> newValues=mergeInlineTopics(updateableValues,existingValues,includeExisting);
  filterNonStorableFieldValues(rules,field,newValues);
  if (topic.isInline()) {
    PrestoInlineTopicBuilder builder=dataProvider.createInlineTopic(type,topic.getId());
    builder.setValues(field,newValues);
    PrestoTopic newTopic=builder.build();
    return mergeInlineTopic(newTopic,topic);
  }
 else {
    PrestoDataProvider dataProvider=getDataProvider();
    PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
    PrestoUpdate update=changeSet.updateTopic(topic,type);
    update.setValues(field,newValues);
    changeSet.save();
    return update.getTopicAfterSave();
  }
}
Program: 19909
Project: 19909
Buggy source:
@Override public PrestoTopic getTopicAfterSave(){
  return topic.getDataProvider().getTopicById(topic.getId());
}

Fixed version (ground truth):
@Override public PrestoTopic getTopicAfterSave(){
  if (topic.isInline()) {
    return topic;
  }
 else {
    return topic.getDataProvider().getTopicById(topic.getId());
  }
}
Program: 19911
Project: 19911
Buggy source:
public PrestoTopic addFieldValues(PrestoContextRules rules,PrestoFieldUsage field,List<? extends Object> addableValues,Integer index){
  validateAddableFieldValues(rules,field,addableValues);
  PrestoContext context=rules.getContext();
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoUpdate update=changeSet.updateTopic(topic,type);
  if (index == null) {
    update.addValues(field,addableValues);
  }
 else {
    update.addValues(field,addableValues,index);
  }
  changeSet.save();
  return update.getTopicAfterSave();
}

Fixed version (ground truth):
public PrestoContext addFieldValues(PrestoContextRules rules,PrestoFieldUsage field,List<? extends Object> addableValues,Integer index){
  validateAddableFieldValues(rules,field,addableValues);
  PrestoContext context=rules.getContext();
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoUpdate update=changeSet.updateTopic(topic,type);
  if (index == null) {
    update.addValues(field,addableValues);
  }
 else {
    update.addValues(field,addableValues,index);
  }
  changeSet.save();
  PrestoTopic updatedTopic=update.getTopicAfterSave();
  return updateParentContext(rules.getContext(),updatedTopic);
}
Program: 19912
Project: 19912
Buggy source:
public Object updateTopicView(PrestoContext context,TopicView topicView,boolean returnParent){
  PrestoContextRules rules=getPrestoContextRules(context);
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,rules,status);
  if (status.isValid()) {
    PrestoTopic result=updatePrestoTopic(rules,topicView);
    PrestoContext parentContext=context.getParentContext();
    PrestoFieldUsage parentField=context.getParentField();
    PrestoContext newContext;
    if (parentContext != null && returnParent) {
      PrestoTopic updatedParent=updateFieldValues(parentContext,parentField,Collections.singletonList(result));
      newContext=PrestoContext.newContext(parentContext,updatedParent);
    }
 else {
      newContext=PrestoContext.createSubContext(parentContext,parentField,result,context.getType(),context.getView());
    }
    if (context.isNewTopic() && parentContext == null) {
      return getTopicAndProcess(newContext);
    }
 else {
      return getTopicViewAndProcess(newContext);
    }
  }
 else {
    return processor.postProcessTopicView(topicView,rules,null);
  }
}

Fixed version (ground truth):
public Object updateTopicView(PrestoContext context,TopicView topicView,boolean returnParent){
  PrestoContextRules rules=getPrestoContextRules(context);
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,rules,status);
  if (status.isValid()) {
    PrestoTopic updatedTopic=updatePrestoTopic(rules,topicView);
    PrestoContext newContext=updateParentContext(context,updatedTopic);
    if (returnParent) {
      PrestoContext parentContext=context.getParentContext();
      if (parentContext != null) {
        newContext=parentContext;
      }
    }
    PrestoContext parentContext=context.getParentContext();
    if (context.isNewTopic() && parentContext == null) {
      return getTopicAndProcess(newContext);
    }
 else {
      return getTopicViewAndProcess(newContext);
    }
  }
 else {
    return processor.postProcessTopicView(topicView,rules,null);
  }
}
Program: 19914
Project: 19914
Buggy source:
protected PrestoTopic updatePrestoTopic(PrestoContextRules rules,FieldData fieldData){
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoContext context=rules.getContext();
  PrestoType type=context.getType();
  PrestoView view=context.getView();
  boolean filterNonStorable=true;
  boolean validateValueTypes=true;
  if (type.isInline()) {
    throw new RuntimeException("String_Node_Str");
  }
 else {
    PrestoUpdate update;
    if (context.isNewTopic()) {
      update=changeSet.createTopic(type);
    }
 else {
      update=changeSet.updateTopic(context.getTopic(),type);
    }
    String fieldId=fieldData.getId();
    PrestoFieldUsage field=type.getFieldById(fieldId,view);
    if (!rules.isReadOnlyField(field) && !rules.isPageableField(field)) {
      boolean resolveEmbedded=true;
      boolean includeExisting=false;
      List<? extends Object> values=updateAndExtractValuesFromFieldData(rules,field,fieldData,resolveEmbedded,includeExisting,filterNonStorable,validateValueTypes);
      update.setValues(field,values);
    }
    changeSet.save();
    return update.getTopicAfterSave();
  }
}

Fixed version (ground truth):
protected PrestoContext updatePrestoTopic(PrestoContextRules rules,FieldData fieldData){
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoContext context=rules.getContext();
  PrestoType type=context.getType();
  PrestoView view=context.getView();
  boolean filterNonStorable=true;
  boolean validateValueTypes=true;
  if (type.isInline()) {
    throw new RuntimeException("String_Node_Str");
  }
 else {
    PrestoUpdate update;
    if (context.isNewTopic()) {
      update=changeSet.createTopic(type);
    }
 else {
      update=changeSet.updateTopic(context.getTopic(),type);
    }
    String fieldId=fieldData.getId();
    PrestoFieldUsage field=type.getFieldById(fieldId,view);
    if (!rules.isReadOnlyField(field) && !rules.isPageableField(field)) {
      boolean resolveEmbedded=true;
      boolean includeExisting=false;
      List<? extends Object> values=updateAndExtractValuesFromFieldData(rules,field,fieldData,resolveEmbedded,includeExisting,filterNonStorable,validateValueTypes);
      update.setValues(field,values);
    }
    changeSet.save();
    PrestoTopic updatedTopic=update.getTopicAfterSave();
    return updateParentContext(context,updatedTopic);
  }
}
Program: 19915
Project: 19915
Buggy source:
public FieldData updateFieldValues(PrestoContextRules rules,PrestoFieldUsage field,FieldData fieldData){
  PrestoTopic topicAfterSave=updatePrestoTopic(rules,fieldData);
  return getFieldData(topicAfterSave,field);
}

Fixed version (ground truth):
public FieldData updateFieldValues(PrestoContextRules rules,PrestoFieldUsage field,FieldData fieldData){
  PrestoContext updatedContext=updatePrestoTopic(rules,fieldData);
  return getFieldDataAndProcess(updatedContext,field);
}
Program: 19916
Project: 19916
Buggy source:
public PrestoTopic removeFieldValues(PrestoContextRules rules,PrestoFieldUsage field,List<? extends Object> removeableValues){
  validateRemovableFieldValues(rules,field,removeableValues);
  PrestoContext context=rules.getContext();
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoUpdate update=changeSet.updateTopic(topic,type);
  update.removeValues(field,removeableValues);
  changeSet.save();
  return update.getTopicAfterSave();
}

Fixed version (ground truth):
public PrestoContext removeFieldValues(PrestoContextRules rules,PrestoFieldUsage field,List<? extends Object> removeableValues){
  validateRemovableFieldValues(rules,field,removeableValues);
  PrestoContext context=rules.getContext();
  PrestoTopic topic=context.getTopic();
  PrestoType type=context.getType();
  PrestoDataProvider dataProvider=getDataProvider();
  PrestoChangeSet changeSet=dataProvider.newChangeSet(getChangeSetHandler());
  PrestoUpdate update=changeSet.updateTopic(topic,type);
  update.removeValues(field,removeableValues);
  changeSet.save();
  PrestoTopic updatedTopic=update.getTopicAfterSave();
  return updateParentContext(rules.getContext(),updatedTopic);
}
Program: 19918
Project: 19918
Buggy source:
protected PrestoTopic mergeInlineTopic(PrestoTopic t1,PrestoTopic t2){
  String topicId=t1.getId();
  if (Utils.different(topicId,t2.getId())) {
    throw new IllegalArgumentException("String_Node_Str" + topicId + "String_Node_Str"+ t2.getId()+ "String_Node_Str");
  }
  PrestoSchemaProvider schemaProvider=getSchemaProvider();
  PrestoType type=schemaProvider.getTypeById(t1.getTypeId());
  PrestoInlineTopicBuilder builder=dataProvider.createInlineTopic(type,topicId);
  for (  PrestoField field : type.getFields()) {
    boolean hasValue1=t1.hasValue(field);
    boolean hasValue2=t2.hasValue(field);
    if (hasValue1 && hasValue2) {
      if (field.isInline()) {
        Collection<? extends Object> merged=mergeInlineTopics(t1.getValues(field),t2.getValues(field),true);
        builder.setValues(field,merged);
      }
 else {
        builder.setValues(field,t1.getValues(field));
      }
    }
 else     if (hasValue1) {
      builder.setValues(field,t1.getValues(field));
    }
 else     if (hasValue2) {
      builder.setValues(field,t2.getValues(field));
    }
  }
  return builder.build();
}

Fixed version (ground truth):
protected PrestoTopic mergeInlineTopic(PrestoTopic t1,PrestoTopic t2){
  String topicId=t1.getId();
  if (Utils.different(topicId,t2.getId())) {
    throw new IllegalArgumentException("String_Node_Str" + topicId + "String_Node_Str"+ t2.getId()+ "String_Node_Str");
  }
  PrestoSchemaProvider schemaProvider=getSchemaProvider();
  PrestoType type=schemaProvider.getTypeById(t1.getTypeId());
  PrestoInlineTopicBuilder builder=dataProvider.createInlineTopic(type,topicId);
  for (  PrestoField field : type.getFields()) {
    boolean hasValue1=t1.hasValue(field);
    boolean hasValue2=t2.hasValue(field);
    if (hasValue1 && hasValue2) {
      if (field.isInline()) {
        boolean includeExisting=false;
        Collection<? extends Object> merged=mergeInlineTopics(t1.getValues(field),t2.getValues(field),includeExisting);
        builder.setValues(field,merged);
      }
 else {
        builder.setValues(field,t1.getValues(field));
      }
    }
 else     if (hasValue1) {
      builder.setValues(field,t1.getValues(field));
    }
 else     if (hasValue2) {
      builder.setValues(field,t2.getValues(field));
    }
  }
  return builder.build();
}
Program: 19920
Project: 19920
Buggy source:
public TopicView updateTopic(PrestoContext context,TopicView topicView){
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,context,status);
  if (status.isValid()) {
    PrestoTopic result=updatePrestoTopic(context,topicView);
    PrestoContext newContext=PrestoContext.create(this,result,context.getType(),context.getView(),context.isReadOnly());
    TopicView newTopicView=getTopicView(newContext,topicView);
    return processor.postProcessTopicView(newTopicView,context,null);
  }
 else {
    return processor.postProcessTopicView(topicView,context,null);
  }
}

Fixed version (ground truth):
public TopicView updateTopic(PrestoContext context,TopicView topicView){
  Status status=new Status();
  topicView=processor.preProcessTopicView(topicView,context,status);
  if (status.isValid()) {
    PrestoTopic result=updatePrestoTopic(context,topicView);
    PrestoContext parentContext=context.getParentContext();
    PrestoField parentField=context.getParentField();
    PrestoContext newContext=PrestoContext.createSubContext(this,parentContext,parentField,result,context.getType(),context.getView(),context.isReadOnly());
    TopicView newTopicView=getTopicView(newContext,topicView);
    return processor.postProcessTopicView(newTopicView,context,null);
  }
 else {
    return processor.postProcessTopicView(topicView,context,null);
  }
}
Program: 19921
Project: 19921
Buggy source:
public static PrestoContext createSubContext(Presto session,PrestoContext parentContext,PrestoField parentField,PrestoTopic topic,PrestoType type,PrestoView view,boolean readOnly){
  PrestoContext context=new PrestoContext(session,topic,type,view,readOnly);
  context.setParentContext(parentContext,parentField);
  return context;
}

Fixed version (ground truth):
public static PrestoContext createSubContext(Presto session,PrestoContext parentContext,PrestoField parentField,String topicId,String viewId,boolean readOnly){
  PrestoContext context=new PrestoContext(session,topicId,viewId,readOnly);
  context.setParentContext(parentContext,parentField);
  return context;
}
Program: 19922
Project: 19922
Buggy source:
private FieldData addOnChangeLink(FieldData fieldData,PrestoTopic topic,PrestoFieldUsage field){
  Collection<Link> links=fieldData.getLinks();
  if (links == null) {
    links=new LinkedHashSet<Link>();
  }
  Presto presto=getPresto();
  PrestoView view=field.getView();
  UriBuilder builder=UriBuilder.fromUri(presto.getBaseUri()).path("String_Node_Str").path(presto.getDatabaseId()).path(topic.getId()).path(view.getId());
  String href=builder.build().toString();
  Link link=new Link();
  link.setRel("String_Node_Str");
  link.setHref(href);
  if (!links.contains(link)) {
    links.add(link);
  }
  fieldData.setLinks(links);
  return fieldData;
}

Fixed version (ground truth):
private FieldData addOnChangeLink(FieldData fieldData,PrestoTopic topic,PrestoFieldUsage field){
  if (topic != null) {
    Collection<Link> links=fieldData.getLinks();
    if (links == null) {
      links=new LinkedHashSet<Link>();
    }
    Presto presto=getPresto();
    PrestoView view=field.getView();
    UriBuilder builder=UriBuilder.fromUri(presto.getBaseUri()).path("String_Node_Str").path(presto.getDatabaseId()).path(topic.getId()).path(view.getId());
    String href=builder.build().toString();
    Link link=new Link();
    link.setRel("String_Node_Str");
    link.setHref(href);
    if (!links.contains(link)) {
      links.add(link);
    }
    fieldData.setLinks(links);
  }
  return fieldData;
}
Program: 19923
Project: 19923
Buggy source:
private PrestoContext(Presto session,PrestoTopic topic,PrestoType type,PrestoView view,boolean isNewTopic){
  this.topic=topic;
  this.type=type;
  this.view=view;
  this.isNewTopic=false;
}

Fixed version (ground truth):
private PrestoContext(Presto session,PrestoTopic topic,PrestoType type,PrestoView view,boolean isNewTopic){
  this.topic=topic;
  this.type=type;
  this.view=view;
  this.isNewTopic=isNewTopic;
}
Program: 19924
Project: 19924
Buggy source:
protected void aggregateTopicsByType(Collection<PrestoType> types,Collection<PrestoTopic> result){
  Map<String,BasicDBList> collectionKeys=new HashMap<String,BasicDBList>();
  for (  PrestoType type : types) {
    String typeId=type.getId();
    String collectionKey=getCollectionKeyByTopicId(typeId);
    BasicDBList partitionedTypeIds=collectionKeys.get(collectionKey);
    if (partitionedTypeIds == null) {
      partitionedTypeIds=new BasicDBList();
      collectionKeys.put(collectionKey,partitionedTypeIds);
    }
    partitionedTypeIds.add(typeId);
  }
  for (  String collectionKey : collectionKeys.keySet()) {
    JacksonDBCollection<ObjectNode,Object> coll=getCollectionByKey(collectionKey);
    BasicDBList partitionedTypeIds=collectionKeys.get(collectionKey);
    aggregateResult(coll.find(new BasicDBObject("String_Node_Str",new BasicDBObject("String_Node_Str",partitionedTypeIds))),result);
  }
}

Fixed version (ground truth):
protected void aggregateTopicsByType(Collection<PrestoType> types,Collection<PrestoTopic> result){
  Map<String,BasicDBList> collectionKeys=new HashMap<String,BasicDBList>();
  for (  PrestoType type : types) {
    String typeId=type.getId();
    String collectionKey=getCollectionKeyByTypeId(typeId);
    BasicDBList partitionedTypeIds=collectionKeys.get(collectionKey);
    if (partitionedTypeIds == null) {
      partitionedTypeIds=new BasicDBList();
      collectionKeys.put(collectionKey,partitionedTypeIds);
    }
    partitionedTypeIds.add(typeId);
  }
  for (  String collectionKey : collectionKeys.keySet()) {
    JacksonDBCollection<ObjectNode,Object> coll=getCollectionByKey(collectionKey);
    BasicDBList partitionedTypeIds=collectionKeys.get(collectionKey);
    aggregateResult(coll.find(new BasicDBObject("String_Node_Str",new BasicDBObject("String_Node_Str",partitionedTypeIds))),result);
  }
}
Program: 19927
Project: 19927
Buggy source:
@POST @Produces(APPLICATION_JSON_UTF8) @Consumes(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public FieldData addFieldValuesAtIndex(@Context UriInfo uriInfo,@PathParam("String_Node_Str") final String topicMapId,@PathParam("String_Node_Str") final String topicId,@PathParam("String_Node_Str") final String viewId,@PathParam("String_Node_Str") final String fieldId,@QueryParam("String_Node_Str") final Integer index,FieldData jsonObject) throws Exception {
  PrestoSession session=createSession(topicMapId);
  PrestoSchemaProvider schemaProvider=session.getSchemaProvider();
  PrestoDataProvider dataProvider=session.getDataProvider();
  try {
    PrestoTopic topic=dataProvider.getTopicById(topicId);
    PrestoType topicType=schemaProvider.getTypeById(topic.getTypeId());
    PrestoView fieldsView=topicType.getViewById(viewId);
    PrestoFieldUsage field=topicType.getFieldById(fieldId,fieldsView);
    FieldData result=Utils.addFieldValues(uriInfo,session,topic,field,index,jsonObject);
    String id=topic.getId();
    session.commit();
    onTopicUpdated(id);
    return result;
  }
 catch (  Exception e) {
    session.abort();
    throw e;
  }
 finally {
    session.close();
  }
}

Fixed version (ground truth):
@POST @Produces(APPLICATION_JSON_UTF8) @Consumes(MediaType.APPLICATION_JSON) @Path("String_Node_Str") public FieldData addFieldValuesAtIndex(@Context UriInfo uriInfo,@PathParam("String_Node_Str") final String topicMapId,@PathParam("String_Node_Str") final String topicId,@PathParam("String_Node_Str") final String viewId,@PathParam("String_Node_Str") final String fieldId,@PathParam("String_Node_Str") final Integer index,FieldData jsonObject) throws Exception {
  PrestoSession session=createSession(topicMapId);
  PrestoSchemaProvider schemaProvider=session.getSchemaProvider();
  PrestoDataProvider dataProvider=session.getDataProvider();
  try {
    PrestoTopic topic=dataProvider.getTopicById(topicId);
    PrestoType topicType=schemaProvider.getTypeById(topic.getTypeId());
    PrestoView fieldsView=topicType.getViewById(viewId);
    PrestoFieldUsage field=topicType.getFieldById(fieldId,fieldsView);
    FieldData result=Utils.addFieldValues(uriInfo,session,topic,field,index,jsonObject);
    String id=topic.getId();
    session.commit();
    onTopicUpdated(id);
    return result;
  }
 catch (  Exception e) {
    session.abort();
    throw e;
  }
 finally {
    session.close();
  }
}