nus-yam/ex-repair huggingface dataset:
Program: 45276
Project: 45276
Buggy source:
/** 
 * Effect the move
 * @param board the board
 * @param piece the piece of move
 * @param row row of the move
 * @param col column of the move
 * @return the new board after the move is affected
 */
public static char[][] effectMove(char[][] board,char piece,int row,int col){
  board[row][col]=piece;
  for (int i=0; i < 8; ++i) {
    int curRow=row + sOFFSET_MOVE_ROW[i];
    int curCol=col + sOFFSET_MOVE_COL[i];
    boolean hasOppPieceBetween=false;
    while (curRow >= 0 && curRow < 8 && curCol >= 0 && curCol < 8) {
      if (board[curRow][curCol] == sEMPTY_PIECE)       break;
      if (board[curRow][curCol] != piece)       hasOppPieceBetween=true;
      if ((board[curRow][curCol] == piece) && hasOppPieceBetween) {
        Reversi.getInstance().resetEffectedPieces();
        int effectPieceRow=row + sOFFSET_MOVE_ROW[i];
        int effectPieceCol=col + sOFFSET_MOVE_COL[i];
        while (effectPieceRow != curRow || effectPieceCol != curCol) {
          Reversi.getInstance().setEffectedPiece(effectPieceRow,effectPieceCol);
          board[effectPieceRow][effectPieceCol]=piece;
          effectPieceRow+=sOFFSET_MOVE_ROW[i];
          effectPieceCol+=sOFFSET_MOVE_COL[i];
        }
        break;
      }
      curRow+=sOFFSET_MOVE_ROW[i];
      curCol+=sOFFSET_MOVE_COL[i];
    }
  }
  return board;
}

Fixed version (ground truth):
/** 
 * Effect the move
 * @param board the board
 * @param piece the piece of move
 * @param row row of the move
 * @param col column of the move
 * @return the new board after the move is affected
 */
public static char[][] effectMove(char[][] board,char piece,int row,int col){
  board[row][col]=piece;
  Reversi.getInstance().resetEffectedPieces();
  for (int i=0; i < 8; ++i) {
    int curRow=row + sOFFSET_MOVE_ROW[i];
    int curCol=col + sOFFSET_MOVE_COL[i];
    boolean hasOppPieceBetween=false;
    while (curRow >= 0 && curRow < 8 && curCol >= 0 && curCol < 8) {
      if (board[curRow][curCol] == sEMPTY_PIECE)       break;
      if (board[curRow][curCol] != piece)       hasOppPieceBetween=true;
      if ((board[curRow][curCol] == piece) && hasOppPieceBetween) {
        int effectPieceRow=row + sOFFSET_MOVE_ROW[i];
        int effectPieceCol=col + sOFFSET_MOVE_COL[i];
        while (effectPieceRow != curRow || effectPieceCol != curCol) {
          Reversi.getInstance().setEffectedPiece(effectPieceRow,effectPieceCol);
          board[effectPieceRow][effectPieceCol]=piece;
          effectPieceRow+=sOFFSET_MOVE_ROW[i];
          effectPieceCol+=sOFFSET_MOVE_COL[i];
        }
        break;
      }
      curRow+=sOFFSET_MOVE_ROW[i];
      curCol+=sOFFSET_MOVE_COL[i];
    }
  }
  return board;
}
Program: 45277
Project: 45277
Buggy source:
/** 
 * @param args the command line argumentsusage is: <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy -txtstory ./reports/story-report.txt <p/> You don't need to pass in the file name for the report either-- if no path is present, then the runner will create a report in the current directory with a default filename following this convention: easyb-<type>-report.<format> (for reports of either story or specification) easyb-report.<format> (for reports that contain both) <p/> Multiple specifications can be passed in on the command line <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy my/path/to/spec/AnotherStory.groovy
 */
public static void main(final String[] args){
  final Configuration configuration=new ConsoleConfigurator().configure(args);
  final ConsoleReporter consoleRpt=configuration.getConsoleReporter();
  if (configuration != null) {
    final BehaviorRunner runner=new BehaviorRunner(configuration,consoleRpt);
    try {
      boolean success=runner.runBehaviors(getBehaviors(configuration.getFilePaths(),configuration));
      if (!success) {
        System.exit(-1);
      }
    }
 catch (    Throwable exception) {
      System.err.println("String_Node_Str");
      exception.printStackTrace(System.err);
      System.exit(-1);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param args the command line argumentsusage is: <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy -txtstory ./reports/story-report.txt <p/> You don't need to pass in the file name for the report either-- if no path is present, then the runner will create a report in the current directory with a default filename following this convention: easyb-<type>-report.<format> (for reports of either story or specification) easyb-report.<format> (for reports that contain both) <p/> Multiple specifications can be passed in on the command line <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy my/path/to/spec/AnotherStory.groovy
 */
public static void main(final String[] args){
  final Configuration configuration=new ConsoleConfigurator().configure(args);
  if (configuration != null) {
    final ConsoleReporter consoleRpt=configuration.getConsoleReporter();
    final BehaviorRunner runner=new BehaviorRunner(configuration,consoleRpt);
    try {
      boolean success=runner.runBehaviors(getBehaviors(configuration.getFilePaths(),configuration));
      if (!success) {
        System.exit(-1);
      }
    }
 catch (    Throwable exception) {
      System.err.println("String_Node_Str");
      exception.printStackTrace(System.err);
      System.exit(-1);
    }
  }
}
Program: 45278
Project: 45278
Buggy source:
private static void validateArguments(final CommandLine commandLine) throws IllegalArgumentException {
  if (commandLine.getArgs().length == 0) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
private static void validateArguments(final CommandLine commandLine) throws IllegalArgumentException {
  if (commandLine.getArgs().length == 0) {
    if (!commandLine.hasOption(BEHAVIOR_FILE)) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
  }
}
Program: 45279
Project: 45279
Buggy source:
/** 
 * @param behaviors collection of files that contain the specifications
 * @throws Exception if unable to write report file
 */
public void runBehavior(List<Behavior> behaviors) throws Exception {
  for (  final Behavior behavior : behaviors) {
    behavior.execute(broadcastListener);
  }
  broadcastListener.completeTesting();
  for (  final ReportWriter report : reports) {
    report.writeReport(resultsCollector);
  }
}

Fixed version (ground truth):
/** 
 * @param behaviors collection of files that contain the specifications
 * @throws Exception if unable to write report file
 */
public boolean runBehavior(List<Behavior> behaviors) throws Exception {
  boolean wasSuccessful=true;
  for (  final Behavior behavior : behaviors) {
    behavior.execute(broadcastListener);
  }
  broadcastListener.completeTesting();
  for (  final ReportWriter report : reports) {
    report.writeReport(resultsCollector);
  }
  if (failureDetector.failuresDetected()) {
    wasSuccessful=false;
  }
  return wasSuccessful;
}
Program: 45280
Project: 45280
Buggy source:
/** 
 * @param args the command line argumentsusage is: <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy -txtstory ./reports/story-report.txt <p/> You don't need to pass in the file name for the report either-- if no path is present, then the runner will create a report in the current directory with a default filename following this convention: easyb-<type>-report.<format> (for reports of either story or specification) easyb-report.<format> (for reports that contain both) <p/> Multiple specifications can be passed in on the command line <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy my/path/to/spec/AnotherStory.groovy
 */
public static void main(final String[] args){
  final Configuration configuration=new ConsoleConfigurator().configure(args);
  final ConsoleReporter consoleRpt=configuration.getConsoleReporter();
  if (configuration != null) {
    final BehaviorRunner runner=new BehaviorRunner(configuration.getConfiguredReports(),consoleRpt);
    try {
      runner.runBehavior(getBehaviors(configuration.getFilePaths()));
    }
 catch (    Throwable exception) {
      System.err.println("String_Node_Str");
      exception.printStackTrace(System.err);
      System.exit(-1);
    }
  }
}

Fixed version (ground truth):
/** 
 * @param args the command line argumentsusage is: <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy -txtstory ./reports/story-report.txt <p/> You don't need to pass in the file name for the report either-- if no path is present, then the runner will create a report in the current directory with a default filename following this convention: easyb-<type>-report.<format> (for reports of either story or specification) easyb-report.<format> (for reports that contain both) <p/> Multiple specifications can be passed in on the command line <p/> java BehaviorRunner my/path/to/spec/MyStory.groovy my/path/to/spec/AnotherStory.groovy
 */
public static void main(final String[] args){
  final Configuration configuration=new ConsoleConfigurator().configure(args);
  final ConsoleReporter consoleRpt=configuration.getConsoleReporter();
  if (configuration != null) {
    final BehaviorRunner runner=new BehaviorRunner(configuration.getConfiguredReports(),consoleRpt);
    try {
      boolean success=runner.runBehavior(getBehaviors(configuration.getFilePaths()));
      if (!success) {
        System.exit(-1);
      }
    }
 catch (    Throwable exception) {
      System.err.println("String_Node_Str");
      exception.printStackTrace(System.err);
      System.exit(-1);
    }
  }
}
Program: 45281
Project: 45281
Buggy source:
List<String> easybDependencies() throws ArtifactResolutionException, ArtifactNotFoundException {
  List<String> dependencies=new ArrayList<String>();
  dependencies.add(pathForDependency("String_Node_Str","String_Node_Str","String_Node_Str"));
  dependencies.add(pathForDependency("String_Node_Str","String_Node_Str","String_Node_Str"));
  dependencies.add(pathForDependency("String_Node_Str","String_Node_Str","String_Node_Str"));
  return dependencies;
}

Fixed version (ground truth):
List<String> easybDependencies() throws ArtifactResolutionException, ArtifactNotFoundException, MojoExecutionException {
  Artifact mojoArtifact=artifactFactory.createBuildArtifact("String_Node_Str","String_Node_Str",pluginVersion,"String_Node_Str");
  Artifact easybArtifact=findEasybArtifact(this.pluginArtifacts);
  easybArtifact=artifactFactory.createArtifact(easybArtifact.getGroupId(),easybArtifact.getArtifactId(),easybArtifact.getVersion(),Artifact.SCOPE_COMPILE,easybArtifact.getType());
  ArtifactResolutionResult resolutionResult=resolver.resolveTransitively(singleton(easybArtifact),mojoArtifact,EMPTY_LIST,localRepository,metadataSource);
  getLog().debug("String_Node_Str" + easybArtifact);
  List<String> dependencies=new ArrayList<String>();
  for (  Object each : resolutionResult.getArtifacts()) {
    Artifact artifact=(Artifact)each;
    getLog().info("String_Node_Str" + artifact);
    dependencies.add(artifact.getFile().getAbsolutePath());
  }
  return dependencies;
}
Program: 45282
Project: 45282
Buggy source:
/** 
 * @param args the command line arguments
 */
public static void main(String[] args){
  try {
    Options options=getOptionsForMain();
    if (args.length > 0 && args[0] != null) {
      CommandLine commandLine=getCommandLineForMain(args,options);
      SpecificationRunner runner=new SpecificationRunner(getConfiguredReports(commandLine));
      List<SpecificationListener> listeners=runner.runSpecification(getFileCollection(commandLine.getArgs()));
      notifyAndExitOnSpecificationFailures(listeners);
    }
 else {
      handleHelpForMain(options);
    }
  }
 catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace(System.err);
    System.exit(-6);
  }
}

Fixed version (ground truth):
/** 
 * @param args the command line arguments
 */
public static void main(String[] args){
  Options options=getOptionsForMain();
  try {
    CommandLine commandLine=getCommandLineForMain(args,options);
    validateArguments(commandLine);
    SpecificationRunner runner=new SpecificationRunner(getConfiguredReports(commandLine));
    List<SpecificationListener> listeners=runner.runSpecification(getFileCollection(commandLine.getArgs()));
    notifyAndExitOnSpecificationFailures(listeners);
  }
 catch (  InvalidArgumentException iae) {
    System.out.println(iae.getMessage());
    handleHelpForMain(options);
  }
catch (  ParseException pe) {
    System.out.println(pe.getMessage());
    handleHelpForMain(options);
  }
catch (  Exception e) {
    System.err.println("String_Node_Str");
    e.printStackTrace(System.err);
    System.exit(-6);
  }
}
Program: 45284
Project: 45284
Buggy source:
/** 
 * Gets the formatter.
 * @param wFormat the w format
 * @return the formatter
 */
private PatternFormatter getFormatter(String wFormat){
  PatternFormatter formatter=new PatternFormatter();
  String pattern="String_Node_Str";
  if (wFormat.contains("String_Node_Str")) {
    formatter.setTimeFormat("String_Node_Str");
  }
 else {
    formatter.setTimeFormat("String_Node_Str");
  }
  for (int i=0; i < wFormat.length(); i++) {
    if (i > 0)     pattern+="String_Node_Str";
    char c=wFormat.charAt(i);
switch (c) {
case 'L':
      pattern+="String_Node_Str";
    break;
case 'P':
  pattern+="String_Node_Str";
break;
case 'N':
pattern+="String_Node_Str";
break;
case 'T':
case 'Z':
pattern+="String_Node_Str";
break;
case 'M':
pattern+="String_Node_Str";
break;
default :
;
}
}
pattern+="String_Node_Str";
formatter.setLogPattern(pattern);
return formatter;
}

Fixed version (ground truth):
/** 
 * Gets the formatter.
 * @param wFormat the w format
 * @return the formatter
 */
private PatternFormatter getFormatter(String wFormat){
  PatternFormatter formatter=new PatternFormatter();
  String pattern="String_Node_Str";
  if (wFormat.contains("String_Node_Str")) {
    formatter.setTimeFormat("String_Node_Str");
  }
 else {
    formatter.setTimeFormat("String_Node_Str");
  }
  for (int i=0; i < wFormat.length(); i++) {
    if (i > 0)     pattern+="String_Node_Str";
    char c=wFormat.charAt(i);
switch (c) {
case 'L':
      pattern+="String_Node_Str";
    break;
case 'P':
  pattern+="String_Node_Str";
break;
case 'N':
pattern+="String_Node_Str";
break;
case 'T':
case 'Z':
pattern+="String_Node_Str";
break;
case 'M':
pattern+="String_Node_Str";
break;
default :
;
}
}
pattern+=System.getProperty("String_Node_Str");
formatter.setLogPattern(pattern);
return formatter;
}
Program: 45285
Project: 45285
Buggy source:
/** 
 * Gets the wrapper logger.
 * @return the wrapper logger
 */
@Override public Logger getWrapperLogger(){
  if (_wrapperLogger != null)   return _wrapperLogger;
  _wrapperLogger=new MyLogger();
  ((MyLogger)_wrapperLogger).setPID(_wrapperLoggerName);
  ((MyLogger)_wrapperLogger).setName(getName());
  _wrapperLogger.setUseParentHandlers(false);
  if (_controller != null)   _controller.setLogger(_appLogger);
  if (getFileHandler() != null)   _wrapperLogger.addHandler(getFileHandler());
  return _wrapperLogger;
}

Fixed version (ground truth):
/** 
 * Gets the wrapper logger.
 * @return the wrapper logger
 */
@Override public Logger getWrapperLogger(){
  if (_wrapperLogger != null)   return _wrapperLogger;
  _wrapperLogger=new MyLogger();
  ((MyLogger)_wrapperLogger).setPID(_wrapperLoggerName);
  ((MyLogger)_wrapperLogger).setName(getName());
  _wrapperLogger.setUseParentHandlers(false);
  if (_controller != null)   _controller.setLogger(_appLogger);
  if (getFileHandler() != null)   _wrapperLogger.addHandler(getFileHandler());
  if (getConsoleHandler() != null)   _wrapperLogger.addHandler(getConsoleHandler());
  return _wrapperLogger;
}
Program: 45286
Project: 45286
Buggy source:
/** 
 * Gets the app logger.
 * @return the app logger
 */
protected Logger getAppLogger(){
  if (_appLogger != null)   return _appLogger;
  if (_appLogger == null) {
    _appLogger=new MyLogger();
    updateAppLoggerName();
    _appLogger.setUseParentHandlers(false);
  }
  if (getFileHandler() != null)   _appLogger.addHandler(getFileHandler());
  if (getConsoleHandler() != null)   _appLogger.addHandler(getConsoleHandler());
  _appLogger.setLevel(Level.ALL);
  return _appLogger;
}

Fixed version (ground truth):
/** 
 * Gets the app logger.
 * @return the app logger
 */
protected Logger getAppLogger(){
  if (_appLogger != null)   return _appLogger;
  if (_appLogger == null) {
    _appLogger=new MyLogger();
    updateAppLoggerName();
    _appLogger.setUseParentHandlers(false);
  }
  if (getFileHandler() != null)   _appLogger.addHandler(getFileHandler());
  _appLogger.setLevel(Level.ALL);
  return _appLogger;
}
Program: 45288
Project: 45288
Buggy source:
/** 
 * Parses the command.
 * @param args the args
 */
private static void parseCommand(String[] args){
  HelpFormatter hf=new HelpFormatter();
  DefaultOptionBuilder oBuilder=new DefaultOptionBuilder();
  ;
  Parser p=new Parser();
  p.setGroup(group);
  p.setHelpFormatter(hf);
  p.setHelpOption(oBuilder.withLongName("String_Node_Str").withShortName("String_Node_Str").create());
  cl=p.parseAndHelp(args);
  if (cl == null) {
    System.exit(-1);
  }
  cmds=cl.getOptions();
  try {
    confFileList=cl.getValues(CONF_FILE);
    if (confFileList == null || confFileList.isEmpty())     System.out.println("String_Node_Str");
 else     confFile=(String)confFileList.get(0);
  }
 catch (  Exception ex) {
    System.out.println("String_Node_Str");
  }
  try {
    defaultFile=(String)cl.getValue(cl.getOption("String_Node_Str"));
    if (defaultFile != null)     defaultFile=new File(defaultFile).getCanonicalPath();
  }
 catch (  Exception ex) {
  }
  properties=cl.getValues(PROPERTIES);
}

Fixed version (ground truth):
/** 
 * Parses the command.
 * @param args the args
 */
private static void parseCommand(String[] args){
  HelpFormatter hf=new HelpFormatter();
  DefaultOptionBuilder oBuilder=new DefaultOptionBuilder();
  Parser p=new Parser();
  p.setGroup(group);
  p.setHelpFormatter(hf);
  p.setHelpOption(oBuilder.withLongName("String_Node_Str").withShortName("String_Node_Str").create());
  cl=p.parseAndHelp(args);
  if (cl == null) {
    System.exit(-1);
  }
  cmds=cl.getOptions();
  try {
    confFileList=cl.getValues(CONF_FILE);
    if (confFileList == null || confFileList.isEmpty())     System.out.println("String_Node_Str");
 else     confFile=(String)confFileList.get(0);
  }
 catch (  Exception ex) {
    System.out.println("String_Node_Str");
  }
  try {
    defaultFile=(String)cl.getValue(cl.getOption("String_Node_Str"));
    if (defaultFile != null)     defaultFile=new File(defaultFile).getCanonicalPath();
  }
 catch (  Exception ex) {
  }
  properties=cl.getValues(PROPERTIES);
}
Program: 45289
Project: 45289
Buggy source:
private ArrayList<? extends Location> getLocationList(LocationType type){
  ArrayList<? extends Location> locs=new ArrayList<Location>();
  DBAdapter adp=new DBAdapter(this);
  try {
    adp.createDataBase();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  adp.openDataBase();
switch (type) {
case BUILDING:
    locs=adp.getBuildings();
  break;
case ROOM:
locs=adp.getRooms();
break;
default :
locs=adp.getAllLocations();
break;
}
adp.close();
places=new String[locs.size()];
int i=0;
for (Location l : locs) {
places[i]=l.getName();
i++;
}
return locs;
}

Fixed version (ground truth):
private ArrayList<? extends Location> getLocationList(LocationType type){
  ArrayList<? extends Location> locs=new ArrayList<Location>();
  DBAdapter adp=new DBAdapter(this);
  try {
    adp.createDataBase();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  adp.openDataBase();
switch (type) {
case BUILDINGS:
    locs=adp.getBuildings();
  break;
case ROOMS:
locs=adp.getRooms();
break;
case RESTAURANTS:
locs=adp.getRestaurants();
break;
default :
locs=adp.getAllLocations();
break;
}
adp.close();
places=new String[locs.size()];
int i=0;
for (Location l : locs) {
places[i]=l.getName();
i++;
}
return locs;
}
Program: 45290
Project: 45290
Buggy source:
private int yChute(int x,int y){
  while (map.get(y + 1).get(x) == Box.EMPTY) {
    ++y;
  }
  return y;
}

Fixed version (ground truth):
private int yChute(int x,int y){
  while (map.get(y + 1).get(x) == Box.EMPTY) {
    ++y;
  }
  if (map.get(y + 1).get(x) == Box.DOOR) {
    ++y;
  }
  return y;
}
Program: 45291
Project: 45291
Buggy source:
public void keyPressed(int key,char c){
  if (key == Input.KEY_ENTER) {
    try {
      game.getState(1).init(container,game);
      ((Level)game.getState(1)).setLevel(selected + 1);
    }
 catch (    SlickException e) {
      e.printStackTrace();
    }
    game.enterState(1);
  }
 else {
    int d=0;
switch (key) {
case Input.KEY_UP:
      d=-7;
    break;
case Input.KEY_DOWN:
  d=7;
;
break;
case Input.KEY_LEFT:
d=-1;
break;
case Input.KEY_RIGHT:
d=1;
break;
}
if (selected + d >= 0 && selected + d < 7 * 5) {
selected+=d;
}
}
}

Fixed version (ground truth):
public void keyPressed(int key,char c){
  if (key == Input.KEY_ENTER || key == Input.KEY_SPACE) {
    try {
      game.getState(1).init(container,game);
      ((Level)game.getState(1)).setLevel(selected + 1);
    }
 catch (    SlickException e) {
      e.printStackTrace();
    }
    game.enterState(1);
  }
 else {
    int d=0;
switch (key) {
case Input.KEY_UP:
      d=-7;
    break;
case Input.KEY_DOWN:
  d=7;
;
break;
case Input.KEY_LEFT:
d=-1;
break;
case Input.KEY_RIGHT:
d=1;
break;
}
if (selected + d >= 0 && selected + d < 7 * 5) {
selected+=d;
}
}
}
Program: 45293
Project: 45293
Buggy source:
/** 
 * {@inheritDoc}
 */
public final void injectMembers(Object target){
  if (isFinal(field.getModifiers())) {
    return;
  }
  boolean wasAccessible=field.isAccessible();
  field.setAccessible(true);
  try {
    if (field.get(target) == null) {
      field.set(target,createLogger(field.getType()));
    }
  }
 catch (  Exception e) {
    throw new ProvisionException(format("String_Node_Str",field,e.getMessage()));
  }
 finally {
    field.setAccessible(wasAccessible);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public final void injectMembers(Object target){
  if (isFinal(field.getModifiers())) {
    return;
  }
  boolean wasAccessible=field.isAccessible();
  field.setAccessible(true);
  try {
    if (field.get(target) == null) {
      field.set(target,createLogger(target.getClass()));
    }
  }
 catch (  Exception e) {
    throw new ProvisionException(format("String_Node_Str",field,e.getMessage()));
  }
 finally {
    field.setAccessible(wasAccessible);
  }
}
Program: 45294
Project: 45294
Buggy source:
public Player getLastWhisperSent(Player sender){
  if (this.whisperTracker.containsKey(sender)) {
    return ((Whispers)this.whisperTracker.get(sender)).lastTo;
  }
  return null;
}

Fixed version (ground truth):
public String getLastWhisperSent(Player sender){
  if (this.whisperTracker.containsKey(sender.getName())) {
    return ((Whispers)this.whisperTracker.get(sender.getName())).lastTo;
  }
  return null;
}
Program: 45295
Project: 45295
Buggy source:
public void setWhisperSent(Player sender,Player receiver){
  if (this.whisperTracker.containsKey(sender)) {
    ((Whispers)this.whisperTracker.get(sender)).lastTo=receiver;
  }
 else {
    Whispers whisper=new Whispers();
    whisper.lastTo=receiver;
    this.whisperTracker.put(sender,whisper);
  }
}

Fixed version (ground truth):
public void setWhisperSent(Player sender,Player receiver){
  if (this.whisperTracker.containsKey(sender.getName())) {
    ((Whispers)this.whisperTracker.get(sender.getName())).lastTo=receiver.getName();
  }
 else {
    Whispers whisper=new Whispers();
    whisper.lastTo=receiver.getName();
    this.whisperTracker.put(sender.getName(),whisper);
  }
}
Program: 45296
Project: 45296
Buggy source:
public void setWhisperReceived(Player sender,Player receiver){
  if (this.whisperTracker.containsKey(receiver)) {
    ((Whispers)this.whisperTracker.get(receiver)).lastFrom=sender;
  }
 else {
    Whispers whisper=new Whispers();
    whisper.lastFrom=sender;
    this.whisperTracker.put(receiver,whisper);
  }
}

Fixed version (ground truth):
public void setWhisperReceived(Player sender,Player receiver){
  if (this.whisperTracker.containsKey(receiver.getName())) {
    ((Whispers)this.whisperTracker.get(receiver.getName())).lastFrom=sender.getName();
  }
 else {
    Whispers whisper=new Whispers();
    whisper.lastFrom=sender.getName();
    this.whisperTracker.put(receiver.getName(),whisper);
  }
}
Program: 45297
Project: 45297
Buggy source:
public Player getLastWhisperRecieved(Player receiver){
  if (this.whisperTracker.containsKey(receiver)) {
    return ((Whispers)this.whisperTracker.get(receiver)).lastFrom;
  }
  return null;
}

Fixed version (ground truth):
public String getLastWhisperRecieved(Player receiver){
  if (this.whisperTracker.containsKey(receiver.getName())) {
    return ((Whispers)this.whisperTracker.get(receiver.getName())).lastFrom;
  }
  return null;
}
Program: 45298
Project: 45298
Buggy source:
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (args.length == 0) {
    return false;
  }
  if (sender instanceof Player) {
    Player player=(Player)sender;
    ChatChannel chan=plugin.channelHelper.getChannelFromName(argString);
    if (chan != null) {
      ChatChannelJoinEvent ccje=new ChatChannelJoinEvent(player,chan,"String_Node_Str",false,true,true,false);
      server.getPluginManager().callEvent(ccje);
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (args.length == 0) {
    return false;
  }
  if (sender instanceof Player) {
    Player player=(Player)sender;
    ChatChannel chan=plugin.channelHelper.getChannelFromName(argString);
    if (chan != null) {
      Boolean alertOthers=!(chan.getId().equals("String_Node_Str") || chan.getId().equals("String_Node_Str"));
      ChatChannelJoinEvent ccje=new ChatChannelJoinEvent(player,chan,"String_Node_Str",false,true,alertOthers,false);
      server.getPluginManager().callEvent(ccje);
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}
Program: 45299
Project: 45299
Buggy source:
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (sender instanceof Player) {
    Player player=(Player)sender;
    Player reply=plugin.whisperTracker.getLastWhisperRecieved(player);
    if (reply != null) {
      ChatWhisperEvent cwe=new ChatWhisperEvent(player,reply,argString);
      server.getPluginManager().callEvent(cwe);
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (sender instanceof Player) {
    Player player=(Player)sender;
    String name=plugin.whisperTracker.getLastWhisperRecieved(player);
    if (name != null) {
      List<Player> matches=plugin.getServer().matchPlayer(name);
      if (matches.size() > 0) {
        Player reply=matches.get(0);
        ChatWhisperEvent cwe=new ChatWhisperEvent(player,reply,argString);
        server.getPluginManager().callEvent(cwe);
      }
 else {
        player.sendMessage(String.format("String_Node_Str",name));
      }
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}
Program: 45300
Project: 45300
Buggy source:
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (sender instanceof Player) {
    Player player=(Player)sender;
    Player rewhisper=plugin.whisperTracker.getLastWhisperSent(player);
    if (rewhisper != null) {
      ChatWhisperEvent cwe=new ChatWhisperEvent(player,rewhisper,argString);
      server.getPluginManager().callEvent(cwe);
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
  String argString=StringHelper.join(args,0);
  if (sender instanceof Player) {
    Player player=(Player)sender;
    String name=plugin.whisperTracker.getLastWhisperSent(player);
    if (name != null) {
      List<Player> matches=plugin.getServer().matchPlayer(name);
      if (matches.size() > 0) {
        Player rewhisper=plugin.getServer().matchPlayer(name).get(0);
        ChatWhisperEvent cwe=new ChatWhisperEvent(player,rewhisper,argString);
        server.getPluginManager().callEvent(cwe);
      }
 else {
        player.sendMessage(String.format("String_Node_Str",name));
      }
    }
 else {
      player.sendMessage("String_Node_Str");
    }
    return true;
  }
  return false;
}
Program: 45301
Project: 45301
Buggy source:
public static List<String> getIgnoreList(Player player){
  return ignoreList.get(player);
}

Fixed version (ground truth):
public static List<String> getIgnoreList(Player player){
  return ignoreList.get(player.getName());
}
Program: 45302
Project: 45302
Buggy source:
@Override public List<Document> buildSplitGpx(int preferredInstrNum){
  List<Document> gpxList=new ArrayList<Document>();
  List<Waypoint> instructions=gpx.getInstructions();
  int splitFiles=howManyFiles(instructions.size(),preferredInstrNum);
  int currInstr=0;
  int fileNum=1;
  while (fileNum <= splitFiles) {
    Document newGpxDocument=createGpxTemplate();
    Element route=new Element(Gpx.RTE_TAG);
    for (int i=0; i < preferredInstrNum; i++) {
      Waypoint currentInstruction=instructions.get(currInstr);
      Element routePt=new Element(Gpx.RTEPT_TAG);
      routePt.setAttribute(Gpx.LATITUDE_TAG,currentInstruction.getLatitude());
      routePt.setAttribute(Gpx.LONGITUDE_TAG,currentInstruction.getLongitude());
      Element ele=new Element(Gpx.ELEMENT_TAG);
      ele.setText(currentInstruction.getElement());
      routePt.setContent(ele);
      Element name=new Element(Gpx.ELEMENT_TAG);
      name.setText(currentInstruction.getElement());
      routePt.setContent(name);
      route.addContent(routePt);
      currInstr++;
    }
    newGpxDocument.getRootElement().setContent(route);
    gpxList.add(newGpxDocument);
    fileNum++;
  }
  return gpxList;
}

Fixed version (ground truth):
@Override public List<Document> buildSplitGpx(int preferredInstrNum){
  List<Document> gpxList=new ArrayList<Document>();
  List<Waypoint> instructions=gpx.getInstructions();
  int splitFiles=howManyFiles(instructions.size(),preferredInstrNum);
  int currInstr=0;
  int fileNum=1;
  while (fileNum <= splitFiles) {
    Document newGpxDocument=createGpxTemplate();
    Element route=new Element(Gpx.RTE_TAG);
    for (int i=0; i < preferredInstrNum; i++) {
      try {
        Waypoint currentInstruction=instructions.get(currInstr);
        Element routePt=new Element(Gpx.RTEPT_TAG);
        routePt.setAttribute(Gpx.LATITUDE_TAG,currentInstruction.getLatitude());
        routePt.setAttribute(Gpx.LONGITUDE_TAG,currentInstruction.getLongitude());
        Element ele=new Element(Gpx.ELEMENT_TAG);
        ele.setText(currentInstruction.getElement());
        routePt.setContent(ele);
        Element name=new Element(Gpx.ELEMENT_TAG);
        name.setText(currentInstruction.getElement());
        routePt.setContent(name);
        route.addContent(routePt);
        currInstr++;
      }
 catch (      IndexOutOfBoundsException e) {
        break;
      }
    }
    newGpxDocument.getRootElement().setContent(route);
    gpxList.add(newGpxDocument);
    fileNum++;
  }
  return gpxList;
}
Program: 45303
Project: 45303
Buggy source:
@Override public void build(File file,int preferedInstrNum) throws IOException {
  int fileNum=1;
  int instrNum=1;
  while (fileNum <= fileNum) {
    Document newGpxDocument=createGpxTemplate();
    Element rteSeg=new Element("String_Node_Str");
    for (    Waypoint wpt : gpx.getInstructions()) {
      Element rtePt=new Element("String_Node_Str");
      rtePt.setAttribute(Gpx.LATITUDE_TAG,wpt.getLatitude());
      rtePt.setAttribute(Gpx.LONGITUDE_TAG,wpt.getLongitude());
      Element ele=new Element(Gpx.ELEMENT_TAG);
      ele.setText(wpt.getElement());
      rtePt.setContent(ele);
      rteSeg.setContent(rtePt);
    }
    newGpxDocument.setContent(rteSeg);
    saveFile(new File(file.getName() + "String_Node_Str" + fileNum+ GPX_FORMAT),newGpxDocument);
    instrNum--;
    fileNum++;
  }
}

Fixed version (ground truth):
@Override public void build(File file,int preferedInstrNum) throws IOException {
  int fileNum=1;
  List<Document> docs=buildSplitGpx(preferedInstrNum);
  for (  Document newGpxDocument : docs) {
    saveFile(new File(stripExtension(file.getAbsolutePath(),GPX_FORMAT) + "String_Node_Str" + fileNum+ GPX_FORMAT),newGpxDocument);
    fileNum++;
  }
}
Program: 45304
Project: 45304
Buggy source:
@Override public List<Document> buildSplitGpx(int preferredInstrNum){
  List<Document> gpxList=new ArrayList<Document>();
  List<Waypoint> instructions=gpx.getInstructions();
  int splitFiles=howManyFiles(instructions.size(),preferredInstrNum);
  int currInstr=0;
  int fileNum=1;
  while (fileNum <= splitFiles) {
    Document newGpxDocument=createGpxTemplate();
    Element track=new Element(Gpx.TRK_TAG);
    Element trackSegment=new Element(Gpx.TRACKSEGMENT_TAG);
    track.setContent(trackSegment);
    for (int i=0; i < preferredInstrNum; i++) {
      Waypoint currentInstruction=instructions.get(currInstr);
      Element trackPoint=new Element(Gpx.TRACKPOINT);
      trackPoint.setAttribute(Gpx.LATITUDE_TAG,currentInstruction.getLatitude());
      trackPoint.setAttribute(Gpx.LONGITUDE_TAG,currentInstruction.getLongitude());
      Element ele=new Element(Gpx.ELEMENT_TAG);
      ele.setText(currentInstruction.getElement());
      trackPoint.setContent(ele);
      trackSegment.addContent(trackPoint);
      currInstr++;
    }
    newGpxDocument.getRootElement().setContent(track);
    gpxList.add(newGpxDocument);
    fileNum++;
  }
  return gpxList;
}

Fixed version (ground truth):
@Override public List<Document> buildSplitGpx(int preferredInstrNum){
  List<Document> gpxList=new ArrayList<Document>();
  List<Waypoint> instructions=gpx.getInstructions();
  int splitFiles=howManyFiles(instructions.size(),preferredInstrNum);
  int currInstr=0;
  int fileNum=1;
  while (fileNum <= splitFiles) {
    Document newGpxDocument=createGpxTemplate();
    Element track=new Element(Gpx.TRK_TAG);
    Element trackSegment=new Element(Gpx.TRACKSEGMENT_TAG);
    track.setContent(trackSegment);
    for (int i=0; i < preferredInstrNum; i++) {
      try {
        Waypoint currentInstruction=instructions.get(currInstr);
        Element trackPoint=new Element(Gpx.TRACKPOINT);
        trackPoint.setAttribute(Gpx.LATITUDE_TAG,currentInstruction.getLatitude());
        trackPoint.setAttribute(Gpx.LONGITUDE_TAG,currentInstruction.getLongitude());
        Element ele=new Element(Gpx.ELEMENT_TAG);
        ele.setText(currentInstruction.getElement());
        trackPoint.setContent(ele);
        trackSegment.addContent(trackPoint);
        currInstr++;
      }
 catch (      IndexOutOfBoundsException e) {
        break;
      }
    }
    newGpxDocument.getRootElement().setContent(track);
    gpxList.add(newGpxDocument);
    fileNum++;
  }
  return gpxList;
}
Program: 45305
Project: 45305
Buggy source:
private void saveGpxFile(){
  String numOfInstructions=view.getInstructionsNumber();
  if (!isAValidInteger(numOfInstructions)) {
    view.showMessage("String_Node_Str");
    return;
  }
  int instNum=Integer.parseInt(numOfInstructions);
  String gpxType=view.getHighlightedGpxType();
  String fileName=view.getNewGpxFileName();
  if (fileName.isEmpty()) {
    view.showMessage("String_Node_Str");
    return;
  }
  try {
    JFileChooser saveFileChooser=new JFileChooser(fileName);
    saveFileChooser.setFileFilter(new GpxFileFilter());
    saveFileChooser.showSaveDialog(view);
    saveGpxFile(instNum,gpxType,saveFileChooser.getSelectedFile());
  }
 catch (  IOException e) {
    view.showMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
private void saveGpxFile(){
  String numOfInstructions=view.getInstructionsNumber();
  if (!isAValidInteger(numOfInstructions)) {
    view.showMessage("String_Node_Str");
    return;
  }
  int instNum=Integer.parseInt(numOfInstructions);
  String gpxType=view.getHighlightedGpxType();
  String fileName=view.getNewGpxFileName();
  if (fileName.isEmpty()) {
    view.showMessage("String_Node_Str");
    return;
  }
  try {
    JFileChooser saveFileChooser=new JFileChooser();
    saveFileChooser.setSelectedFile(new File(fileName));
    saveFileChooser.setFileFilter(new GpxFileFilter());
    saveFileChooser.showSaveDialog(view);
    saveGpxFile(instNum,gpxType,saveFileChooser.getSelectedFile());
  }
 catch (  IOException e) {
    view.showMessage("String_Node_Str");
  }
}
Program: 45306
Project: 45306
Buggy source:
/** 
 * This method will build a set of GPX files given the file name, number of GPX instructions per file and the number of files to be built. TODO: split this method so it returns a testable gpx document. TODO: do we need to pass in the num of instructions
 * @param file
 * @param instNum
 * @param filesNum
 * @throws IOException
 */
public void build(File file,int totalInstructionsNum,int filesNum) throws IOException {
  int fileNum=1;
  int instrNum=1;
  while (fileNum <= filesNum) {
    Document newGpxDocument=createNewGpx();
    Element rteSeg=new Element("String_Node_Str");
    for (    WayPoint wpt : gpx.getIntructions()) {
      Element rtePt=new Element("String_Node_Str");
      rtePt.setAttribute("String_Node_Str",wpt.getLatitude() + "String_Node_Str");
      rtePt.setAttribute("String_Node_Str",wpt.getLongitude() + "String_Node_Str");
      Element ele=new Element("String_Node_Str");
      ele.setText(wpt.getElement());
      rtePt.setContent(ele);
      rteSeg.setContent(rtePt);
    }
    newGpxDocument.setContent(rteSeg);
    saveFile(new File(file + "String_Node_Str" + fileNum+ GPX_FORMAT),newGpxDocument);
    instrNum--;
    fileNum++;
  }
}

Fixed version (ground truth):
/** 
 * This method will build a set of GPX files given the file name, number of GPX instructions per file and the number of files to be built. TODO: split this method so it returns a testable gpx document. TODO: do we need to pass in the num of instructions TODO: fix multiple files bug
 * @param file
 * @param instNum
 * @param filesNum
 * @throws IOException
 */
public void build(File file,int totalInstructionsNum,int filesNum) throws IOException {
  int fileNum=1;
  int instrNum=1;
  while (fileNum <= filesNum) {
    Document newGpxDocument=createNewGpx();
    Element track=new Element("String_Node_Str");
    Element trackSegment=new Element("String_Node_Str");
    track.setContent(trackSegment);
    for (    WayPoint wpt : gpx.getIntructions()) {
      Element trackPoint=new Element("String_Node_Str");
      trackPoint.setAttribute("String_Node_Str",wpt.getLatitude() + "String_Node_Str");
      trackPoint.setAttribute("String_Node_Str",wpt.getLongitude() + "String_Node_Str");
      Element ele=new Element("String_Node_Str");
      ele.setText(wpt.getElement());
      trackPoint.setContent(ele);
      trackSegment.addContent(trackPoint);
    }
    newGpxDocument.getRootElement().setContent(track);
    saveFile(new File(file + "String_Node_Str" + fileNum+ GPX_FORMAT),newGpxDocument);
    instrNum--;
    fileNum++;
  }
}
Program: 45307
Project: 45307
Buggy source:
public double calculatetax(){
  if (age < 60) {
switch (gender) {
case 'M':
      if (totalSalary <= 180000)       return 0.0;
    if (totalSalary <= 500000)     return (totalSalary - 180000) * 0.10;
  if (totalSalary <= 800000)   return 32000 + (totalSalary - 500000) * 0.20;
return 92000 + (totalSalary - 800000) * 0.30;
case 'F':
if (totalSalary <= 190000) return 0.0;
if (totalSalary <= 500000) return (totalSalary - 190000) * 0.10;
if (totalSalary <= 800000) return 31000 + (totalSalary - 500000) * 0.20;
return 91000 + (totalSalary - 800000) * 0.30;
default :
break;
}
}
 else if (age < 80) {
if (totalSalary <= 250000) return 0.0;
if (totalSalary <= 500000) return (totalSalary - 250000) * 0.10;
if (totalSalary <= 800000) return 25000 + (totalSalary - 500000) * 0.20;
return 75000 + (totalSalary - 800000) * 0.30;
}
if (totalSalary <= 500000) return 0.0;
 else if (totalSalary <= 800000) return (totalSalary - 500000) * 0.20;
return 60000 + (totalSalary - 800000) * 0.30;
}

Fixed version (ground truth):
public double calculatetax(){
  if (age < 60) {
switch (gender) {
case 'M':
      if (totalSalary <= 180000)       return 0.0;
    if (totalSalary <= 500000)     return (totalSalary - 180000) * 0.10;
  if (totalSalary <= 800000)   return 32000 + (totalSalary - 500000) * 0.20;
return 92000 + (totalSalary - 800000) * 0.30;
case 'F':
if (totalSalary <= 190000) return 0.0;
if (totalSalary <= 500000) return (totalSalary - 190000) * 0.10;
if (totalSalary <= 800000) return 31000 + (totalSalary - 500000) * 0.20;
return 91000 + (totalSalary - 800000) * 0.30;
default :
break;
}
}
 else if (age < 80) {
if (totalSalary <= 250000) return 0.0;
if (totalSalary <= 500000) return (totalSalary - 250000) * 0.10;
if (totalSalary <= 800000) return 25000 + (totalSalary - 500000) * 0.20;
return 85000 + (totalSalary - 800000) * 0.30;
}
if (totalSalary <= 500000) return 0.0;
 else if (totalSalary <= 800000) return (totalSalary - 500000) * 0.20;
return 60000 + (totalSalary - 800000) * 0.30;
}
Program: 45308
Project: 45308
Buggy source:
@Test public void taxForSeniorCitizenIfInThirdIncomeSlab(){
  assertEquals(78000.0,new Salary('M',60,810000).calculatetax(),0.1);
}

Fixed version (ground truth):
@Test public void taxForSeniorCitizenIfInThirdIncomeSlab(){
  assertEquals(88000.0,new Salary('M',60,810000).calculatetax(),0.1);
}
Program: 45309
Project: 45309
Buggy source:
public boolean play(CellKey this_cell_key,Player this_player){
  assert(cell_space != null);
  assert(started);
  Cell this_cell=cell_space.get_cell_from_key(this_cell_key);
  if (this_cell != null)   return play(this_cell,this_player);
 else   return false;
}

Fixed version (ground truth):
public boolean play(CellKey this_cell_key,Player this_player){
  assert(myCellSpace != null);
  assert(started);
  Cell this_cell=myCellSpace.get_cell_from_key(this_cell_key);
  if (this_cell != null)   return play(this_cell,this_player);
 else   return false;
}
Program: 45310
Project: 45310
Buggy source:
public void set_listener(GameListener this_listener){
  my_listener=this_listener;
}

Fixed version (ground truth):
public void set_listener(GameListener this_listener){
  myListener=this_listener;
}
Program: 45311
Project: 45311
Buggy source:
protected Game(){
  players=new LinkedHashSet<Player>();
  pieces=new LinkedHashSet<Piece>();
  started=false;
  my_listener=null;
}

Fixed version (ground truth):
protected Game(){
  myPlayers=new LinkedHashSet<Player>();
  pieces=new LinkedHashSet<Piece>();
  started=false;
  myListener=null;
}
Program: 45312
Project: 45312
Buggy source:
protected abstract void next_player();

Fixed version (ground truth):
protected void next_player(){
  if (playerTurn.hasNext()) {
    currentPlayer=playerTurn.next();
    if (!currentPlayer.is_alive())     next_player();
    assert(currentPlayer != null);
  }
 else   select_first_player();
}
Program: 45313
Project: 45313
Buggy source:
protected abstract void select_first_player();

Fixed version (ground truth):
protected void select_first_player(){
  playerTurn=getPlayers().iterator();
  currentPlayer=playerTurn.next();
  if (!currentPlayer.is_alive())   next_player();
  assert(currentPlayer != null);
}
Program: 45314
Project: 45314
Buggy source:
public void start(){
  assert(players.size() > 1);
  select_first_player();
  started=true;
}

Fixed version (ground truth):
public void start(){
  assert(myPlayers.size() > 1);
  select_first_player();
  started=true;
}
Program: 45315
Project: 45315
Buggy source:
public ReadOnlyCellSpace get_cell_space_view(){
  assert(cell_space != null);
  return cell_space;
}

Fixed version (ground truth):
public ReadOnlyCellSpace get_cell_space_view(){
  assert(myCellSpace != null);
  return myCellSpace;
}
Program: 45316
Project: 45316
Buggy source:
public abstract Player get_current_player();

Fixed version (ground truth):
public Player get_current_player(){
  return currentPlayer;
}
Program: 45317
Project: 45317
Buggy source:
protected void win(Player winner){
  if (my_listener != null)   my_listener.on_win(this,winner);
}

Fixed version (ground truth):
protected void win(Player winner){
  if (myListener != null) {
    myListener.on_win(this,winner);
  }
}
Program: 45318
Project: 45318
Buggy source:
public void change_owner(Player this_player){
  Player old_owner=owner;
  old_owner.loose_a_piece(this);
  owner=this_player;
  owner.win_a_piece(this);
  if (my_listener != null)   my_listener.on_owner_changed(this,old_owner,owner);
}

Fixed version (ground truth):
public void change_owner(Player this_player){
  Player old_owner=owner;
  old_owner.looseAPiece(this);
  owner=this_player;
  owner.winAPiece(this);
  if (my_listener != null)   my_listener.on_owner_changed(this,old_owner,owner);
}
Program: 45319
Project: 45319
Buggy source:
public Player(String this_name){
  super(this_name);
}

Fixed version (ground truth):
public Player(String thisName){
  super(thisName);
}
Program: 45322
Project: 45322
Buggy source:
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == CAMERA_PIC_REQUEST) {
    final File file=getTempFile(this);
    try {
      pic=Media.getBitmap(getContentResolver(),Uri.fromFile(file));
      int srcWidth=pic.getWidth();
      int srcHeight=pic.getHeight();
      int desiredWidth=350;
      int desiredHeight=350;
      if (srcWidth > srcHeight && srcWidth > desiredWidth) {
        float scaleRatio=(float)srcWidth / (float)desiredWidth;
        float newHeight=(float)srcHeight / scaleRatio;
        resizedBitmap=Bitmap.createScaledBitmap(pic,desiredWidth,(int)newHeight,true);
        pic.recycle();
      }
 else       if (srcHeight > desiredHeight) {
        float scaleRatio=(float)srcHeight / (float)desiredWidth;
        float newWidth=(float)srcWidth / scaleRatio;
        resizedBitmap=Bitmap.createScaledBitmap(pic,(int)newWidth,desiredHeight,true);
        pic.recycle();
      }
      tookPic=true;
      iv_Image.setImageBitmap(resizedBitmap);
      iv_Image.setVisibility(View.VISIBLE);
      b_AddCard.setVisibility(View.VISIBLE);
      ib_Camera.setVisibility(View.GONE);
      tv_TakeAPic.setVisibility(View.GONE);
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
protected void onActivityResult(int requestCode,int resultCode,Intent data){
  if (requestCode == CAMERA_PIC_REQUEST) {
    final File file=getTempFile(this);
    try {
      pic=Media.getBitmap(getContentResolver(),Uri.fromFile(file));
      int srcWidth=pic.getWidth();
      int srcHeight=pic.getHeight();
      int desiredWidth=350;
      int desiredHeight=350;
      if (srcWidth > srcHeight && srcWidth > desiredWidth) {
        float scaleRatio=(float)srcWidth / (float)desiredWidth;
        float newHeight=(float)srcHeight / scaleRatio;
        resizedBitmap=Bitmap.createScaledBitmap(pic,desiredWidth,(int)newHeight,true);
        pic.recycle();
      }
 else       if (srcHeight > desiredHeight) {
        float scaleRatio=(float)srcHeight / (float)desiredWidth;
        float newWidth=(float)srcWidth / scaleRatio;
        resizedBitmap=Bitmap.createScaledBitmap(pic,(int)newWidth,desiredHeight,true);
        pic.recycle();
      }
      tookPic=true;
      et_Original.setText(original);
      iv_Image.setImageBitmap(resizedBitmap);
      iv_Image.setVisibility(View.VISIBLE);
      b_AddCard.setVisibility(View.VISIBLE);
      ib_Camera.setVisibility(View.GONE);
      tv_TakeAPic.setVisibility(View.GONE);
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
}