nus-yam/ex-repair huggingface dataset:
Program: 110141
Project: 110141
Buggy source:
/** 
 * Retrieve facebook access token.
 * @param code Facebook "authorization code"
 * @return The token
 * @throws IOException If some problem with FB
 */
private String token(final String code) throws IOException {
  final String response=this.retrieve(UriBuilder.fromPath("String_Node_Str").queryParam("String_Node_Str",Manifests.read("String_Node_Str")).queryParam("String_Node_Str",this.base().path("String_Node_Str").build()).queryParam("String_Node_Str",Manifests.read("String_Node_Str")).queryParam("String_Node_Str",code).build());
  final String[] sectors=response.split("String_Node_Str");
  for (  String sector : sectors) {
    final String[] pair=sector.split("String_Node_Str");
    if (pair.length != 2) {
      throw new IOException(String.format("String_Node_Str",response));
    }
    if ("String_Node_Str".equals(pair[0])) {
      return pair[1];
    }
  }
  throw new IOException(String.format("String_Node_Str",response));
}

Fixed version (ground truth):
/** 
 * Retrieve facebook access token.
 * @param code Facebook "authorization code"
 * @return The token
 * @throws IOException If some problem with FB
 */
private String token(final String code) throws IOException {
  final String response=this.retrieve(UriBuilder.fromPath("String_Node_Str").queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").build(Manifests.read("String_Node_Str"),this.base().path("String_Node_Str").build(),Manifests.read("String_Node_Str"),code));
  final String[] sectors=response.split("String_Node_Str");
  for (  String sector : sectors) {
    final String[] pair=sector.split("String_Node_Str");
    if (pair.length != 2) {
      throw new IOException(String.format("String_Node_Str",response));
    }
    if ("String_Node_Str".equals(pair[0])) {
      return pair[1];
    }
  }
  throw new IOException(String.format("String_Node_Str",response));
}
Program: 110142
Project: 110142
Buggy source:
/** 
 * Build link to period.
 * @param name Name of this link
 * @param title The title of it
 * @return The link
 */
private Link link(final String name,final String title){
  return new Link(name,String.format("String_Node_Str",title,this.total),this.base.clone().queryParam(this.param,this.period));
}

Fixed version (ground truth):
/** 
 * Build link to period.
 * @param name Name of this link
 * @param title The title of it
 * @return The link
 */
private Link link(final String name,final String title){
  return new Link(name,String.format("String_Node_Str",title,this.total),UriBuilder.fromUri(this.base.clone().queryParam(this.param,"String_Node_Str").build(this.period)));
}
Program: 110143
Project: 110143
Buggy source:
/** 
 * Utc can save date to prepared statement.
 * @throws Exception If there is some problem inside
 */
@Test public void savesDateWithUtcTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  this.fmt.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("String_Node_Str")));
  final Date date=this.fmt.parse("String_Node_Str");
  final Connection conn=Database.connection();
  String saved;
  try {
    final PreparedStatement ustmt=conn.prepareStatement("String_Node_Str");
    Utc.setTimestamp(ustmt,1,date);
    ustmt.setLong(2,message);
    ustmt.executeUpdate();
    final PreparedStatement rstmt=conn.prepareStatement("String_Node_Str");
    rstmt.setLong(1,message);
    final ResultSet rset=rstmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException();
      }
      saved=rset.getString(1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  MatcherAssert.assertThat(saved,Matchers.equalTo("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Utc can save date to prepared statement.
 * @throws Exception If there is some problem inside
 */
@Test public void savesDateWithUtcTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  this.fmt.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("String_Node_Str")));
  final Date date=this.fmt.parse("String_Node_Str");
  final Connection conn=Database.connection();
  String saved;
  try {
    final PreparedStatement ustmt=conn.prepareStatement("String_Node_Str");
    Utc.setTimestamp(ustmt,1,date);
    ustmt.setLong(2,message);
    ustmt.executeUpdate();
    final PreparedStatement rstmt=conn.prepareStatement("String_Node_Str");
    rstmt.setLong(1,message);
    final ResultSet rset=rstmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException();
      }
      saved=rset.getString(1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  MatcherAssert.assertThat(saved,Matchers.startsWith("String_Node_Str"));
}
Program: 110144
Project: 110144
Buggy source:
/** 
 * Utc can set and read message date, with different timezone.
 * @throws Exception If there is some problem inside
 */
@Test public void setsAndReadsDateWithDifferentTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  final Date date=new Date();
  new MessageFarm().changedMessageDate(message,date);
  final Connection conn=Database.connection();
  String saved;
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    stmt.setLong(1,message);
    final ResultSet rset=stmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalStateException();
      }
      saved=rset.getString(1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  this.fmt.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
  final Date absolute=this.fmt.parse(saved);
  MatcherAssert.assertThat(absolute,Matchers.equalTo(date));
}

Fixed version (ground truth):
/** 
 * Utc can set and read message date, with different timezone.
 * @throws Exception If there is some problem inside
 */
@Test public void setsAndReadsDateWithDifferentTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  final Date date=new Date();
  new MessageFarm().changedMessageDate(message,date);
  final Connection conn=Database.connection();
  String saved;
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    stmt.setLong(1,message);
    final ResultSet rset=stmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalStateException();
      }
      saved=rset.getString(1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  this.fmt.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
  final Date absolute=this.fmt.parse(saved);
  MatcherAssert.assertThat(absolute.toString(),Matchers.equalTo(date.toString()));
}
Program: 110145
Project: 110145
Buggy source:
/** 
 * Utc can load date from result set.
 * @throws Exception If there is some problem inside
 */
@Test public void loadsDateWithUtcTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  final Connection conn=Database.connection();
  Date loaded;
  try {
    final PreparedStatement ustmt=conn.prepareStatement("String_Node_Str");
    ustmt.setString(1,"String_Node_Str");
    ustmt.setLong(2,message);
    ustmt.executeUpdate();
    final PreparedStatement rstmt=conn.prepareStatement("String_Node_Str");
    rstmt.setLong(1,message);
    final ResultSet rset=rstmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException();
      }
      loaded=Utc.getTimestamp(rset,1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  this.fmt.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("String_Node_Str")));
  MatcherAssert.assertThat(this.fmt.format(loaded),Matchers.equalTo("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Utc can load date from result set.
 * @throws Exception If there is some problem inside
 */
@Test public void loadsDateWithUtcTimezone() throws Exception {
  final Long message=new MessageRowMocker(new BoutRowMocker().mock()).mock();
  final Connection conn=Database.connection();
  Date loaded;
  try {
    final PreparedStatement ustmt=conn.prepareStatement("String_Node_Str");
    ustmt.setString(1,"String_Node_Str");
    ustmt.setLong(2,message);
    ustmt.executeUpdate();
    final PreparedStatement rstmt=conn.prepareStatement("String_Node_Str");
    rstmt.setLong(1,message);
    final ResultSet rset=rstmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException();
      }
      loaded=Utc.getTimestamp(rset,1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  this.fmt.setCalendar(new GregorianCalendar(TimeZone.getTimeZone("String_Node_Str")));
  MatcherAssert.assertThat(this.fmt.format(loaded),Matchers.startsWith("String_Node_Str"));
}
Program: 110146
Project: 110146
Buggy source:
/** 
 * Changed message date.
 * @param number The bout where it happened
 * @param date The date of the message to change
 * @throws SQLException If some SQL problem inside
 */
@Operation("String_Node_Str") public void changedMessageDate(final Long number,final Date date) throws SQLException {
  final long start=System.currentTimeMillis();
  final Connection conn=Database.connection();
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    stmt.setTimestamp(1,new Timestamp(date.getTime()));
    stmt.setLong(2,number);
    final int updated=stmt.executeUpdate();
    if (updated != 1) {
      throw new SQLException(String.format("String_Node_Str",number,date));
    }
  }
  finally {
    conn.close();
  }
  Logger.debug(this,"String_Node_Str",number,date,System.currentTimeMillis() - start);
}

Fixed version (ground truth):
/** 
 * Changed message date.
 * @param number The bout where it happened
 * @param date The date of the message to change
 * @throws SQLException If some SQL problem inside
 */
@Operation("String_Node_Str") public void changedMessageDate(final Long number,final Date date) throws SQLException {
  final long start=System.currentTimeMillis();
  final Connection conn=Database.connection();
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    Utc.setTimestamp(stmt,1,date);
    stmt.setLong(2,number);
    final int updated=stmt.executeUpdate();
    if (updated != 1) {
      throw new SQLException(String.format("String_Node_Str",number,date));
    }
  }
  finally {
    conn.close();
  }
  Logger.debug(this,"String_Node_Str",number,date,System.currentTimeMillis() - start);
}
Program: 110147
Project: 110147
Buggy source:
/** 
 * Get message date.
 * @param number Number of the message
 * @return The date
 * @throws SQLException If some SQL problem inside
 */
@Operation("String_Node_Str") public Date getMessageDate(final Long number) throws SQLException {
  final long start=System.currentTimeMillis();
  final Connection conn=Database.connection();
  Date date;
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    stmt.setLong(1,number);
    final ResultSet rset=stmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException(String.format("String_Node_Str",number));
      }
      date=new Date(rset.getTimestamp(1).getTime());
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  Logger.debug(this,"String_Node_Str",number,date,System.currentTimeMillis() - start);
  return date;
}

Fixed version (ground truth):
/** 
 * Get message date.
 * @param number Number of the message
 * @return The date
 * @throws SQLException If some SQL problem inside
 */
@Operation("String_Node_Str") public Date getMessageDate(final Long number) throws SQLException {
  final long start=System.currentTimeMillis();
  final Connection conn=Database.connection();
  Date date;
  try {
    final PreparedStatement stmt=conn.prepareStatement("String_Node_Str");
    stmt.setLong(1,number);
    final ResultSet rset=stmt.executeQuery();
    try {
      if (!rset.next()) {
        throw new IllegalArgumentException(String.format("String_Node_Str",number));
      }
      date=Utc.getTimestamp(rset,1);
    }
  finally {
      rset.close();
    }
  }
  finally {
    conn.close();
  }
  Logger.debug(this,"String_Node_Str",number,date,System.currentTimeMillis() - start);
  return date;
}
Program: 110148
Project: 110148
Buggy source:
/** 
 * Facebook authentication page (callback hits it).
 * @param code Facebook "authorization code"
 * @return The JAX-RS response
 */
@GET @Path("String_Node_Str") public Response fbauth(@QueryParam("String_Node_Str") final String code){
  this.logoff();
  final Identity remote=(Identity)new FacebookRs().auth(Urn.create("String_Node_Str"),code).getEntity();
  Identity identity;
  try {
    identity=this.hub().identity(remote.name());
  }
 catch (  com.netbout.spi.UnreachableUrnException ex) {
    throw new LoginRequiredException(this,ex);
  }
  return new PageBuilder().build(AbstractPage.class).init(this).authenticated(identity).status(Response.Status.SEE_OTHER).location(this.base().build()).build();
}

Fixed version (ground truth):
/** 
 * Facebook authentication page (callback hits it).
 * @param code Facebook "authorization code"
 * @return The JAX-RS response
 */
@GET @Path("String_Node_Str") public Response fbauth(@QueryParam("String_Node_Str") final String code){
  this.logoff();
  Identity remote;
  try {
    remote=new AuthMediator(this.hub().resolver()).authenticate(new Urn("String_Node_Str","String_Node_Str"),code);
  }
 catch (  java.io.IOException ex) {
    throw new LoginRequiredException(this,ex);
  }
  Identity identity;
  try {
    identity=this.hub().identity(remote.name());
  }
 catch (  com.netbout.spi.UnreachableUrnException ex) {
    throw new LoginRequiredException(this,ex);
  }
  return new PageBuilder().build(AbstractPage.class).init(this).authenticated(identity).status(Response.Status.SEE_OTHER).location(this.base().build()).build();
}
Program: 110149
Project: 110149
Buggy source:
/** 
 * Authenticate the user through facebook.
 * @param iname Identity name
 * @param secret Secret word
 * @return The identity found
 */
private Identity authenticate(final Urn iname,final String secret){
  final Identity remote=this.remote(iname,secret);
  Identity identity;
  try {
    identity=this.hub().identity(iname);
  }
 catch (  com.netbout.spi.UnreachableUrnException ex) {
    throw new LoginRequiredException(this,ex);
  }
  for (  String alias : remote.aliases()) {
    identity.alias(alias);
  }
  identity.setPhoto(remote.photo());
  return identity;
}

Fixed version (ground truth):
/** 
 * Authenticate the user through facebook.
 * @param iname Identity name
 * @param secret Secret word
 * @return The identity found
 */
private Identity authenticate(final Urn iname,final String secret){
  Identity remote;
  try {
    remote=new AuthMediator(this.hub().resolver()).authenticate(iname,secret);
  }
 catch (  java.io.IOException ex) {
    throw new LoginRequiredException(this,ex);
  }
  Identity identity;
  try {
    identity=this.hub().identity(iname);
  }
 catch (  com.netbout.spi.UnreachableUrnException ex) {
    throw new LoginRequiredException(this,ex);
  }
  for (  String alias : remote.aliases()) {
    identity.alias(alias);
  }
  identity.setPhoto(remote.photo());
  return identity;
}
Program: 110150
Project: 110150
Buggy source:
/** 
 * Authentication page.
 * @param iname Name of identity
 * @param secret The secret code
 * @return The JAX-RS response
 */
@GET public Response auth(@QueryParam("String_Node_Str") final Urn iname,@QueryParam("String_Node_Str") final String secret){
  if (iname == null || secret == null) {
    throw new LoginRequiredException(this,"String_Node_Str");
  }
  Identity identity;
  try {
    identity=this.authenticate(secret);
  }
 catch (  IOException ex) {
    throw new LoginRequiredException(this,ex);
  }
  Logger.debug(this,"String_Node_Str",iname,secret);
  return new PageBuilder().build(AbstractPage.class).init(this).authenticated(identity).build();
}

Fixed version (ground truth):
/** 
 * Authentication page.
 * @param iname Name of identity
 * @param secret The secret code
 * @return The JAX-RS response
 */
@GET public Response auth(@QueryParam("String_Node_Str") final Urn iname,@QueryParam("String_Node_Str") final String secret){
  if (iname == null || secret == null) {
    throw new LoginRequiredException(this,"String_Node_Str");
  }
  Identity identity;
  try {
    identity=this.authenticate(secret);
  }
 catch (  IOException ex) {
    Logger.warn(this,"String_Node_Str",secret,ex);
    throw new LoginRequiredException(this,ex);
  }
  Logger.debug(this,"String_Node_Str",iname,secret);
  return new PageBuilder().build(AbstractPage.class).init(this).authenticated(identity).build();
}
Program: 110151
Project: 110151
Buggy source:
@SuppressWarnings("String_Node_Str") protected void loadLocationFile(String filename) throws JsonParseException, JsonMappingException, IOException {
  ObjectMapper mapper=new ObjectMapper();
  Scanner inputScanner=new Scanner(new FileInputStream(filename));
  while (inputScanner.hasNextLine()) {
    String line=inputScanner.nextLine();
    Map<String,Object> locationObj=mapper.readValue(line,Map.class);
    Location location=Location.parseLocationFromJsonObj(locationObj);
    List<String> aliases=(List<String>)locationObj.get("String_Node_Str");
    this.idToLocation.put(location.getId(),location);
    this.locationToId.put(location,location.getId());
    HashSet<String> justAddedAliases=new HashSet<String>();
    for (    String alias : aliases) {
      if (justAddedAliases.contains(alias))       continue;
      if (this.locationNameToLocation.containsKey(alias))       logger.warn("String_Node_Str" + alias);
 else       this.locationNameToLocation.put(alias,location);
      justAddedAliases.add(alias);
      String newEntry=alias.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
      if (justAddedAliases.contains(newEntry))       continue;
      if (!newEntry.equals(alias)) {
        if (this.locationNameToLocation.containsKey(newEntry))         logger.warn("String_Node_Str" + newEntry);
 else         this.locationNameToLocation.put(newEntry,location);
      }
      justAddedAliases.add(newEntry);
    }
  }
  inputScanner.close();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") protected void loadLocationFile(String filename) throws JsonParseException, JsonMappingException, IOException {
  ObjectMapper mapper=new ObjectMapper();
  Scanner inputScanner=new Scanner(new FileInputStream(filename));
  while (inputScanner.hasNextLine()) {
    String line=inputScanner.nextLine();
    Map<String,Object> locationObj=mapper.readValue(line,Map.class);
    Location location=Location.parseLocationFromJsonObj(locationObj);
    List<String> aliases=(List<String>)locationObj.get("String_Node_Str");
    this.idToLocation.put(location.getId(),location);
    this.locationToId.put(location,location.getId());
    HashSet<String> justAddedAliases=new HashSet<String>();
    if (aliases != null) {
      for (      String alias : aliases) {
        if (justAddedAliases.contains(alias))         continue;
        if (this.locationNameToLocation.containsKey(alias))         logger.warn("String_Node_Str" + alias);
 else         this.locationNameToLocation.put(alias,location);
        justAddedAliases.add(alias);
        String newEntry=alias.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
        if (justAddedAliases.contains(newEntry))         continue;
        if (!newEntry.equals(alias)) {
          if (this.locationNameToLocation.containsKey(newEntry))           logger.warn("String_Node_Str" + newEntry);
 else           this.locationNameToLocation.put(newEntry,location);
        }
        justAddedAliases.add(newEntry);
      }
    }
  }
  inputScanner.close();
}
Program: 110153
Project: 110153
Buggy source:
public Location resolveLocationFromTweet(Map<String,Object> tweet){
  Location location=null;
  Location provisionalLocation=null;
  if (this.usePlace) {
    location=resolveLocationUsingPlace(tweet);
    if (location != null) {
      location.setResolutionMethod(ResolutionMethod.PLACE);
      if (!location.isKnownLocation()) {
        if (this.useUnknownPlaces)         registerNewLocation(location);
 else         if (this.useKnownParentForUnknownPlaces) {
          Location parent=this.createParentOfLocation(location,false);
          while (parent != null && !parent.isKnownLocation()) {
            parent=this.createParentOfLocation(parent,false);
          }
          if (parent != null && parent.isKnownLocation())           provisionalLocation=parent;
        }
 else         location=null;
      }
    }
  }
  if (location == null && this.useGeocodes) {
    location=resolveLocationUsingGeocodes(tweet);
    if (location != null)     location.setResolutionMethod(ResolutionMethod.COORDINATES);
  }
  if (location == null && this.useUserString) {
    location=resolveLocationUsingUserLocation(tweet);
    if (location != null)     location.setResolutionMethod(ResolutionMethod.USER_LOCATION);
  }
  if (location == null && provisionalLocation != null)   location=provisionalLocation;
  return location;
}

Fixed version (ground truth):
public Location resolveLocationFromTweet(Map<String,Object> tweet){
  Location location=null;
  Location provisionalLocation=null;
  if (this.usePlace) {
    location=resolveLocationUsingPlace(tweet);
    if (location != null) {
      location.setResolutionMethod(ResolutionMethod.PLACE);
      if (!location.isKnownLocation()) {
        if (this.useUnknownPlaces)         registerNewLocation(location);
 else         if (this.useKnownParentForUnknownPlaces) {
          Location parent=this.createParentOfLocation(location,false);
          location=null;
          while (parent != null && !parent.isKnownLocation()) {
            parent=this.createParentOfLocation(parent,false);
          }
          if (parent != null && parent.isKnownLocation())           provisionalLocation=parent;
        }
 else         location=null;
      }
    }
  }
  if (location == null && this.useGeocodes) {
    location=resolveLocationUsingGeocodes(tweet);
    if (location != null)     location.setResolutionMethod(ResolutionMethod.COORDINATES);
  }
  if (location == null && this.useUserString) {
    location=resolveLocationUsingUserLocation(tweet);
    if (location != null)     location.setResolutionMethod(ResolutionMethod.USER_LOCATION);
  }
  if (location == null && provisionalLocation != null)   location=provisionalLocation;
  return location;
}
Program: 110154
Project: 110154
Buggy source:
public static Location parseLocationFromJsonObj(Map<String,Object> locationMap){
  String country=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String state=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String county=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String city=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  int id=Integer.parseInt((String)locationMap.get("String_Node_Str"));
  double latitude=Double.parseDouble((String)locationMap.get("String_Node_Str"));
  double longitude=Double.parseDouble((String)locationMap.get("String_Node_Str"));
  int parentId=Integer.parseInt((String)locationMap.get("String_Node_Str"));
  return new Location(country,state,county,city,latitude,longitude,id,parentId,true);
}

Fixed version (ground truth):
public static Location parseLocationFromJsonObj(Map<String,Object> locationMap){
  String country=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String state=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String county=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  String city=Utils.getNullForEmptyString((String)locationMap.get("String_Node_Str"));
  int id=Integer.parseInt((String)locationMap.get("String_Node_Str"));
  double latitude=0;
  double longitude=0;
  if (locationMap.containsKey("String_Node_Str"))   latitude=Double.parseDouble((String)locationMap.get("String_Node_Str"));
  if (locationMap.containsKey("String_Node_Str"))   longitude=Double.parseDouble((String)locationMap.get("String_Node_Str"));
  int parentId=Integer.parseInt((String)locationMap.get("String_Node_Str"));
  return new Location(country,state,county,city,latitude,longitude,id,parentId,true);
}
Program: 110155
Project: 110155
Buggy source:
/** 
 * Does this location object contain the provided location?
 * @param location
 * @return
 * @throws ClassNotFoundException 
 * @throws IOException 
 */
public boolean containsLocation(Location location) throws IOException, ClassNotFoundException {
  while (location != null) {
    if (this.equals(location))     return true;
    location=LocationResolver.getLocationResolver().getParent(location);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Does this location object contain the provided location?
 * @param location
 * @return
 * @throws ClassNotFoundException 
 * @throws IOException 
 */
public boolean containsLocation(Location location) throws IOException, ClassNotFoundException {
  while (location != null && !location.isNone()) {
    if (this.equals(location))     return true;
    location=LocationResolver.getLocationResolver().getParent(location);
  }
  return false;
}
Program: 110157
Project: 110157
Buggy source:
@Override public void onError(Throwable e){
  mIsLoading=false;
  mHasError=true;
  if (mList == null || mList.isEmpty()) {
    mView.contentLoadingError();
  }
}

Fixed version (ground truth):
@Override public void onError(Throwable e){
  mIsLoading=false;
  mHasError=true;
  mCurPage--;
  if (mList == null || mList.isEmpty()) {
    mView.contentLoadingError();
  }
  mView.loadDataComplete(null);
}
Program: 110158
Project: 110158
Buggy source:
@Override public void loadDataNext(){
  ++mCurPage;
  mIsLoading=true;
  mModel.loadData(mParams,mCurPage).subscribe(new Observer<IPageModel<B>>(){
    @Override public void onError(    Throwable e){
      mIsLoading=false;
      mHasError=true;
      if (mList == null || mList.isEmpty()) {
        mView.contentLoadingError();
      }
    }
    @Override public void onComplete(){
      mIsLoading=false;
      mHasError=false;
      if (mList == null || mList.isEmpty()) {
        mView.contentLoadingEmpty();
      }
 else {
        mView.contentLoadingComplete();
      }
      mView.loadDataComplete(mCurrentPageList);
    }
    @Override public void onSubscribe(    @NonNull Disposable d){
      mRxManage.add(d);
    }
    @Override public void onNext(    IPageModel<B> pageModel){
      mPageModel=pageModel;
      if (mCurPage == 1) {
        mList.clear();
      }
      if (pageModel.getDataList() != null && !pageModel.getDataList().isEmpty()) {
        mList.addAll(pageModel.getDataList());
        mCurrentPageList.clear();
        mCurrentPageList.addAll(pageModel.getDataList());
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void loadDataNext(){
  ++mCurPage;
  mIsLoading=true;
  mModel.loadData(mParams,mCurPage).subscribe(new Observer<IPageModel<B>>(){
    @Override public void onError(    Throwable e){
      mIsLoading=false;
      mHasError=true;
      mCurPage--;
      if (mList == null || mList.isEmpty()) {
        mView.contentLoadingError();
      }
      mView.loadDataComplete(null);
    }
    @Override public void onComplete(){
      mIsLoading=false;
      mHasError=false;
      if (mList == null || mList.isEmpty()) {
        mView.contentLoadingEmpty();
      }
 else {
        mView.contentLoadingComplete();
      }
      mView.loadDataComplete(mCurrentPageList);
    }
    @Override public void onSubscribe(    @NonNull Disposable d){
      mRxManage.add(d);
    }
    @Override public void onNext(    IPageModel<B> pageModel){
      mPageModel=pageModel;
      if (mCurPage == 1) {
        mList.clear();
      }
      if (pageModel.getDataList() != null && !pageModel.getDataList().isEmpty()) {
        mList.addAll(pageModel.getDataList());
        mCurrentPageList.clear();
        mCurrentPageList.addAll(pageModel.getDataList());
      }
    }
  }
);
}
Program: 110160
Project: 110160
Buggy source:
public JsonNode handleResult(String result) throws AradException {
  try {
    JsonNode node=JsonUtil.json2node(result);
    JsonNode error=node.findValue(errorKey);
    if (error == null || errorCodes.contains(error.asText())) {
      return node;
    }
 else {
      String statue=error.asText();
      AradException e=new AradException();
      e.setError_code(statue);
      throw e;
    }
  }
 catch (  JsonProcessingException e1) {
    e1.printStackTrace();
    AradException exception=new AradException(e1.getMessage());
    throw exception;
  }
catch (  IOException e1) {
    e1.printStackTrace();
    AradException exception=new AradException(e1.getMessage());
    throw exception;
  }
}

Fixed version (ground truth):
public JsonNode handleResult(String result) throws AradException {
  try {
    JsonNode node=JsonUtil.json2node(result);
    JsonNode error=node.get(errorKey);
    if (error == null || errorCodes.contains(error.asText())) {
      return node;
    }
 else {
      String statue=error.asText();
      AradException e=new AradException();
      e.setError_code(statue);
      throw e;
    }
  }
 catch (  JsonProcessingException e1) {
    e1.printStackTrace();
    AradException exception=new AradException(e1.getMessage());
    throw exception;
  }
catch (  IOException e1) {
    e1.printStackTrace();
    AradException exception=new AradException(e1.getMessage());
    throw exception;
  }
}
Program: 110161
Project: 110161
Buggy source:
private ImageLoader(Context ctx,String cacheFolder){
  finalBitmap=FinalBitmap.create(ctx,BitmapCommonUtils.getDiskCacheDir(ctx,cacheFolder).getAbsolutePath());
}

Fixed version (ground truth):
private ImageLoader(Context ctx,String cacheFolder){
  finalBitmap=FinalBitmap.create(ctx,BitmapCommonUtils.getDiskCacheDir(ctx,cacheFolder).getAbsolutePath());
  finalBitmap.configCompressFormat(CompressFormat.PNG);
}
Program: 110162
Project: 110162
Buggy source:
@Override public void display(String url,ImageView imageView,int loadingImage){
  finalBitmap.configLoadingImage(loadingImage);
  finalBitmap.display(imageView,url);
}

Fixed version (ground truth):
@Override public void display(String url,ImageView imageView,int loadingImage){
  finalBitmap.configLoadingImage(loadingImage);
  finalBitmap.configLoadfailImage(loadingImage);
  finalBitmap.display(imageView,url);
}
Program: 110163
Project: 110163
Buggy source:
private ImageLoader(Context ctx){
  finalBitmap=FinalBitmap.create(ctx);
}

Fixed version (ground truth):
private ImageLoader(Context ctx){
  finalBitmap=FinalBitmap.create(ctx,BitmapCommonUtils.getDiskCacheDir(ctx,"String_Node_Str").getAbsolutePath());
}
Program: 110164
Project: 110164
Buggy source:
@Override public <T>int countByWhere(Class<T> clazz,String strWhere){
  TableInfo table=TableInfo.get(clazz);
  DbModel model=db.findDbModelBySQL(clazz,"String_Node_Str" + table.getTableName() + "String_Node_Str"+ strWhere);
  if (model != null) {
    return model.getInt("String_Node_Str");
  }
  return 0;
}

Fixed version (ground truth):
@Override public <T>int countByWhere(Class<T> clazz,String strWhere){
  TableInfo table=TableInfo.get(clazz);
  DbModel model=db.findDbModelBySQL("String_Node_Str" + table.getTableName() + "String_Node_Str"+ strWhere);
  if (model != null) {
    return model.getInt("String_Node_Str");
  }
  return 0;
}
Program: 110165
Project: 110165
Buggy source:
private ImageLoader(Context ctx,String cacheFolder){
  finalBitmap=FinalBitmap.create(ctx,BitmapCommonUtils.getDiskCacheDir(ctx,cacheFolder).getAbsolutePath());
  finalBitmap.configCompressFormat(CompressFormat.PNG);
}

Fixed version (ground truth):
private ImageLoader(Context ctx,String cacheFolder){
  finalBitmap=FinalBitmap.create(ctx);
}
Program: 110167
Project: 110167
Buggy source:
/** 
 * Initializes the wrapper for loading a chunk.
 * @param chunkUid The chunk's uid.
 * @param shouldSpliceIn Whether the samples parsed from the chunk should be spliced into anysamples already queued to the wrapper.
 * @param reusingExtractor Whether the extractor for the chunk has already been used for precedingchunks.
 */
public void init(int chunkUid,boolean shouldSpliceIn,boolean reusingExtractor){
  if (!reusingExtractor) {
    audioSampleQueueMappingDone=false;
    videoSampleQueueMappingDone=false;
  }
  for (  SampleQueue sampleQueue : sampleQueues) {
    sampleQueue.sourceId(chunkUid);
  }
  if (shouldSpliceIn) {
    for (    SampleQueue sampleQueue : sampleQueues) {
      sampleQueue.splice();
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes the wrapper for loading a chunk.
 * @param chunkUid The chunk's uid.
 * @param shouldSpliceIn Whether the samples parsed from the chunk should be spliced into anysamples already queued to the wrapper.
 * @param reusingExtractor Whether the extractor for the chunk has already been used for precedingchunks.
 */
public void init(int chunkUid,boolean shouldSpliceIn,boolean reusingExtractor){
  if (!reusingExtractor) {
    audioSampleQueueMappingDone=false;
    videoSampleQueueMappingDone=false;
  }
  this.chunkUid=chunkUid;
  for (  SampleQueue sampleQueue : sampleQueues) {
    sampleQueue.sourceId(chunkUid);
  }
  if (shouldSpliceIn) {
    for (    SampleQueue sampleQueue : sampleQueues) {
      sampleQueue.splice();
    }
  }
}
Program: 110168
Project: 110168
Buggy source:
/** 
 * Dequeues the playing period holder from the front of the queue and advances the playing period holder to be the next item in the queue. If the playing period holder is unset, set it to the item in the front of the queue.
 * @return The updated playing period holder, or null if the queue is or becomes empty.
 */
public MediaPeriodHolder advancePlayingPeriod(){
  if (playing != null) {
    if (playing == reading) {
      reading=playing.next;
    }
    playing.release();
    playing=playing.next;
    length--;
    if (length == 0) {
      loading=null;
    }
  }
 else {
    playing=loading;
    reading=loading;
  }
  return playing;
}

Fixed version (ground truth):
/** 
 * Dequeues the playing period holder from the front of the queue and advances the playing period holder to be the next item in the queue. If the playing period holder is unset, set it to the item in the front of the queue.
 * @return The updated playing period holder, or null if the queue is or becomes empty.
 */
public MediaPeriodHolder advancePlayingPeriod(){
  if (playing != null) {
    if (playing == reading) {
      reading=playing.next;
    }
    playing.release();
    length--;
    if (length == 0) {
      loading=null;
      oldFrontPeriodUid=playing.uid;
      oldFrontPeriodWindowSequenceNumber=playing.info.id.windowSequenceNumber;
    }
    playing=playing.next;
  }
 else {
    playing=loading;
    reading=loading;
  }
  return playing;
}
Program: 110169
Project: 110169
Buggy source:
/** 
 * @deprecated Use {@link ConcatenatingMediaSource#ConcatenatingMediaSource(boolean,ShuffleOrder)} instead.
 */
@Deprecated public DynamicConcatenatingMediaSource(boolean isAtomic,ShuffleOrder shuffleOrder){
  super(isAtomic,shuffleOrder);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ConcatenatingMediaSource#ConcatenatingMediaSource(boolean,ShuffleOrder,MediaSource)} instead.
 */
@Deprecated public DynamicConcatenatingMediaSource(boolean isAtomic,ShuffleOrder shuffleOrder){
  super(isAtomic,shuffleOrder);
}
Program: 110170
Project: 110170
Buggy source:
private void updatePlayingPeriodRenderers(@Nullable MediaPeriodHolder oldPlayingPeriodHolder) throws ExoPlaybackException {
  MediaPeriodHolder newPlayingPeriodHolder=queue.getPlayingPeriod();
  if (newPlayingPeriodHolder == null || oldPlayingPeriodHolder == newPlayingPeriodHolder) {
    return;
  }
  int enabledRendererCount=0;
  boolean[] rendererWasEnabledFlags=new boolean[renderers.length];
  for (int i=0; i < renderers.length; i++) {
    Renderer renderer=renderers[i];
    rendererWasEnabledFlags[i]=renderer.getState() != Renderer.STATE_DISABLED;
    if (newPlayingPeriodHolder.trackSelectorResult.isRendererEnabled(i)) {
      enabledRendererCount++;
    }
    if (rendererWasEnabledFlags[i] && (!newPlayingPeriodHolder.trackSelectorResult.isRendererEnabled(i) || (renderer.isCurrentStreamFinal() && renderer.getStream() == oldPlayingPeriodHolder.sampleStreams[i]))) {
      disableRenderer(renderer);
    }
  }
  playbackInfo=playbackInfo.copyWithTrackInfo(newPlayingPeriodHolder.trackGroups,newPlayingPeriodHolder.trackSelectorResult);
  enableRenderers(rendererWasEnabledFlags,enabledRendererCount);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void updatePlayingPeriodRenderers(@Nullable MediaPeriodHolder oldPlayingPeriodHolder) throws ExoPlaybackException {
  MediaPeriodHolder newPlayingPeriodHolder=queue.getPlayingPeriod();
  if (newPlayingPeriodHolder == null || oldPlayingPeriodHolder == newPlayingPeriodHolder) {
    return;
  }
  int enabledRendererCount=0;
  boolean[] rendererWasEnabledFlags=new boolean[renderers.length];
  for (int i=0; i < renderers.length; i++) {
    Renderer renderer=renderers[i];
    rendererWasEnabledFlags[i]=renderer.getState() != Renderer.STATE_DISABLED;
    if (newPlayingPeriodHolder.trackSelectorResult.isRendererEnabled(i)) {
      enabledRendererCount++;
    }
    if (rendererWasEnabledFlags[i] && (!newPlayingPeriodHolder.trackSelectorResult.isRendererEnabled(i) || (renderer.isCurrentStreamFinal() && renderer.getStream() == oldPlayingPeriodHolder.sampleStreams[i]))) {
      disableRenderer(renderer);
    }
  }
  playbackInfo=playbackInfo.copyWithTrackInfo(newPlayingPeriodHolder.trackGroups,newPlayingPeriodHolder.trackSelectorResult);
  enableRenderers(rendererWasEnabledFlags,enabledRendererCount);
}
Program: 110171
Project: 110171
Buggy source:
/** 
 * @param inputBuffers An array of nulls that will be used to store references to input buffers.
 * @param outputBuffers An array of nulls that will be used to store references to output buffers.
 */
protected SimpleDecoder(I[] inputBuffers,O[] outputBuffers){
  lock=new Object();
  queuedInputBuffers=new LinkedList<>();
  queuedOutputBuffers=new LinkedList<>();
  availableInputBuffers=inputBuffers;
  availableInputBufferCount=inputBuffers.length;
  for (int i=0; i < availableInputBufferCount; i++) {
    availableInputBuffers[i]=createInputBuffer();
  }
  availableOutputBuffers=outputBuffers;
  availableOutputBufferCount=outputBuffers.length;
  for (int i=0; i < availableOutputBufferCount; i++) {
    availableOutputBuffers[i]=createOutputBuffer();
  }
  decodeThread=new Thread(){
    @Override public void run(){
      SimpleDecoder.this.run();
    }
  }
;
  decodeThread.start();
}

Fixed version (ground truth):
/** 
 * @param inputBuffers An array of nulls that will be used to store references to input buffers.
 * @param outputBuffers An array of nulls that will be used to store references to output buffers.
 */
protected SimpleDecoder(I[] inputBuffers,O[] outputBuffers){
  lock=new Object();
  queuedInputBuffers=new ArrayDeque<>();
  queuedOutputBuffers=new ArrayDeque<>();
  availableInputBuffers=inputBuffers;
  availableInputBufferCount=inputBuffers.length;
  for (int i=0; i < availableInputBufferCount; i++) {
    availableInputBuffers[i]=createInputBuffer();
  }
  availableOutputBuffers=outputBuffers;
  availableOutputBufferCount=outputBuffers.length;
  for (int i=0; i < availableOutputBufferCount; i++) {
    availableOutputBuffers[i]=createOutputBuffer();
  }
  decodeThread=new Thread(){
    @Override public void run(){
      SimpleDecoder.this.run();
    }
  }
;
  decodeThread.start();
}
Program: 110172
Project: 110172
Buggy source:
@Override public byte[] executeProvisionRequest(UUID uuid,ProvisionRequest request) throws IOException {
  String url=request.getDefaultUrl() + "String_Node_Str" + new String(request.getData());
  return executePost(dataSourceFactory,url,new byte[0],null);
}

Fixed version (ground truth):
@Override public byte[] executeProvisionRequest(UUID uuid,ProvisionRequest request) throws IOException {
  String url=request.getDefaultUrl() + "String_Node_Str" + Util.fromUtf8Bytes(request.getData());
  return executePost(dataSourceFactory,url,new byte[0],null);
}
Program: 110174
Project: 110174
Buggy source:
/** 
 * @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput)
 */
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  long inputLength=input.getLength();
  int bytesToSearch=(int)(inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH ? SEARCH_LENGTH : inputLength);
  input.peekFully(scratch.data,0,4);
  long tag=scratch.readUnsignedInt();
  peekLength=4;
  while (tag != ID_EBML) {
    if (++peekLength == bytesToSearch) {
      return false;
    }
    input.peekFully(scratch.data,0,1);
    tag=(tag << 8) & 0xFFFFFF00;
    tag|=scratch.data[0] & 0xFF;
  }
  long headerSize=readUint(input);
  long headerStart=peekLength;
  if (headerSize == Long.MIN_VALUE || (inputLength != C.LENGTH_UNSET && headerStart + headerSize >= inputLength)) {
    return false;
  }
  while (peekLength < headerStart + headerSize) {
    long id=readUint(input);
    if (id == Long.MIN_VALUE) {
      return false;
    }
    long size=readUint(input);
    if (size < 0 || size > Integer.MAX_VALUE) {
      return false;
    }
    if (size != 0) {
      input.advancePeekPosition((int)size);
      peekLength+=size;
    }
  }
  return peekLength == headerStart + headerSize;
}

Fixed version (ground truth):
/** 
 * @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput)
 */
public boolean sniff(ExtractorInput input) throws IOException, InterruptedException {
  long inputLength=input.getLength();
  int bytesToSearch=(int)(inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH ? SEARCH_LENGTH : inputLength);
  input.peekFully(scratch.data,0,4);
  long tag=scratch.readUnsignedInt();
  peekLength=4;
  while (tag != ID_EBML) {
    if (++peekLength == bytesToSearch) {
      return false;
    }
    input.peekFully(scratch.data,0,1);
    tag=(tag << 8) & 0xFFFFFF00;
    tag|=scratch.data[0] & 0xFF;
  }
  long headerSize=readUint(input);
  long headerStart=peekLength;
  if (headerSize == Long.MIN_VALUE || (inputLength != C.LENGTH_UNSET && headerStart + headerSize >= inputLength)) {
    return false;
  }
  while (peekLength < headerStart + headerSize) {
    long id=readUint(input);
    if (id == Long.MIN_VALUE) {
      return false;
    }
    long size=readUint(input);
    if (size < 0 || size > Integer.MAX_VALUE) {
      return false;
    }
    if (size != 0) {
      int sizeInt=(int)size;
      input.advancePeekPosition(sizeInt);
      peekLength+=sizeInt;
    }
  }
  return peekLength == headerStart + headerSize;
}
Program: 110177
Project: 110177
Buggy source:
/** 
 * Creates a new extractor for unfragmented MP4 streams, using the specified flags to control the extractor's behavior.
 * @param flags Flags that control the extractor's behavior.
 */
public Mp4Extractor(@Flags int flags){
  this.flags=flags;
  atomHeader=new ParsableByteArray(Atom.LONG_HEADER_SIZE);
  containerAtoms=new Stack<>();
  nalStartCode=new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
  nalLength=new ParsableByteArray(4);
  sampleTrackIndex=C.INDEX_UNSET;
}

Fixed version (ground truth):
/** 
 * Creates a new extractor for unfragmented MP4 streams, using the specified flags to control the extractor's behavior.
 * @param flags Flags that control the extractor's behavior.
 */
public Mp4Extractor(@Flags int flags){
  this.flags=flags;
  atomHeader=new ParsableByteArray(Atom.LONG_HEADER_SIZE);
  containerAtoms=new ArrayDeque<>();
  nalStartCode=new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
  nalLength=new ParsableByteArray(4);
  sampleTrackIndex=C.INDEX_UNSET;
}
Program: 110179
Project: 110179
Buggy source:
/** 
 * Builds a PSSH atom for the given system id, containing the given key ids and data.
 * @param systemId The system id of the scheme.
 * @param keyIds The key ids for a version 1 PSSH atom, or null for a version 0 PSSH atom.
 * @param data The scheme specific data.
 * @return The PSSH atom.
 */
public static byte[] buildPsshAtom(UUID systemId,@Nullable UUID[] keyIds,@Nullable byte[] data){
  boolean buildV1Atom=keyIds != null;
  int dataLength=data != null ? data.length : 0;
  int psshBoxLength=Atom.FULL_HEADER_SIZE + 16 + 4+ dataLength;
  if (buildV1Atom) {
    psshBoxLength+=4 + (keyIds.length * 16);
  }
  ByteBuffer psshBox=ByteBuffer.allocate(psshBoxLength);
  psshBox.putInt(psshBoxLength);
  psshBox.putInt(Atom.TYPE_pssh);
  psshBox.putInt(buildV1Atom ? 0x01000000 : 0);
  psshBox.putLong(systemId.getMostSignificantBits());
  psshBox.putLong(systemId.getLeastSignificantBits());
  if (buildV1Atom) {
    psshBox.putInt(keyIds.length);
    for (    UUID keyId : keyIds) {
      psshBox.putLong(keyId.getMostSignificantBits());
      psshBox.putLong(keyId.getLeastSignificantBits());
    }
  }
  if (dataLength != 0) {
    psshBox.putInt(data.length);
    psshBox.put(data);
  }
  return psshBox.array();
}

Fixed version (ground truth):
/** 
 * Builds a PSSH atom for the given system id, containing the given key ids and data.
 * @param systemId The system id of the scheme.
 * @param keyIds The key ids for a version 1 PSSH atom, or null for a version 0 PSSH atom.
 * @param data The scheme specific data.
 * @return The PSSH atom.
 */
@SuppressWarnings("String_Node_Str") public static byte[] buildPsshAtom(UUID systemId,@Nullable UUID[] keyIds,@Nullable byte[] data){
  boolean buildV1Atom=keyIds != null;
  int dataLength=data != null ? data.length : 0;
  int psshBoxLength=Atom.FULL_HEADER_SIZE + 16 + 4+ dataLength;
  if (buildV1Atom) {
    psshBoxLength+=4 + (keyIds.length * 16);
  }
  ByteBuffer psshBox=ByteBuffer.allocate(psshBoxLength);
  psshBox.putInt(psshBoxLength);
  psshBox.putInt(Atom.TYPE_pssh);
  psshBox.putInt(buildV1Atom ? 0x01000000 : 0);
  psshBox.putLong(systemId.getMostSignificantBits());
  psshBox.putLong(systemId.getLeastSignificantBits());
  if (buildV1Atom) {
    psshBox.putInt(keyIds.length);
    for (    UUID keyId : keyIds) {
      psshBox.putLong(keyId.getMostSignificantBits());
      psshBox.putLong(keyId.getLeastSignificantBits());
    }
  }
  if (dataLength != 0) {
    psshBox.putInt(data.length);
    psshBox.put(data);
  }
  return psshBox.array();
}
Program: 110180
Project: 110180
Buggy source:
/** 
 * Returns the duration of the given audio packet.
 * @param packet Contains audio data.
 * @return Returns the duration of the given audio packet.
 */
private long getPacketDurationUs(byte[] packet){
  int toc=packet[0] & 0xFF;
  int frames;
switch (toc & 0x3) {
case 0:
    frames=1;
  break;
case 1:
case 2:
frames=2;
break;
default :
frames=packet[1] & 0x3F;
break;
}
int config=toc >> 3;
int length=config & 0x3;
if (config >= 16) {
length=2500 << length;
}
 else if (config >= 12) {
length=10000 << (length & 0x1);
}
 else if (length == 3) {
length=60000;
}
 else {
length=10000 << length;
}
return frames * length;
}

Fixed version (ground truth):
/** 
 * Returns the duration of the given audio packet.
 * @param packet Contains audio data.
 * @return Returns the duration of the given audio packet.
 */
private long getPacketDurationUs(byte[] packet){
  int toc=packet[0] & 0xFF;
  int frames;
switch (toc & 0x3) {
case 0:
    frames=1;
  break;
case 1:
case 2:
frames=2;
break;
default :
frames=packet[1] & 0x3F;
break;
}
int config=toc >> 3;
int length=config & 0x3;
if (config >= 16) {
length=2500 << length;
}
 else if (config >= 12) {
length=10000 << (length & 0x1);
}
 else if (length == 3) {
length=60000;
}
 else {
length=10000 << length;
}
return (long)frames * length;
}