nus-yam/ex-repair huggingface dataset:
Program: 7098
Project: 7098
Buggy source:
public void testServeFile() throws Exception {
  Map<String,String> files=new HashMap<String,String>();
  files.put("String_Node_Str","String_Node_Str");
  files.put("String_Node_Str","String_Node_Str");
  FilesCache filesCache=new FilesCache(files);
  TestResourceServlet resourceServlet=new TestResourceServlet(filesCache);
  resourceServlet.service("String_Node_Str",writer);
  assertEquals("String_Node_Str",out.toString());
  out.reset();
  resourceServlet.service("String_Node_Str",writer);
  assertEquals("String_Node_Str",out.toString());
}

Fixed version (ground truth):
public void testServeFile() throws Exception {
  Map<String,FileData> files=new HashMap<String,FileData>();
  files.put("String_Node_Str",new FileData("String_Node_Str","String_Node_Str",-1));
  files.put("String_Node_Str",new FileData("String_Node_Str","String_Node_Str",20));
  FilesCache filesCache=new FilesCache(files);
  TestResourceServlet resourceServlet=new TestResourceServlet(filesCache);
  resourceServlet.service("String_Node_Str",writer);
  assertEquals("String_Node_Str",out.toString());
  out.reset();
  resourceServlet.service("String_Node_Str",writer);
  assertEquals("String_Node_Str",out.toString());
}
Program: 7099
Project: 7099
Buggy source:
public JsTestDriverClient getJsTestDriverClient(Set<String> files,Set<String> filesToServe,String serverAddress){
  Set<FileInfo> filesInfo=new LinkedHashSet<FileInfo>();
  for (  String file : files) {
    boolean isPatch=file.startsWith("String_Node_Str");
    if (isPatch) {
      String[] tokens=file.split("String_Node_Str",2);
      file=tokens[1].trim();
    }
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified(),isPatch));
  }
  for (  String file : filesToServe) {
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified(),false));
  }
  return new JsTestDriverClientImpl(new CommandTaskFactory(new ActionFactoryFileFilter(),fileReader),filesInfo,filesToServe,serverAddress,new HttpServer());
}

Fixed version (ground truth):
public JsTestDriverClient getJsTestDriverClient(Set<String> files,Set<String> filesToServe,String serverAddress){
  Set<FileInfo> filesInfo=new LinkedHashSet<FileInfo>();
  for (  String file : files) {
    boolean isPatch=file.startsWith("String_Node_Str");
    if (isPatch) {
      String[] tokens=file.split("String_Node_Str",2);
      file=tokens[1].trim();
    }
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified(),isPatch,false));
  }
  for (  String file : filesToServe) {
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified(),false,true));
  }
  return new JsTestDriverClientImpl(new CommandTaskFactory(new ActionFactoryFileFilter(),fileReader),filesInfo,filesToServe,serverAddress,new HttpServer());
}
Program: 7100
Project: 7100
Buggy source:
/** 
 * Wraps the current sequence of actions with the server start and stop actions. 
 */
private void addServerActions(List<Action> actions,boolean leaveServerRunning){
  if (preloadFiles) {
    for (    String file : fileSet) {
      files.put(file,ActionSequenceBuilder.readFile(this,file));
    }
  }
  ServerStartupAction serverStartupAction=actionFactory.getServerStartupAction(localServerPort,capturedBrowsers,new FilesCache(files));
  actions.add(0,serverStartupAction);
  if (!leaveServerRunning) {
    actions.add(new ServerShutdownAction(serverStartupAction));
  }
}

Fixed version (ground truth):
/** 
 * Wraps the current sequence of actions with the server start and stop actions. 
 */
private void addServerActions(List<Action> actions,boolean leaveServerRunning){
  if (preloadFiles) {
    for (    String file : fileSet) {
      files.put(file,new FileData(file,ActionSequenceBuilder.readFile(this,file),new File(file).lastModified()));
    }
  }
  ServerStartupAction serverStartupAction=actionFactory.getServerStartupAction(localServerPort,capturedBrowsers,new FilesCache(files));
  actions.add(0,serverStartupAction);
  if (!leaveServerRunning) {
    actions.add(new ServerShutdownAction(serverStartupAction));
  }
}
Program: 7101
Project: 7101
Buggy source:
/** 
 * Add the Browser startup and shutdown actions to the actions stack. 
 */
private void addBrowserControlActions(List<Action> actions){
  BrowserStartupAction browserStartupAction=new BrowserStartupAction(browsers,getServerAddress());
  capturedBrowsers.addObserver(browserStartupAction);
  actions.add(0,browserStartupAction);
  actions.add(new BrowserShutdownAction(browserStartupAction));
}

Fixed version (ground truth):
/** 
 * Add the Browser startup and shutdown actions to the actions stack. 
 */
private void addBrowserControlActions(List<Action> actions){
  if (!browsers.isEmpty()) {
    BrowserStartupAction browserStartupAction=new BrowserStartupAction(browsers,getServerAddress());
    capturedBrowsers.addObserver(browserStartupAction);
    actions.add(0,browserStartupAction);
    actions.add(new BrowserShutdownAction(browserStartupAction));
  }
}
Program: 7103
Project: 7103
Buggy source:
public FileInfo(String fileName,long timestamp,boolean isPatch){
  this.fileName=fileName;
  this.timestamp=timestamp;
  this.isPatch=isPatch;
}

Fixed version (ground truth):
public FileInfo(String fileName,long timestamp,boolean isPatch,boolean serveOnly){
  this.fileName=fileName;
  this.timestamp=timestamp;
  this.isPatch=isPatch;
  this.serveOnly=serveOnly;
}
Program: 7104
Project: 7104
Buggy source:
public void checkFileSet(String fileSet,String browserId,PrintWriter writer){
  Collection<FileInfo> clientFileSet=gson.fromJson(fileSet,new TypeToken<Collection<FileInfo>>(){
  }
.getType());
  SlaveBrowser browser=capturedBrowsers.getBrowser(browserId);
  Set<FileInfo> browserFileSet=browser.getFileSet();
  Set<String> filesToRequest=new LinkedHashSet<String>();
  if (browserFileSet.isEmpty() || !clientFileSet.containsAll(browserFileSet)) {
    for (    FileInfo info : clientFileSet) {
      filesToRequest.add(info.getFileName());
    }
  }
 else {
    Set<FileInfo> diff=new LinkedHashSet<FileInfo>(clientFileSet);
    diff.removeAll(browserFileSet);
    for (    FileInfo info : diff) {
      filesToRequest.add(info.getFileName());
    }
    for (    FileInfo browserFileInfo : browserFileSet) {
      for (      FileInfo clientFileInfo : clientFileSet) {
        if (clientFileInfo.equals(browserFileInfo) && clientFileInfo.getTimestamp() > browserFileInfo.getTimestamp()) {
          filesToRequest.add(clientFileInfo.getFileName());
          break;
        }
      }
    }
  }
  if (!filesToRequest.isEmpty()) {
    if (browser.getBrowserInfo().getName().contains("String_Node_Str")) {
      filesToRequest.clear();
      for (      FileInfo info : clientFileSet) {
        filesToRequest.add(info.getFileName());
      }
    }
    writer.write(gson.toJson(filesToRequest));
  }
  writer.flush();
}

Fixed version (ground truth):
public void checkFileSet(String fileSet,String browserId,PrintWriter writer){
  Collection<FileInfo> clientFileSet=gson.fromJson(fileSet,new TypeToken<Collection<FileInfo>>(){
  }
.getType());
  SlaveBrowser browser=capturedBrowsers.getBrowser(browserId);
  Set<FileInfo> browserFileSet=browser.getFileSet();
  Set<String> filesToRequest=new LinkedHashSet<String>();
  if (browserFileSet.isEmpty() || !clientFileSet.containsAll(browserFileSet)) {
    for (    FileInfo info : clientFileSet) {
      filesToRequest.add(info.getFileName());
    }
  }
 else {
    Set<FileInfo> diff=new LinkedHashSet<FileInfo>(clientFileSet);
    diff.removeAll(browserFileSet);
    for (    FileInfo info : diff) {
      filesToRequest.add(info.getFileName());
    }
    for (    FileInfo browserFileInfo : browserFileSet) {
      for (      FileInfo clientFileInfo : clientFileSet) {
        if (clientFileInfo.equals(browserFileInfo) && clientFileInfo.getTimestamp() > browserFileInfo.getTimestamp()) {
          filesToRequest.add(clientFileInfo.getFileName());
          break;
        }
      }
    }
  }
  if (!filesToRequest.isEmpty()) {
    if (browser.getBrowserInfo().getName().contains("String_Node_Str")) {
      filesToRequest.clear();
      for (      FileInfo info : clientFileSet) {
        filesToRequest.add(info.getFileName());
      }
    }
    Set<String> filteredFilesToRequest=filterServeOnlyFiles(clientFileSet,filesToRequest);
    writer.write(gson.toJson(filteredFilesToRequest));
  }
  writer.flush();
}
Program: 7105
Project: 7105
Buggy source:
public void uploadFiles(String id,String data){
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  for (  FileData f : filesData) {
    String path=f.getFile();
    String fileData=f.getData();
    filesCache.addFile(path,fileData);
  }
}

Fixed version (ground truth):
public void uploadFiles(String id,String data){
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  for (  FileData f : filesData) {
    String path=f.getFile();
    filesCache.addFile(path,f);
  }
}
Program: 7106
Project: 7106
Buggy source:
public String getFileContent(String fileName){
  return files.get(fileName);
}

Fixed version (ground truth):
public String getFileContent(String fileName){
  FileData fileData=files.get(fileName);
  return fileData != null ? fileData.getData() : "String_Node_Str";
}
Program: 7107
Project: 7107
Buggy source:
public FilesCache(Map<String,String> files){
  this.files=files;
}

Fixed version (ground truth):
public FilesCache(Map<String,FileData> files){
  this.files=files;
}
Program: 7108
Project: 7108
Buggy source:
public void addFile(String path,String fileData){
  files.put(path,fileData);
}

Fixed version (ground truth):
public void addFile(String path,FileData fileData){
  files.put(path,fileData);
}
Program: 7109
Project: 7109
Buggy source:
public JsTestDriverClient getJsTestDriverClient(Set<String> files,String serverAddress){
  Set<FileInfo> filesInfo=new LinkedHashSet<FileInfo>();
  for (  String file : files) {
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified()));
  }
  return new JsTestDriverClientImpl(new CommandTaskFactory(new JsTestDriverFileFilter(){
    public String filterFile(    String content,    boolean reload){
      return content;
    }
    public Set<String> resolveFilesDeps(    String file){
      Set<String> set=new LinkedHashSet<String>();
      set.add(file);
      return set;
    }
  }
),filesInfo,serverAddress,new HttpServer());
}

Fixed version (ground truth):
public JsTestDriverClient getJsTestDriverClient(Set<String> files,String serverAddress){
  Set<FileInfo> filesInfo=new LinkedHashSet<FileInfo>();
  for (  String file : files) {
    boolean isPatch=file.startsWith("String_Node_Str");
    if (isPatch) {
      String[] tokens=file.split("String_Node_Str");
      file=tokens[1].trim();
    }
    filesInfo.add(new FileInfo(file,(file.startsWith("String_Node_Str") || file.startsWith("String_Node_Str")) ? -1 : new File(file).lastModified(),isPatch));
  }
  return new JsTestDriverClientImpl(new CommandTaskFactory(new JsTestDriverFileFilter(){
    public String filterFile(    String content,    boolean reload){
      return content;
    }
    public Set<String> resolveFilesDeps(    String file){
      Set<String> set=new LinkedHashSet<String>();
      set.add(file);
      return set;
    }
  }
),filesInfo,serverAddress,new HttpServer());
}
Program: 7112
Project: 7112
Buggy source:
public FileInfo(String fileName,long timestamp){
  this.fileName=fileName;
  this.timestamp=timestamp;
}

Fixed version (ground truth):
public FileInfo(String fileName,long timestamp,boolean isPatch){
  this.fileName=fileName;
  this.timestamp=timestamp;
  this.isPatch=isPatch;
}
Program: 7113
Project: 7113
Buggy source:
public void uploadFiles(String id,String data){
  SlaveBrowser browser=capturedBrowsers.getBrowser(id);
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  LinkedHashSet<FileInfo> filesUploaded=new LinkedHashSet<FileInfo>();
  for (  FileData f : filesData) {
    String path=f.getFile();
    String fileData=f.getData();
    files.put(path,fileData);
    files.put(resolvePath(path),fileData);
    filesUploaded.add(new FileInfo(f.getFile(),f.getTimestamp()));
  }
  browser.addFiles(filesUploaded);
}

Fixed version (ground truth):
public void uploadFiles(String id,String data){
  SlaveBrowser browser=capturedBrowsers.getBrowser(id);
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  LinkedHashSet<FileInfo> filesUploaded=new LinkedHashSet<FileInfo>();
  for (  FileData f : filesData) {
    String path=f.getFile();
    String fileData=f.getData();
    files.put(path,fileData);
    files.put(resolvePath(path),fileData);
    filesUploaded.add(new FileInfo(f.getFile(),f.getTimestamp(),false));
  }
  browser.addFiles(filesUploaded);
}
Program: 7114
Project: 7114
Buggy source:
@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws IOException {
  service(resp.getWriter());
}

Fixed version (ground truth):
@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws IOException {
  PrintWriter writer=resp.getWriter();
  if ("String_Node_Str".equals(req.getRequestURI())) {
    service(writer);
  }
 else {
    resp.setStatus(204);
    writer.flush();
  }
}
Program: 7115
Project: 7115
Buggy source:
private Set<String> resolveFiles(List<String> files){
  if (files != null) {
    Set<String> resolvedFiles=new LinkedHashSet<String>();
    for (    String f : files) {
      if (f.startsWith("String_Node_Str") || f.startsWith("String_Node_Str")) {
        resolvedFiles.add(f);
      }
 else {
        File testFile=new File(f);
        String relativeDir=testFile.getParent() == null ? "String_Node_Str" : testFile.getParent();
        File file=basePath != null ? new File(basePath,f) : new File(f);
        File dir=file.getParentFile() == null ? new File("String_Node_Str") : file.getParentFile();
        final String pattern=file.getName();
        String[] filteredFiles=dir.list(new GlobFilenameFilter(pattern,GlobCompiler.DEFAULT_MASK | GlobCompiler.CASE_INSENSITIVE_MASK));
        for (        String filteredFile : filteredFiles) {
          String normalizedRelativeDir=relativeDir.replaceAll("String_Node_Str","String_Node_Str");
          if (normalizedRelativeDir.length() > 0) {
            normalizedRelativeDir+="String_Node_Str";
          }
          resolvedFiles.add(String.format("String_Node_Str",normalizedRelativeDir,filteredFile.replaceAll("String_Node_Str","String_Node_Str")));
        }
      }
    }
    return resolvedFiles;
  }
  return EMPTY_SET;
}

Fixed version (ground truth):
private Set<String> resolveFiles(List<String> files){
  if (files != null) {
    Set<String> resolvedFiles=new LinkedHashSet<String>();
    for (    String f : files) {
      if (f.startsWith("String_Node_Str") || f.startsWith("String_Node_Str")) {
        resolvedFiles.add(f);
      }
 else {
        File testFile=new File(f);
        String relativeDir=testFile.getParent() == null ? "String_Node_Str" : testFile.getParent();
        File file=basePath != null ? new File(basePath,f) : new File(f);
        File dir=file.getParentFile() == null ? new File("String_Node_Str") : file.getParentFile();
        final String pattern=file.getName();
        String[] filteredFiles=dir.list(new GlobFilenameFilter(pattern,GlobCompiler.DEFAULT_MASK | GlobCompiler.CASE_INSENSITIVE_MASK));
        if (filteredFiles == null) {
          System.err.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
          System.exit(1);
        }
        String normalizedBasePath=basePath != null ? basePath.getPath().replaceAll("String_Node_Str","String_Node_Str") + "String_Node_Str" : "String_Node_Str";
        for (        String filteredFile : filteredFiles) {
          String normalizedRelativeDir=relativeDir.replaceAll("String_Node_Str","String_Node_Str");
          if (normalizedRelativeDir.length() > 0) {
            normalizedRelativeDir+="String_Node_Str";
          }
          resolvedFiles.add(String.format("String_Node_Str",normalizedBasePath,normalizedRelativeDir,filteredFile.replaceAll("String_Node_Str","String_Node_Str")));
        }
      }
    }
    return resolvedFiles;
  }
  return EMPTY_SET;
}
Program: 7116
Project: 7116
Buggy source:
public void uploadFiles(String id,String data){
  SlaveBrowser browser=capturedBrowsers.getBrowser(id);
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  LinkedHashSet<FileInfo> filesUploaded=new LinkedHashSet<FileInfo>();
  for (  FileData f : filesData) {
    files.put(f.getFile(),f.getData());
    filesUploaded.add(new FileInfo(f.getFile(),f.getTimestamp()));
  }
  browser.addFiles(filesUploaded);
}

Fixed version (ground truth):
public void uploadFiles(String id,String data){
  SlaveBrowser browser=capturedBrowsers.getBrowser(id);
  Collection<FileData> filesData=gson.fromJson(data,new TypeToken<Collection<FileData>>(){
  }
.getType());
  LinkedHashSet<FileInfo> filesUploaded=new LinkedHashSet<FileInfo>();
  for (  FileData f : filesData) {
    String path=f.getFile();
    String fileData=f.getData();
    files.put(path,fileData);
    files.put(resolvePath(path),fileData);
    filesUploaded.add(new FileInfo(f.getFile(),f.getTimestamp()));
  }
  browser.addFiles(filesUploaded);
}
Program: 7117
Project: 7117
Buggy source:
@Override public IObservable createObservable(Object target){
  if (target instanceof IObservableList) {
    return (IObservable)target;
  }
 else   if (target instanceof DeploymentRuntime) {
    return deployedExtensionsProperty.observe(deployedExtensionsProperty);
  }
  return null;
}

Fixed version (ground truth):
@Override public IObservable createObservable(Object target){
  if (target instanceof IObservableList) {
    return (IObservable)target;
  }
 else   if (target instanceof DeploymentRuntime) {
    return deployedExtensionsProperty.observe(target);
  }
  return null;
}
Program: 7119
Project: 7119
Buggy source:
public EventRequest getRequest(String url){
  RequestQueryResult requestQueryResult=restTemplate.getForObject(getUrl() + VIEW_ALL + "String_Node_Str",RequestQueryResult.class,url);
  return requestQueryResult.getRows().get(0).getValue();
}

Fixed version (ground truth):
public EventRequest getRequest(String locationKey,String date,String userid){
  String view=getUrl() + VIEW_ALL + "String_Node_Str";
  RequestQueryResult requestQueryResult=restTemplate.getForObject(view,RequestQueryResult.class,locationKey,date,userid);
  return requestQueryResult.getRows().get(0).getValue();
}
Program: 7120
Project: 7120
Buggy source:
public Collection<EventRequest> getRequestsByLocation(String location){
  return queryRequestView(VIEW_BY_LOCATION,location);
}

Fixed version (ground truth):
public Collection<EventRequest> getRequestsByLocation(String location){
  return queryRequestView(VIEW_BY_LOCATION,location.toLowerCase());
}
Program: 7121
Project: 7121
Buggy source:
public Collection<EventRequest> getRequestsByLocationAndDate(String location,String date){
  return queryRequestView(VIEW_BY_LOCATION_DATE,location,date);
}

Fixed version (ground truth):
public Collection<EventRequest> getRequestsByLocationAndDate(String location,String date){
  return queryRequestView(VIEW_BY_LOCATION_DATE,location.toLowerCase(),date);
}
Program: 7122
Project: 7122
Buggy source:
public EventRequest getRequest(String url);

Fixed version (ground truth):
public EventRequest getRequest(String locationKey,String date,String userid);
Program: 7123
Project: 7123
Buggy source:
@RequestMapping(value="String_Node_Str",method={RequestMethod.GET}) public @ResponseBody EventRequest getRequest(@PathVariable String location,@PathVariable String date,@PathVariable String user) throws EventNotFoundException {
  String url=createUrl(location,date,user);
  EventRequest eventRequest=dao.getRequest(url);
  if (eventRequest == null) {
    throw new EventNotFoundException(url);
  }
  return eventRequest;
}

Fixed version (ground truth):
@RequestMapping(value="String_Node_Str",method={RequestMethod.GET}) public @ResponseBody EventRequest getRequest(@PathVariable String location,@PathVariable String date,@PathVariable String user) throws EventNotFoundException {
  EventRequest eventRequest=dao.getRequest(location,date,user);
  if (eventRequest == null) {
    throw new EventNotFoundException(createUrl(location,date,user));
  }
  return eventRequest;
}
Program: 7124
Project: 7124
Buggy source:
/** 
 * Get closest Edge within a specified distance in meters.
 * @param point The point to search from.
 * @param radius The maximum distance an Edge can be at to be accepted.
 * @param eval An evaluator to eliminate roads that can't be traveled by the given travel mode
 * @return The closest edge within the maximum search distance.
 * @throws NothingCloseException If there are no edges within the maximum search distance.
 */
public KrakEdge getClosestEdge(Point2D.Double point,double radius,Evaluator eval) throws NothingCloseException {
  Rectangle2D.Double search_area=new Rectangle2D.Double(point.x - radius,point.y - radius,2 * radius,2 * radius);
  List<KrakEdge> all=query(search_area);
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  for (  KrakEdge edge : all) {
    if (edge.roadname.length() > 1) {
      double cur_dist=edge.getLine().ptSegDist(point);
      try {
        eval.evaluate(edge);
        if (cur_dist < distance) {
          distance=cur_dist;
          closest=edge;
        }
      }
 catch (      NotPassableException e) {
      }
    }
  }
  if (closest != null && distance < radius) {
    return closest;
  }
 else {
    throw new NothingCloseException("String_Node_Str" + Model.ROAD_SEARCH_DISTANCE);
  }
}

Fixed version (ground truth):
/** 
 * Get closest Edge within a specified distance in meters.
 * @param point The point to search from.
 * @param radius The maximum distance an Edge can be at to be accepted.
 * @param eval An evaluator to eliminate roads that can't be traveled by the given travel mode
 * @return The closest edge within the maximum search distance.
 * @throws NothingCloseException If there are no edges within the maximum search distance.
 */
public KrakEdge getClosestEdge(Point2D.Double point,double radius,Evaluator eval) throws NothingCloseException {
  Rectangle2D.Double search_area=new Rectangle2D.Double(point.x - radius,point.y - radius,2 * radius,2 * radius);
  List<KrakEdge> all=query(search_area);
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  for (  KrakEdge edge : all) {
    double cur_dist=edge.getLine().ptSegDist(point);
    try {
      eval.evaluate(edge);
      if (cur_dist < distance) {
        distance=cur_dist;
        closest=edge;
      }
    }
 catch (    NotPassableException e) {
    }
  }
  if (closest != null && distance < radius) {
    return closest;
  }
 else {
    throw new NothingCloseException("String_Node_Str" + Model.ROAD_SEARCH_DISTANCE);
  }
}
Program: 7125
Project: 7125
Buggy source:
/** 
 * Gives the name of the closest road from a given point.
 * @param point the point to search from
 * @return the name of the closest road. If there is no path it will return a String of one whitespace.
 */
public String getClosestRoadname(Point2D.Double point){
  KrakEdge road;
  try {
    road=getClosestEdge(point,Model.ROAD_SEARCH_DISTANCE,Evaluator.ANYTHING);
    return road.roadname;
  }
 catch (  NothingCloseException e) {
    return "String_Node_Str";
  }
}

Fixed version (ground truth):
/** 
 * Gives the name of the closest road from a given point.
 * @param point the point to search from
 * @return the name of the closest road. If there is no path it will return a String of one whitespace.
 */
public String getClosestRoadname(Point2D.Double point){
  KrakEdge road;
  try {
    road=getClosestEdge(point,Model.ROAD_SEARCH_DISTANCE,Evaluator.HAS_NAME);
    return road.roadname;
  }
 catch (  NothingCloseException e) {
    return "String_Node_Str";
  }
}
Program: 7127
Project: 7127
Buggy source:
/** 
 * Used to find the path between two points - opens dialog window in view if problems occur.
 * @param start What pin the start point is at.
 * @param end What pin the end point is at.
 */
private void findPath(int start,int end){
  Evaluator<KrakEdge> eval=null;
  if (view.isCarChoiceSelected()) {
    eval=Evaluator.CAR;
    System.out.println("String_Node_Str");
  }
 else   if (view.isBikeChoiceSelected()) {
    eval=Evaluator.BIKE;
    System.out.println("String_Node_Str");
  }
  try {
    model.findPath(model.getClosestNode(pins.get(start)),model.getClosestNode(pins.get(end)),eval);
  }
 catch (  NothingCloseException e1) {
    view.displayDialog("String_Node_Str","String_Node_Str");
  }
catch (  NoPathException e2) {
    view.displayDialog("String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Used to find the path between two points - opens dialog window in view if problems occur.
 * @param start What pin the start point is at.
 * @param end What pin the end point is at.
 */
private void findPath(int start,int end){
  Evaluator<KrakEdge> eval=null;
  if (view.isCarChoiceSelected()) {
    eval=Evaluator.CAR;
  }
 else   if (view.isBikeChoiceSelected()) {
    eval=Evaluator.BIKE;
  }
  try {
    model.findPath(model.getClosestNode(pins.get(start)),model.getClosestNode(pins.get(end)),eval);
  }
 catch (  NothingCloseException e1) {
    view.displayDialog("String_Node_Str","String_Node_Str");
  }
catch (  NoPathException e2) {
    view.displayDialog("String_Node_Str","String_Node_Str");
  }
}
Program: 7128
Project: 7128
Buggy source:
/** 
 * Finds the closest node within 200 meters from a given point
 * @param point the given point
 * @return the closest node from the point
 * @throws NothingCloseException If there are no nodes within the maximum search distance.
 */
public KrakNode getClosestNode(Point2D.Double point) throws NothingCloseException {
  float curDistance=Model.ROAD_SEARCH_DISTANCE;
  KrakEdge edge=null;
  while (edge == null) {
    try {
      edge=getClosestEdge(point,curDistance);
    }
 catch (    NothingCloseException e) {
      if (2 * curDistance > maxBounds.width && 2 * curDistance > maxBounds.height) {
        throw e;
      }
      curDistance*=2;
    }
  }
  System.out.println("String_Node_Str" + edge.roadname);
  KrakNode first=edge.getEnd();
  KrakNode second=edge.getOtherEnd(first);
  if (first.getPoint().distance(point) < second.getPoint().distance(point)) {
    return first;
  }
  return second;
}

Fixed version (ground truth):
/** 
 * Finds the closest node within 200 meters from a given point
 * @param point the given point
 * @return the closest node from the point
 * @throws NothingCloseException If there are no nodes within the maximum search distance.
 */
public KrakNode getClosestNode(Point2D.Double point) throws NothingCloseException {
  float curDistance=Model.ROAD_SEARCH_DISTANCE;
  KrakEdge edge=null;
  while (edge == null) {
    try {
      edge=getClosestEdge(point,curDistance);
    }
 catch (    NothingCloseException e) {
      if (2 * curDistance > maxBounds.width && 2 * curDistance > maxBounds.height) {
        throw e;
      }
      curDistance*=2;
    }
  }
  KrakNode first=edge.getEnd();
  KrakNode second=edge.getOtherEnd(first);
  if (first.getPoint().distance(point) < second.getPoint().distance(point)) {
    return first;
  }
  return second;
}
Program: 7129
Project: 7129
Buggy source:
@Override public void mouseClicked(MouseEvent e){
  pins.add(PointMethods.pixelToUTM(e.getPoint(),model,view));
  if (pins.size() > 1) {
    for (int i=0; i < pins.size() - 1; i++) {
      try {
        model.findPath(model.getClosestNode(pins.get(i)),model.getClosestNode(pins.get(i + 1)));
      }
 catch (      NothingCloseException e1) {
        view.displayDialog("String_Node_Str","String_Node_Str");
      }
catch (      NoPathException e2) {
        view.displayDialog("String_Node_Str","String_Node_Str");
      }
    }
  }
  repaint();
}

Fixed version (ground truth):
@Override public void mouseClicked(MouseEvent e){
  pins.add(PointMethods.pixelToUTM(e.getPoint(),model,view));
  if (pins.size() > 1) {
    try {
      model.findPath(model.getClosestNode(pins.get(pins.size() - 2)),model.getClosestNode(pins.get(pins.size() - 1)));
    }
 catch (    NothingCloseException e1) {
      view.displayDialog("String_Node_Str","String_Node_Str");
    }
catch (    NoPathException e2) {
      view.displayDialog("String_Node_Str","String_Node_Str");
    }
  }
  repaint();
}
Program: 7131
Project: 7131
Buggy source:
@Override public void run(){
  try {
    BufferedInputStream bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
    ObjectInputStream ois=new ObjectInputStream(bin);
    qt.add((QuadTree<KrakEdge>)ois.readObject());
    ois.close();
    bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
    ois=new ObjectInputStream(bin);
    qt.add((QuadTree<KrakEdge>)ois.readObject());
    ois.close();
    if (loadGraph) {
      bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
      ois=new ObjectInputStream(bin);
      graph=(Graph<KrakEdge,KrakNode>)ois.readObject();
      ois.close();
    }
  }
 catch (  Exception e) {
    System.exit(0);
  }
}

Fixed version (ground truth):
@Override public void run(){
  Stopwatch sw=new Stopwatch("String_Node_Str");
  try {
    BufferedInputStream bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
    ObjectInputStream ois=new ObjectInputStream(bin);
    qt.add((QuadTree<KrakEdge>)ois.readObject());
    ois.close();
    bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
    ois=new ObjectInputStream(bin);
    qt.add((QuadTree<KrakEdge>)ois.readObject());
    ois.close();
    if (loadGraph) {
      bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
      ois=new ObjectInputStream(bin);
      graph=(Graph<KrakEdge,KrakNode>)ois.readObject();
      ois.close();
    }
  }
 catch (  Exception e) {
    System.out.println(e.getMessage());
    System.exit(0);
  }
  sw.printTime();
}
Program: 7132
Project: 7132
Buggy source:
private void loadSerializedFromFiles(final boolean loadGraph) throws IOException, ClassNotFoundException {
  BufferedInputStream bin;
  bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
  ObjectInputStream ois=new ObjectInputStream(bin);
  qt.add((QuadTree<KrakEdge>)ois.readObject());
  ois.close();
  bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
  ois=new ObjectInputStream(bin);
  maxBounds=(Rectangle2D.Double)ois.readObject();
  bounds=originalBounds();
  ois.close();
  new Thread(){
    @Override public void run(){
      try {
        BufferedInputStream bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
        ObjectInputStream ois=new ObjectInputStream(bin);
        qt.add((QuadTree<KrakEdge>)ois.readObject());
        ois.close();
        bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
        ois=new ObjectInputStream(bin);
        qt.add((QuadTree<KrakEdge>)ois.readObject());
        ois.close();
        if (loadGraph) {
          bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
          ois=new ObjectInputStream(bin);
          graph=(Graph<KrakEdge,KrakNode>)ois.readObject();
          ois.close();
        }
      }
 catch (      Exception e) {
        System.exit(0);
      }
    }
  }
.start();
}

Fixed version (ground truth):
private void loadSerializedFromFiles(final boolean loadGraph) throws IOException, ClassNotFoundException {
  BufferedInputStream bin;
  bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
  ObjectInputStream ois=new ObjectInputStream(bin);
  qt.add((QuadTree<KrakEdge>)ois.readObject());
  ois.close();
  bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
  ois=new ObjectInputStream(bin);
  maxBounds=(Rectangle2D.Double)ois.readObject();
  bounds=originalBounds();
  ois.close();
  new Thread(){
    @Override public void run(){
      Stopwatch sw=new Stopwatch("String_Node_Str");
      try {
        BufferedInputStream bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
        ObjectInputStream ois=new ObjectInputStream(bin);
        qt.add((QuadTree<KrakEdge>)ois.readObject());
        ois.close();
        bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
        ois=new ObjectInputStream(bin);
        qt.add((QuadTree<KrakEdge>)ois.readObject());
        ois.close();
        if (loadGraph) {
          bin=new BufferedInputStream(new FileInputStream(Properties.get("String_Node_Str")));
          ois=new ObjectInputStream(bin);
          graph=(Graph<KrakEdge,KrakNode>)ois.readObject();
          ois.close();
        }
      }
 catch (      Exception e) {
        System.out.println(e.getMessage());
        System.exit(0);
      }
      sw.printTime();
    }
  }
.start();
}
Program: 7133
Project: 7133
Buggy source:
/** 
 * Create a new DijkstraSP from the startNode, and finds the path to the endNode. The path is returned as an arraylist of lines
 * @throws NoPathException 
 */
public void findPath(KrakNode startNode,KrakNode endNode) throws NothingCloseException, NoPathException {
  if (startNode == null)   throw new NothingCloseException("String_Node_Str");
  if (endNode == null)   throw new NothingCloseException("String_Node_Str");
  path.addAll(Dijkstra.findPath(graph,startNode,endNode));
}

Fixed version (ground truth):
/** 
 * Create a new DijkstraSP from the startNode, and finds the path to the endNode. The path is returned as an arraylist of lines
 * @throws NoPathException 
 */
public void findPath(KrakNode startNode,KrakNode endNode) throws NothingCloseException, NoPathException {
  while (graph == null)   Thread.yield();
  if (startNode == null)   throw new NothingCloseException("String_Node_Str");
  if (endNode == null)   throw new NothingCloseException("String_Node_Str");
  path.addAll(Dijkstra.findPath(graph,startNode,endNode));
}
Program: 7134
Project: 7134
Buggy source:
public static String getMD5Checksum(String filename) throws Exception {
  byte[] b=createChecksum(filename);
  String result="String_Node_Str";
  for (int i=0; i < b.length; i++) {
    result.concat(Integer.toString((b[i] & 0xff) + 0x100,16).substring(1));
  }
  return result;
}

Fixed version (ground truth):
public static String getMD5Checksum(String filename) throws Exception {
  byte[] b=createChecksum(filename);
  String result="String_Node_Str";
  for (int i=0; i < b.length; i++) {
    result=result.concat(Integer.toString((b[i] & 0xff) + 0x100,16).substring(1));
  }
  return result;
}
Program: 7135
Project: 7135
Buggy source:
@Override public void keyReleased(KeyEvent e){
  if (e.getKeyCode() == 27) {
    m.resetView();
    v.repaint(m.getLines());
  }
}

Fixed version (ground truth):
@Override public void keyReleased(KeyEvent e){
  if (e.getKeyCode() == 27) {
    Rectangle2D.Double temp=(Double)m.originalView().clone();
    fixRatio(temp,m.getBounds());
    m.updateBounds(temp);
    v.repaint(m.getLines());
  }
}
Program: 7137
Project: 7137
Buggy source:
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea){
  double area=(qarea.width / 1000) * (qarea.height / 1000);
  System.out.println("String_Node_Str" + area + "String_Node_Str");
  Set<T> total;
  total=root1.query(qarea);
  if (area < 50000) {
    System.out.println("String_Node_Str");
    total.addAll(root2.query(qarea));
    if (area < 5000) {
      System.out.println("String_Node_Str");
      total.addAll(root3.query(qarea));
    }
  }
  return total;
}

Fixed version (ground truth):
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea){
  double area=(qarea.width / 1000) * (qarea.height / 1000);
  Set<T> total;
  total=root1.query(qarea);
  if (area < CENTER_LEVEL) {
    total.addAll(root2.query(qarea));
    if (area < INNER_LEVEL) {
      total.addAll(root3.query(qarea));
    }
  }
  return total;
}
Program: 7138
Project: 7138
Buggy source:
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea){
  if (!isEmpty()) {
    Set<T> results=new HashSet<T>();
    for (    QuadTreeNode<T> item : nodes) {
      if (item.getBounds().intersects(qarea)) {
        Set<T> temp=item.query(qarea);
        if (temp.size() > 0) {
          if (results.size() == 0) {
            results=item.query(qarea);
          }
 else {
            results.addAll(item.query(qarea));
          }
        }
      }
    }
    return results;
  }
 else {
    return contents;
  }
}

Fixed version (ground truth):
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea){
  if (!isEmpty()) {
    Set<T> results=new HashSet<T>();
    for (    QuadTreeNode<T> item : nodes) {
      if (item.getBounds().intersects(qarea)) {
        results.addAll(item.query(qarea));
      }
    }
    return results;
  }
 else {
    return contents;
  }
}
Program: 7139
Project: 7139
Buggy source:
public String getClosestRoad(Point2D.Double point){
  System.out.println("String_Node_Str");
  Set<KrakEdge> all=qt.query(new Rectangle2D.Double(point.x - this.ROAD_SEARCH_DISTANCE,point.y - this.ROAD_SEARCH_DISTANCE,point.x + this.ROAD_SEARCH_DISTANCE,point.x + this.ROAD_SEARCH_DISTANCE));
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  for (  KrakEdge edge : all) {
    double cur_dist=edge.getLine().ptLineDist(point);
    if (cur_dist < distance) {
      distance=cur_dist;
      closest=edge;
    }
  }
  if (closest != null) {
    return closest.roadname;
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
public String getClosestRoad(Point2D.Double point){
  System.out.println("String_Node_Str");
  Set<KrakEdge> all=qt.query(new Rectangle2D.Double(point.x - Map.ROAD_SEARCH_DISTANCE,point.y - Map.ROAD_SEARCH_DISTANCE,point.x + Map.ROAD_SEARCH_DISTANCE,point.y + Map.ROAD_SEARCH_DISTANCE));
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  System.out.println(all.size() + "String_Node_Str");
  for (  KrakEdge edge : all) {
    double cur_dist=edge.getLine().ptLineDist(point);
    if (cur_dist < distance) {
      distance=cur_dist;
      closest=edge;
    }
  }
  if (closest != null) {
    return closest.roadname;
  }
  return "String_Node_Str";
}
Program: 7141
Project: 7141
Buggy source:
/** 
 * @param point
 * @return
 */
public String getClosestRoad(Point2D.Double point){
  System.out.println("String_Node_Str");
  Set<KrakEdge> all=qt.query(new Rectangle2D.Double(point.x - this.ROAD_SEARCH_DISTANCE,point.y - this.ROAD_SEARCH_DISTANCE,point.x + this.ROAD_SEARCH_DISTANCE,point.x + this.ROAD_SEARCH_DISTANCE),zoomLevel());
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  System.out.println(all.size() + "String_Node_Str");
  for (  KrakEdge edge : all) {
    double cur_dist=edge.getLine().ptLineDist(point);
    if (cur_dist < distance) {
      distance=cur_dist;
      closest=edge;
    }
  }
  if (closest != null) {
    System.out.printf("String_Node_Str" + closest.roadname + "String_Node_Str",distance);
    return closest.roadname;
  }
  return "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * @param point
 * @return
 */
public String getClosestRoad(Point2D.Double point){
  Rectangle2D.Double search_area=new Rectangle2D.Double(point.x - Map.ROAD_SEARCH_DISTANCE,point.y - Map.ROAD_SEARCH_DISTANCE,2 * Map.ROAD_SEARCH_DISTANCE,2 * Map.ROAD_SEARCH_DISTANCE);
  Set<KrakEdge> all=qt.query(search_area);
  double distance=Integer.MAX_VALUE;
  KrakEdge closest=null;
  for (  KrakEdge edge : all) {
    if (edge.roadname.length() > 1) {
      double cur_dist=edge.getLine().ptSegDist(point);
      if (cur_dist < distance) {
        distance=cur_dist;
        closest=edge;
      }
    }
  }
  if (closest != null && distance < 200) {
    return closest.roadname;
  }
  return "String_Node_Str";
}
Program: 7143
Project: 7143
Buggy source:
/** 
 * Constructor Initialize variables.  Set the map to look at the entire graph.
 */
public Map(Graph<KrakEdge,KrakNode> graph){
  System.out.println(graph);
  bounds=outerBounds(graph.getNodes());
  this.qt=new QuadTree<KrakEdge>(bounds,graph.getAllEdges());
}

Fixed version (ground truth):
/** 
 * Constructor Initialize variables.  Set the map to look at the entire graph.
 */
public Map(Graph<KrakEdge,KrakNode> graph){
  bounds=outerBounds(graph.getNodes());
  this.qt=new QuadTree<KrakEdge>(bounds,graph.getAllEdges());
}
Program: 7144
Project: 7144
Buggy source:
public QuadTree(Rectangle2D.Double bounds,Set<T> content){
  System.out.print("String_Node_Str");
  Stopwatch timer=new Stopwatch();
  int zoomLevel=0;
  QuadTree.content=(Set<KrakEdge>)content;
  root=new QuadTreeNode<T>(bounds,content,zoomLevel);
  System.out.printf("String_Node_Str",timer.getTime());
}

Fixed version (ground truth):
public QuadTree(Rectangle2D.Double bounds,Set<T> content){
  Stopwatch timer=new Stopwatch("String_Node_Str");
  root=new QuadTreeNode<T>(bounds,content);
  timer.printTime();
}
Program: 7145
Project: 7145
Buggy source:
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea,int zoomLevel){
  return root.query(qarea,zoomLevel);
}

Fixed version (ground truth):
/** 
 * Querries the node for KrakEdges with a specific rectangle
 * @param qarea The rectangle for which to find all KrakEdges
 * @return A Set with all KrakEdges within the given Rectangle
 */
public Set<T> query(Rectangle2D.Double qarea){
  return root.query(qarea);
}
Program: 7146
Project: 7146
Buggy source:
/** 
 * Move the bounds in a specified direction. The length is how far to move in percentage of the screen.
 * @param d	The direction to move (4 directions)
 * @param length	The length to move (in percentage of the screen)
 */
public void move(Direction d,double length){
  double horizontalChange=d.coordinatepoint().getX() * bounds.getWidth() * length;
  double verticalChange=d.coordinatepoint().getY() * bounds.getHeight() * length;
  bounds.setRect(bounds.getX() + horizontalChange,bounds.getY() + verticalChange,bounds.getWidth(),bounds.getHeight());
  updateEdges();
}

Fixed version (ground truth):
/** 
 * Move the bounds in a specified direction. The length is how far to move in percentage of the screen.
 * @param d	The direction to move (4 directions)
 * @param length	The length to move (in percentage of the screen)
 */
public void move(Direction d,double length){
  double horizontalChange=d.coordinatepoint().getX() * bounds.getWidth() * length;
  double verticalChange=d.coordinatepoint().getY() * bounds.getHeight() * length;
  bounds.setRect(bounds.getX() + horizontalChange,bounds.getY() + verticalChange,bounds.getWidth(),bounds.getHeight());
}
Program: 7147
Project: 7147
Buggy source:
/** 
 * Zoom in or out of the graph
 * @param view The rectangle of the view to zoom to.
 */
public void zoom(Rectangle2D bounds){
  this.bounds=bounds;
}

Fixed version (ground truth):
/** 
 * Zoom in or out of the graph
 * @param view The rectangle of the view to zoom to.
 */
public void zoom(Rectangle2D.Double bounds){
  this.bounds=bounds;
}
Program: 7148
Project: 7148
Buggy source:
public void startRecording(int outputfileformat,String extension){
  stop();
  if (mSampleFile == null) {
    File sampleDir=Environment.getExternalStorageDirectory();
    if (!sampleDir.canWrite())     sampleDir=new File("String_Node_Str");
    try {
      mSampleFile=File.createTempFile(SAMPLE_PREFIX,extension,sampleDir);
    }
 catch (    IOException e) {
      setError(SDCARD_ACCESS_ERROR);
      return;
    }
  }
  mRecorder=new MediaRecorder();
  mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mRecorder.setOutputFormat(outputfileformat);
  mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
  try {
    mRecorder.prepare();
  }
 catch (  IOException exception) {
    setError(INTERNAL_ERROR);
    mRecorder.reset();
    mRecorder.release();
    mRecorder=null;
    return;
  }
  mRecorder.start();
  mSampleStart=System.currentTimeMillis();
  setState(RECORDING_STATE);
}

Fixed version (ground truth):
public void startRecording(int outputfileformat,String extension,Context context){
  stop();
  if (mSampleFile == null) {
    File sampleDir=Environment.getExternalStorageDirectory();
    if (!sampleDir.canWrite())     sampleDir=new File("String_Node_Str");
    try {
      mSampleFile=File.createTempFile(SAMPLE_PREFIX,extension,sampleDir);
    }
 catch (    IOException e) {
      setError(SDCARD_ACCESS_ERROR);
      return;
    }
  }
  mRecorder=new MediaRecorder();
  mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mRecorder.setOutputFormat(outputfileformat);
  mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  mRecorder.setOutputFile(mSampleFile.getAbsolutePath());
  try {
    mRecorder.prepare();
  }
 catch (  IOException exception) {
    setError(INTERNAL_ERROR);
    mRecorder.reset();
    mRecorder.release();
    mRecorder=null;
    return;
  }
  try {
    mRecorder.start();
  }
 catch (  RuntimeException exception) {
    AudioManager audioMngr=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    boolean isInCall=audioMngr.getMode() == AudioManager.MODE_IN_CALL;
    if (isInCall) {
      setError(IN_CALL_RECORD_ERROR);
    }
 else {
      setError(INTERNAL_ERROR);
    }
    mRecorder.reset();
    mRecorder.release();
    mRecorder=null;
    return;
  }
  mSampleStart=System.currentTimeMillis();
  setState(RECORDING_STATE);
}