nus-yam/ex-repair huggingface dataset:
Program: 20379
Project: 20379
Buggy source:
/** 
 * Remove the specified app from the device (uninstall)
 * @param bundleId the bunble identifier (or app id) of the app to remove
 */
public void removeApp(String bundleId);

Fixed version (ground truth):
/** 
 * Remove the specified app from the device (uninstall)
 * @param bundleId the bunble identifier (or app id) of the app to remove
 */
void removeApp(String bundleId);
Program: 20380
Project: 20380
Buggy source:
/** 
 * Runs the current app as a background app for the number of seconds requested. This is a synchronous method, it returns after the back has been returned to the foreground.
 * @param seconds Number of seconds to run App in background
 */
public void runAppInBackground(int seconds);

Fixed version (ground truth):
/** 
 * Runs the current app as a background app for the number of seconds requested. This is a synchronous method, it returns after the back has been returned to the foreground.
 * @param seconds Number of seconds to run App in background
 */
void runAppInBackground(int seconds);
Program: 20381
Project: 20381
Buggy source:
/** 
 * Checks if an app is installed on the device
 * @param bundleId bundleId of the app
 * @return True if app is installed, false otherwise
 */
public boolean isAppInstalled(String bundleId);

Fixed version (ground truth):
/** 
 * Checks if an app is installed on the device
 * @param bundleId bundleId of the app
 * @return True if app is installed, false otherwise
 */
boolean isAppInstalled(String bundleId);
Program: 20382
Project: 20382
Buggy source:
/** 
 * Close the app which was provided in the capabilities at session creation
 */
public void closeApp();

Fixed version (ground truth):
/** 
 * Close the app which was provided in the capabilities at session creation
 */
void closeApp();
Program: 20383
Project: 20383
Buggy source:
/** 
 * Launch the app which was provided in the capabilities at session creation
 */
public void launchApp();

Fixed version (ground truth):
/** 
 * Launch the app which was provided in the capabilities at session creation
 */
void launchApp();
Program: 20384
Project: 20384
Buggy source:
/** 
 * Install an app on the mobile device
 * @param appPath path to app to install
 */
public void installApp(String appPath);

Fixed version (ground truth):
/** 
 * Install an app on the mobile device
 * @param appPath path to app to install
 */
void installApp(String appPath);
Program: 20385
Project: 20385
Buggy source:
/** 
 * Reset the currently running app for this session
 */
public void resetApp();

Fixed version (ground truth):
/** 
 * Reset the currently running app for this session
 */
void resetApp();
Program: 20386
Project: 20386
Buggy source:
/** 
 * Pull a folder from the simulator/device. Does not work on iOS Real Devices, but works on simulators
 * @param remotePath On Android and iOS, this is either the path to the file (relative to the root of the app's file system). On iOS only, if path starts with /AppName.app, which will be replaced with the application's .app directory
 * @return A byte array of Base64 encoded data, representing a ZIP ARCHIVEof the contents of the requested folder.
 */
public byte[] pullFolder(String remotePath);

Fixed version (ground truth):
/** 
 * Pull a folder from the simulator/device. Does not work on iOS Real Devices, but works on simulators
 * @param remotePath On Android and iOS, this is either the path to the file (relative to the root of the app's file system). On iOS only, if path starts with /AppName.app, which will be replaced with the application's .app directory
 * @return A byte array of Base64 encoded data, representing a ZIP ARCHIVEof the contents of the requested folder.
 */
byte[] pullFolder(String remotePath);
Program: 20387
Project: 20387
Buggy source:
/** 
 * @param remotePath On Android and iOS, this is either the path to the file (relative to the root of the app's file system). On iOS only, if path starts with /AppName.app, which will be replaced with the application's .app directory
 * @return A byte array of Base64 encoded data.
 */
public byte[] pullFile(String remotePath);

Fixed version (ground truth):
/** 
 * @param remotePath On Android and iOS, this is either the path to the file (relative to the root of the app's file system). On iOS only, if path starts with /AppName.app, which will be replaced with the application's .app directory
 * @return A byte array of Base64 encoded data.
 */
byte[] pullFile(String remotePath);
Program: 20388
Project: 20388
Buggy source:
public Response execute(String driverCommand,Map<String,?> parameters);

Fixed version (ground truth):
Response execute(String driverCommand,Map<String,?> parameters);
Program: 20389
Project: 20389
Buggy source:
@Override protected File findDefaultExecutable(){
  Process p;
  try {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      p=getSearchingProcess(ArrayUtils.add(CMD_EXE,NODE));
    }
 else {
      p=getSearchingProcess(ArrayUtils.add(BIN_BASH,NODE));
    }
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
  try {
    OutputStream outputStream=p.getOutputStream();
    PrintStream out=new PrintStream(outputStream);
    out.println("String_Node_Str");
    out.close();
    return new File(getTheLastStringFromsOutput(p.getInputStream()));
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
 finally {
    p.destroy();
  }
}

Fixed version (ground truth):
@Override protected File findDefaultExecutable(){
  Process p;
  try {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      p=getSearchingProcess(ArrayUtils.add(CMD_EXE,NODE));
    }
 else {
      p=getSearchingProcess(BIN_BASH,"String_Node_Str","String_Node_Str",NODE);
    }
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
  try {
    OutputStream outputStream=p.getOutputStream();
    PrintStream out=new PrintStream(outputStream);
    out.println("String_Node_Str");
    out.close();
    return new File(getTheLastStringFromsOutput(p.getInputStream()));
  }
 catch (  Throwable t) {
    throw new RuntimeException(t);
  }
 finally {
    p.destroy();
  }
}
Program: 20390
Project: 20390
Buggy source:
private File findNodeInCurrentFileSystem(){
  setUpNPMScript();
  String instancePath;
  Process p=null;
  try {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      p=getSearchingProcess(ArrayUtils.add(CMD_EXE,npmScript.getAbsolutePath()));
    }
 else {
      p=getSearchingProcess(ArrayUtils.add(BIN_BASH,npmScript.getAbsolutePath()));
    }
    p.waitFor();
    instancePath=getTheLastStringFromsOutput(p.getInputStream());
  }
 catch (  Throwable e) {
    throw new RuntimeException(e);
  }
 finally {
    if (p != null)     p.destroy();
  }
  File result;
  if (StringUtils.isBlank(instancePath) || !(result=new File(instancePath + File.separator + APPIUM_NODE_MASK)).exists()) {
    throw new InvalidServerInstanceException("String_Node_Str" + "String_Node_Str" + "String_Node_Str",new IOException("String_Node_Str"));
  }
  return result;
}

Fixed version (ground truth):
private File findNodeInCurrentFileSystem(){
  setUpNPMScript();
  String instancePath;
  Process p=null;
  try {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      p=getSearchingProcess(ArrayUtils.add(CMD_EXE,npmScript.getAbsolutePath()));
      p.waitFor();
    }
 else {
      p=getSearchingProcess(BIN_SH,npmScript.getAbsolutePath());
    }
    instancePath=getTheLastStringFromsOutput(p.getInputStream());
  }
 catch (  Throwable e) {
    throw new RuntimeException(e);
  }
 finally {
    if (p != null)     p.destroy();
  }
  File result;
  if (StringUtils.isBlank(instancePath) || !(result=new File(instancePath + File.separator + APPIUM_NODE_MASK)).exists()) {
    throw new InvalidServerInstanceException("String_Node_Str" + "String_Node_Str" + "String_Node_Str",new IOException("String_Node_Str"));
  }
  return result;
}
Program: 20391
Project: 20391
Buggy source:
private static Process getSearchingProcess(String... command) throws Throwable {
  ProcessBuilder processBuilder=new ProcessBuilder(command);
  if (!StringUtils.isBlank(PATH_NAME)) {
    String path=System.getenv().get(PATH_NAME);
    processBuilder.environment().put(PATH_NAME,path);
  }
  return processBuilder.start();
}

Fixed version (ground truth):
private static Process getSearchingProcess(String... command) throws Throwable {
  ProcessBuilder processBuilder=new ProcessBuilder(command);
  processBuilder.redirectErrorStream(true);
  if (!StringUtils.isBlank(PATH_NAME)) {
    String path=System.getenv().get(PATH_NAME);
    processBuilder.environment().put(PATH_NAME,path);
  }
  return processBuilder.start();
}
Program: 20392
Project: 20392
Buggy source:
private static String getTheLastStringFromsOutput(InputStream stream) throws IOException {
  BufferedReader reader=new BufferedReader(new InputStreamReader(stream));
  String current;
  String result=null;
  while ((current=reader.readLine()) != null) {
    result=current;
  }
  reader.close();
  return result;
}

Fixed version (ground truth):
private static String getTheLastStringFromsOutput(InputStream stream) throws IOException {
  BufferedReader reader=new BufferedReader(new InputStreamReader(stream,Charset.forName("String_Node_Str")));
  String current;
  String result=null;
  while ((current=reader.readLine()) != null) {
    if (StringUtils.isBlank(current)) {
      continue;
    }
    result=current;
  }
  reader.close();
  return result;
}
Program: 20393
Project: 20393
Buggy source:
/** 
 * Find the element.
 */
public WebElement findElement(){
  if (cachedElement != null && shouldCache) {
    return cachedElement;
  }
  List<WebElement> result=waitFor();
  if (result.size() == 0) {
    String message="String_Node_Str" + by.toString();
    if (waitingFunction.foundStaleElementReferenceException != null)     throw new NoSuchElementException(message,waitingFunction.foundStaleElementReferenceException);
    throw new NoSuchElementException(message);
  }
  if (shouldCache) {
    cachedElement=result.get(0);
  }
  return result.get(0);
}

Fixed version (ground truth):
/** 
 * Find the element.
 */
public WebElement findElement(){
  if (cachedElement != null && shouldCache) {
    return cachedElement;
  }
  List<WebElement> result=waitFor();
  if (result.size() == 0) {
    String message="String_Node_Str" + by.toString();
    if (waitingFunction.foundStaleElementReferenceException != null) {
      throw new NoSuchElementException(message,waitingFunction.foundStaleElementReferenceException);
    }
    throw new NoSuchElementException(message);
  }
  if (shouldCache) {
    cachedElement=result.get(0);
  }
  return result.get(0);
}
Program: 20394
Project: 20394
Buggy source:
public List<WebElement> apply(By by){
  List<WebElement> result=new ArrayList<>();
  Throwable shouldBeThrown=null;
  boolean isRootCauseInvalidSelector;
  boolean isRootCauseStaleElementReferenceException=false;
  foundStaleElementReferenceException=null;
  try {
    result.addAll(searchContext.findElements(by));
  }
 catch (  Throwable e) {
    isRootCauseInvalidSelector=isInvalidSelectorRootCause(e);
    if (!isRootCauseInvalidSelector)     isRootCauseStaleElementReferenceException=isStaleElementReferenceException(e);
    if (isRootCauseStaleElementReferenceException)     foundStaleElementReferenceException=extractReadableException(e);
    if (!isRootCauseInvalidSelector & !isRootCauseStaleElementReferenceException)     shouldBeThrown=extractReadableException(e);
  }
  if (shouldBeThrown != null) {
    if (RuntimeException.class.isAssignableFrom(shouldBeThrown.getClass()))     throw (RuntimeException)shouldBeThrown;
    throw new RuntimeException(shouldBeThrown);
  }
  if (result.size() > 0) {
    return result;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public List<WebElement> apply(By by){
  List<WebElement> result=new ArrayList<>();
  Throwable shouldBeThrown=null;
  boolean isRootCauseInvalidSelector;
  boolean isRootCauseStaleElementReferenceException=false;
  foundStaleElementReferenceException=null;
  try {
    result.addAll(searchContext.findElements(by));
  }
 catch (  Throwable e) {
    isRootCauseInvalidSelector=isInvalidSelectorRootCause(e);
    if (!isRootCauseInvalidSelector) {
      isRootCauseStaleElementReferenceException=isStaleElementReferenceException(e);
    }
    if (isRootCauseStaleElementReferenceException) {
      foundStaleElementReferenceException=extractReadableException(e);
    }
    if (!isRootCauseInvalidSelector & !isRootCauseStaleElementReferenceException) {
      shouldBeThrown=extractReadableException(e);
    }
  }
  if (shouldBeThrown != null) {
    if (RuntimeException.class.isAssignableFrom(shouldBeThrown.getClass())) {
      throw (RuntimeException)shouldBeThrown;
    }
    throw new RuntimeException(shouldBeThrown);
  }
  if (result.size() > 0) {
    return result;
  }
 else {
    return null;
  }
}
Program: 20395
Project: 20395
Buggy source:
@Override public CacheableLocator createLocator(AnnotatedElement annotatedElement){
  TimeOutDuration customDuration;
  if (annotatedElement.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=annotatedElement.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else   customDuration=timeOutDuration;
  builder.setAnnotated(annotatedElement);
  By by=builder.buildBy();
  if (by != null)   return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,originalWebDriver);
  return null;
}

Fixed version (ground truth):
@Override public CacheableLocator createLocator(AnnotatedElement annotatedElement){
  TimeOutDuration customDuration;
  if (annotatedElement.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=annotatedElement.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else {
    customDuration=timeOutDuration;
  }
  builder.setAnnotated(annotatedElement);
  By by=builder.buildBy();
  if (by != null)   return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,originalWebDriver);
  return null;
}
Program: 20396
Project: 20396
Buggy source:
public Object decorate(ClassLoader ignored,Field field){
  Object result=defaultElementFieldDecoracor.decorate(ignored,field);
  if (result != null)   return result;
  return decorateWidget(field);
}

Fixed version (ground truth):
public Object decorate(ClassLoader ignored,Field field){
  Object result=defaultElementFieldDecoracor.decorate(ignored,field);
  if (result != null) {
    return result;
  }
  return decorateWidget(field);
}
Program: 20397
Project: 20397
Buggy source:
private Class<?> getTypeForProxy(){
  Class<? extends SearchContext> driverClass=originalDriver.getClass();
  Iterable<Map.Entry<Class<? extends SearchContext>,Class<? extends WebElement>>> rules=elementRuleMap.entrySet();
  for (  Map.Entry<Class<? extends SearchContext>,Class<? extends WebElement>> e : rules) {
    if (e.getKey().isAssignableFrom(driverClass))     return e.getValue();
  }
  return RemoteWebElement.class;
}

Fixed version (ground truth):
private Class<?> getTypeForProxy(){
  Class<? extends SearchContext> driverClass=originalDriver.getClass();
  Iterable<Map.Entry<Class<? extends SearchContext>,Class<? extends WebElement>>> rules=elementRuleMap.entrySet();
  for (  Map.Entry<Class<? extends SearchContext>,Class<? extends WebElement>> e : rules) {
    if (e.getKey().isAssignableFrom(driverClass)) {
      return e.getValue();
    }
  }
  return RemoteWebElement.class;
}
Program: 20398
Project: 20398
Buggy source:
@SuppressWarnings("String_Node_Str") private Object decorateWidget(Field field){
  Class<?> type=field.getType();
  if (!Widget.class.isAssignableFrom(type) && !List.class.isAssignableFrom(type))   return null;
  Class<? extends Widget> widgetType;
  boolean isAlist=false;
  if (List.class.isAssignableFrom(type)) {
    isAlist=true;
    Type genericType=field.getGenericType();
    if (!(genericType instanceof ParameterizedType)) {
      return null;
    }
    Type listType=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (ParameterizedType.class.isAssignableFrom(listType.getClass()))     listType=((ParameterizedType)listType).getRawType();
    if (!Widget.class.isAssignableFrom((Class)listType))     return null;
    widgetType=Class.class.cast(listType);
  }
 else   widgetType=(Class<? extends Widget>)field.getType();
  CacheableLocator locator=widgetLocatorFactory.createLocator(field);
  Map<ContentType,Constructor<? extends Widget>> map=OverrideWidgetReader.read(widgetType,field,platform,automation);
  if (isAlist)   return getEnhancedProxy(ArrayList.class,new WidgetListInterceptor(locator,originalDriver,map,widgetType,timeOutDuration));
  Constructor<? extends Widget> constructor=WidgetConstructorUtil.findConvenientConstructor(widgetType);
  return getEnhancedProxy(widgetType,new Class[]{constructor.getParameterTypes()[0]},new Object[]{proxyForAnElement(locator)},new WidgetInterceptor(locator,originalDriver,null,map,timeOutDuration));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private Object decorateWidget(Field field){
  Class<?> type=field.getType();
  if (!Widget.class.isAssignableFrom(type) && !List.class.isAssignableFrom(type)) {
    return null;
  }
  Class<? extends Widget> widgetType;
  boolean isAlist=false;
  if (List.class.isAssignableFrom(type)) {
    isAlist=true;
    Type genericType=field.getGenericType();
    if (!(genericType instanceof ParameterizedType)) {
      return null;
    }
    Type listType=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (ParameterizedType.class.isAssignableFrom(listType.getClass())) {
      listType=((ParameterizedType)listType).getRawType();
    }
    if (!Widget.class.isAssignableFrom((Class)listType)) {
      return null;
    }
    widgetType=Class.class.cast(listType);
  }
 else {
    widgetType=(Class<? extends Widget>)field.getType();
  }
  CacheableLocator locator=widgetLocatorFactory.createLocator(field);
  Map<ContentType,Constructor<? extends Widget>> map=OverrideWidgetReader.read(widgetType,field,platform,automation);
  if (isAlist) {
    return getEnhancedProxy(ArrayList.class,new WidgetListInterceptor(locator,originalDriver,map,widgetType,timeOutDuration));
  }
  Constructor<? extends Widget> constructor=WidgetConstructorUtil.findConvenientConstructor(widgetType);
  return getEnhancedProxy(widgetType,new Class[]{constructor.getParameterTypes()[0]},new Object[]{proxyForAnElement(locator)},new WidgetInterceptor(locator,originalDriver,null,map,timeOutDuration));
}
Program: 20399
Project: 20399
Buggy source:
@Override protected By buildDefaultBy(){
  AnnotatedElement annotatedElement=annotatedElementContainer.getAnnotated();
  By defaultBy=null;
  FindBy findBy=annotatedElement.getAnnotation(FindBy.class);
  if (findBy != null)   defaultBy=super.buildByFromFindBy(findBy);
  if (defaultBy == null) {
    FindBys findBys=annotatedElement.getAnnotation(FindBys.class);
    if (findBys != null)     defaultBy=super.buildByFromFindBys(findBys);
  }
  if (defaultBy == null) {
    FindAll findAll=annotatedElement.getAnnotation(FindAll.class);
    if (findAll != null)     defaultBy=super.buildBysFromFindByOneOf(findAll);
  }
  return defaultBy;
}

Fixed version (ground truth):
@Override protected By buildDefaultBy(){
  AnnotatedElement annotatedElement=annotatedElementContainer.getAnnotated();
  By defaultBy=null;
  FindBy findBy=annotatedElement.getAnnotation(FindBy.class);
  if (findBy != null) {
    defaultBy=super.buildByFromFindBy(findBy);
  }
  if (defaultBy == null) {
    FindBys findBys=annotatedElement.getAnnotation(FindBys.class);
    if (findBys != null) {
      defaultBy=super.buildByFromFindBys(findBys);
    }
  }
  if (defaultBy == null) {
    FindAll findAll=annotatedElement.getAnnotation(FindAll.class);
    if (findAll != null) {
      defaultBy=super.buildBysFromFindByOneOf(findAll);
    }
  }
  return defaultBy;
}
Program: 20400
Project: 20400
Buggy source:
@Override public By buildBy(){
  assertValidAnnotations();
  By defaultBy=buildDefaultBy();
  By mobileNativeBy=buildMobileNativeBy();
  if (defaultBy == null)   defaultBy=new ByIdOrName(((Field)annotatedElementContainer.getAnnotated()).getName());
  if (mobileNativeBy == null)   mobileNativeBy=defaultBy;
  Map<ContentType,By> contentMap=new HashMap<>();
  contentMap.put(ContentType.HTML_OR_DEFAULT,defaultBy);
  contentMap.put(ContentType.NATIVE_MOBILE_SPECIFIC,mobileNativeBy);
  return new ContentMappedBy(contentMap);
}

Fixed version (ground truth):
@Override public By buildBy(){
  assertValidAnnotations();
  By defaultBy=buildDefaultBy();
  By mobileNativeBy=buildMobileNativeBy();
  if (defaultBy == null) {
    defaultBy=new ByIdOrName(((Field)annotatedElementContainer.getAnnotated()).getName());
  }
  if (mobileNativeBy == null) {
    mobileNativeBy=defaultBy;
  }
  Map<ContentType,By> contentMap=new HashMap<>();
  contentMap.put(ContentType.HTML_OR_DEFAULT,defaultBy);
  contentMap.put(ContentType.NATIVE_MOBILE_SPECIFIC,mobileNativeBy);
  return new ContentMappedBy(contentMap);
}
Program: 20402
Project: 20402
Buggy source:
/** 
 * Creates a new mobile element locator. It instantiates   {@link WebElement}using @AndroidFindBy (-s), @iOSFindBy (-s) and @FindBy (-s) annotation sets
 * @param searchContext The context to use when finding the element
 * @param by a By locator strategy
 * @param shouldCache is the flag that signalizes that elements which are found once should be cached
 * @param duration is a POJO which contains timeout parameters
 * @param originalWebDriver
 */
public AppiumElementLocator(SearchContext searchContext,By by,boolean shouldCache,TimeOutDuration duration,WebDriver originalWebDriver){
  this.searchContext=searchContext;
  this.shouldCache=shouldCache;
  this.timeOutDuration=duration;
  this.by=by;
  this.originalWebDriver=originalWebDriver;
}

Fixed version (ground truth):
/** 
 * Creates a new mobile element locator. It instantiates   {@link WebElement}using @AndroidFindBy (-s), @iOSFindBy (-s) and @FindBy (-s) annotation sets
 * @param searchContext The context to use when finding the element
 * @param by a By locator strategy
 * @param shouldCache is the flag that signalizes that elements which are found once should be cached
 * @param duration is a POJO which contains timeout parameters
 * @param originalWebDriver
 */
public AppiumElementLocator(SearchContext searchContext,By by,boolean shouldCache,TimeOutDuration duration,WebDriver originalWebDriver){
  this.searchContext=searchContext;
  this.shouldCache=shouldCache;
  this.timeOutDuration=duration;
  this.by=by;
  this.originalWebDriver=originalWebDriver;
  waitingFunction=new WaitingFunction(this.searchContext);
}
Program: 20403
Project: 20403
Buggy source:
/** 
 * Find the element.
 */
public WebElement findElement(){
  if (cachedElement != null && shouldCache) {
    return cachedElement;
  }
  List<WebElement> result=waitFor();
  if (result.size() == 0) {
    String message="String_Node_Str" + by.toString();
    throw new NoSuchElementException(message);
  }
  if (shouldCache) {
    cachedElement=result.get(0);
  }
  return result.get(0);
}

Fixed version (ground truth):
/** 
 * Find the element.
 */
public WebElement findElement(){
  if (cachedElement != null && shouldCache) {
    return cachedElement;
  }
  List<WebElement> result=waitFor();
  if (result.size() == 0) {
    String message="String_Node_Str" + by.toString();
    if (waitingFunction.foundStaleElementReferenceException != null)     throw new NoSuchElementException(message,waitingFunction.foundStaleElementReferenceException);
    throw new NoSuchElementException(message);
  }
  if (shouldCache) {
    cachedElement=result.get(0);
  }
  return result.get(0);
}
Program: 20404
Project: 20404
Buggy source:
public List<WebElement> apply(By by){
  List<WebElement> result=new ArrayList<WebElement>();
  try {
    result.addAll(searchContext.findElements(by));
  }
 catch (  StaleElementReferenceException ignored) {
  }
catch (  RuntimeException e) {
    if (!isInvalidSelectorRootCause(e))     throw e;
  }
  if (result.size() > 0) {
    return result;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public List<WebElement> apply(By by){
  List<WebElement> result=new ArrayList<>();
  Throwable shouldBeThrown=null;
  boolean isRootCauseInvalidSelector;
  boolean isRootCauseStaleElementReferenceException=false;
  foundStaleElementReferenceException=null;
  try {
    result.addAll(searchContext.findElements(by));
  }
 catch (  Throwable e) {
    isRootCauseInvalidSelector=isInvalidSelectorRootCause(e);
    if (!isRootCauseInvalidSelector)     isRootCauseStaleElementReferenceException=isStaleElementReferenceException(e);
    if (isRootCauseStaleElementReferenceException)     foundStaleElementReferenceException=extractReadableException(e);
    if (!isRootCauseInvalidSelector & !isRootCauseStaleElementReferenceException)     shouldBeThrown=extractReadableException(e);
  }
  if (shouldBeThrown != null) {
    if (RuntimeException.class.isAssignableFrom(shouldBeThrown.getClass()))     throw (RuntimeException)shouldBeThrown;
    throw new RuntimeException(shouldBeThrown);
  }
  if (result.size() > 0) {
    return result;
  }
 else {
    return null;
  }
}
Program: 20405
Project: 20405
Buggy source:
private List<WebElement> waitFor(){
  try {
    changeImplicitlyWaitTimeOut(0,TimeUnit.SECONDS);
    FluentWait<By> wait=new FluentWait<By>(by);
    wait.withTimeout(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
    return wait.until(new WaitingFunction(searchContext));
  }
 catch (  TimeoutException e) {
    return new ArrayList<WebElement>();
  }
 finally {
    changeImplicitlyWaitTimeOut(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
  }
}

Fixed version (ground truth):
private List<WebElement> waitFor(){
  try {
    changeImplicitlyWaitTimeOut(0,TimeUnit.SECONDS);
    FluentWait<By> wait=new FluentWait<>(by);
    wait.withTimeout(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
    return wait.until(waitingFunction);
  }
 catch (  TimeoutException e) {
    return new ArrayList<>();
  }
 finally {
    changeImplicitlyWaitTimeOut(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
  }
}
Program: 20406
Project: 20406
Buggy source:
public ElementLocator createLocator(Field field){
  TimeOutDuration customDuration;
  if (field.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=field.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else   customDuration=timeOutDuration;
  builder.setAnnotated(field);
  By by=builder.buildBy();
  if (by != null)   return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,originalWebDriver);
  return null;
}

Fixed version (ground truth):
@Override public CacheableLocator createLocator(AnnotatedElement annotatedElement){
  TimeOutDuration customDuration;
  if (annotatedElement.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=annotatedElement.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else   customDuration=timeOutDuration;
  builder.setAnnotated(annotatedElement);
  By by=builder.buildBy();
  if (by != null)   return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,originalWebDriver);
  return null;
}
Program: 20407
Project: 20407
Buggy source:
@SuppressWarnings("String_Node_Str") private Object decorateWidget(Field field){
  Class<?> type=field.getType();
  if (!Widget.class.isAssignableFrom(type) && !List.class.isAssignableFrom(type))   return null;
  Class<? extends Widget> widgetType;
  boolean isAlist=false;
  if (List.class.isAssignableFrom(type)) {
    isAlist=true;
    Type genericType=field.getGenericType();
    if (!(genericType instanceof ParameterizedType)) {
      return null;
    }
    Type listType=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (ParameterizedType.class.isAssignableFrom(listType.getClass()))     listType=((ParameterizedType)listType).getRawType();
    if (!Widget.class.isAssignableFrom((Class)listType))     return null;
    widgetType=Class.class.cast(listType);
  }
 else   widgetType=(Class<? extends Widget>)field.getType();
  ElementLocator locator=widgetLocatorFactory.createLocator(field);
  Map<ContentType,Constructor<? extends Widget>> map=OverrideWidgetReader.read(widgetType,field,platform,automation);
  if (isAlist)   return getEnhancedProxy(ArrayList.class,new WidgetListInterceptor(locator,originalDriver,map,widgetType,timeOutDuration));
  Constructor<? extends Widget> constructor=WidgetConstructorUtil.findConvenientConstructor(widgetType);
  return getEnhancedProxy(widgetType,new Class[]{constructor.getParameterTypes()[0]},new Object[]{proxyForAnElement(locator)},new WidgetInterceptor(locator,originalDriver,null,map,timeOutDuration));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private Object decorateWidget(Field field){
  Class<?> type=field.getType();
  if (!Widget.class.isAssignableFrom(type) && !List.class.isAssignableFrom(type))   return null;
  Class<? extends Widget> widgetType;
  boolean isAlist=false;
  if (List.class.isAssignableFrom(type)) {
    isAlist=true;
    Type genericType=field.getGenericType();
    if (!(genericType instanceof ParameterizedType)) {
      return null;
    }
    Type listType=((ParameterizedType)genericType).getActualTypeArguments()[0];
    if (ParameterizedType.class.isAssignableFrom(listType.getClass()))     listType=((ParameterizedType)listType).getRawType();
    if (!Widget.class.isAssignableFrom((Class)listType))     return null;
    widgetType=Class.class.cast(listType);
  }
 else   widgetType=(Class<? extends Widget>)field.getType();
  CacheableLocator locator=widgetLocatorFactory.createLocator(field);
  Map<ContentType,Constructor<? extends Widget>> map=OverrideWidgetReader.read(widgetType,field,platform,automation);
  if (isAlist)   return getEnhancedProxy(ArrayList.class,new WidgetListInterceptor(locator,originalDriver,map,widgetType,timeOutDuration));
  Constructor<? extends Widget> constructor=WidgetConstructorUtil.findConvenientConstructor(widgetType);
  return getEnhancedProxy(widgetType,new Class[]{constructor.getParameterTypes()[0]},new Object[]{proxyForAnElement(locator)},new WidgetInterceptor(locator,originalDriver,null,map,timeOutDuration));
}
Program: 20408
Project: 20408
Buggy source:
@Override public WebElement getWrappedElement(){
  return element;
}

Fixed version (ground truth):
@Override public WebElement getWrappedElement(){
  return (WebElement)element;
}
Program: 20409
Project: 20409
Buggy source:
@Override protected Object getObject(WebElement element,Method method,Object[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException {
  ContentType type=getCurrentContentType(element);
  if (cachedElement == null || cachedElement.hashCode() != element.hashCode()) {
    cachedElement=element;
    Widget widget=instantiationMap.get(type).newInstance(cachedElement);
    cachedInstances.put(type,widget);
    PageFactory.initElements(new AppiumFieldDecorator(widget,duration),widget);
  }
  return method.invoke(cachedInstances.get(type),args);
}

Fixed version (ground truth):
@Override protected Object getObject(WebElement element,Method method,Object[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException {
  ContentType type=getCurrentContentType(element);
  if (cachedElement == null || (locator != null && !((CacheableLocator)locator).isLookUpCached()) || cachedInstances.size() == 0) {
    cachedElement=element;
    Widget widget=instantiationMap.get(type).newInstance(cachedElement);
    cachedInstances.put(type,widget);
    PageFactory.initElements(new AppiumFieldDecorator(widget,duration),widget);
  }
  return method.invoke(cachedInstances.get(type),args);
}
Program: 20410
Project: 20410
Buggy source:
WidgetInterceptor(ElementLocator locator,WebDriver driver,WebElement cachedElement,Map<ContentType,Constructor<? extends Widget>> instantiationMap,TimeOutDuration duration){
  super(locator,driver);
  this.cachedElement=cachedElement;
  this.instantiationMap=instantiationMap;
  this.duration=duration;
}

Fixed version (ground truth):
WidgetInterceptor(CacheableLocator locator,WebDriver driver,WebElement cachedElement,Map<ContentType,Constructor<? extends Widget>> instantiationMap,TimeOutDuration duration){
  super(locator,driver);
  this.cachedElement=cachedElement;
  this.instantiationMap=instantiationMap;
  this.duration=duration;
}
Program: 20411
Project: 20411
Buggy source:
@Override protected Object getObject(List<WebElement> elements,Method method,Object[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException {
  if (cachedElements == null || cachedElements.hashCode() != elements.hashCode()) {
    cachedElements=elements;
    cachedWidgets.clear();
    for (    WebElement element : cachedElements) {
      ContentType type=getCurrentContentType(element);
      Class<?>[] params=new Class<?>[]{instantiationMap.get(type).getParameterTypes()[0]};
      cachedWidgets.add(ProxyFactory.getEnhancedProxy(declaredType,params,new Object[]{element},new WidgetInterceptor(null,driver,element,instantiationMap,duration)));
    }
  }
  return method.invoke(cachedWidgets,args);
}

Fixed version (ground truth):
@Override protected Object getObject(List<WebElement> elements,Method method,Object[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException {
  if (cachedElements == null || (locator != null && !((CacheableLocator)locator).isLookUpCached())) {
    cachedElements=elements;
    cachedWidgets.clear();
    for (    WebElement element : cachedElements) {
      ContentType type=getCurrentContentType(element);
      Class<?>[] params=new Class<?>[]{instantiationMap.get(type).getParameterTypes()[0]};
      cachedWidgets.add(ProxyFactory.getEnhancedProxy(declaredType,params,new Object[]{element},new WidgetInterceptor(null,driver,element,instantiationMap,duration)));
    }
  }
  return method.invoke(cachedWidgets,args);
}
Program: 20412
Project: 20412
Buggy source:
WidgetListInterceptor(ElementLocator locator,WebDriver driver,Map<ContentType,Constructor<? extends Widget>> instantiationMap,Class<? extends Widget> declaredType,TimeOutDuration duration){
  super(locator);
  this.instantiationMap=instantiationMap;
  this.declaredType=declaredType;
  this.duration=duration;
  this.driver=driver;
}

Fixed version (ground truth):
WidgetListInterceptor(CacheableLocator locator,WebDriver driver,Map<ContentType,Constructor<? extends Widget>> instantiationMap,Class<? extends Widget> declaredType,TimeOutDuration duration){
  super(locator);
  this.instantiationMap=instantiationMap;
  this.declaredType=declaredType;
  this.duration=duration;
  this.driver=driver;
}
Program: 20414
Project: 20414
Buggy source:
@Test public void elementGestureTest(){
  driver.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
  MobileElement e=driver.findElement(MobileBy.AccessibilityId("String_Node_Str"));
  e.tap(1,1500);
  System.out.println("String_Node_Str");
  MobileElement e2=driver.findElementByClassName("String_Node_Str");
  e2.zoom();
  System.out.println("String_Node_Str");
  e2.swipe(SwipeElementDirection.RIGHT,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.RIGHT,10,20,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.LEFT,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.LEFT,10,20,1000);
  System.out.println("String_Node_Str");
  driver.sendKeyEvent(AndroidKeyCode.BACK);
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.DOWN,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.DOWN,10,20,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.UP,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.UP,10,20,1000);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Test public void elementGestureTest(){
  driver.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
  MobileElement e=driver.findElement(MobileBy.AccessibilityId("String_Node_Str"));
  e.tap(1,1500);
  System.out.println("String_Node_Str");
  MobileElement e2=driver.findElementByClassName("String_Node_Str");
  e2.zoom();
  System.out.println("String_Node_Str");
  e2.swipe(SwipeElementDirection.RIGHT,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.RIGHT,10,20,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.LEFT,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.LEFT,10,20,1000);
  System.out.println("String_Node_Str");
  driver.pressKeyCode(AndroidKeyCode.BACK);
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.DOWN,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.DOWN,10,20,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.UP,1000);
  System.out.println("String_Node_Str");
  e2=driver.findElementByClassName("String_Node_Str");
  e2.swipe(SwipeElementDirection.UP,10,20,1000);
  System.out.println("String_Node_Str");
}
Program: 20415
Project: 20415
Buggy source:
private void assertValidAnnotations(){
  AndroidFindBy androidBy=mobileField.getAnnotation(AndroidFindBy.class);
  AndroidFindBys androidBys=mobileField.getAnnotation(AndroidFindBys.class);
  AndroidFindAll androidFindAll=mobileField.getAnnotation(AndroidFindAll.class);
  SelendroidFindBy selendroidBy=mobileField.getAnnotation(SelendroidFindBy.class);
  SelendroidFindBys selendroidBys=mobileField.getAnnotation(SelendroidFindBys.class);
  SelendroidFindAll selendroidFindAll=mobileField.getAnnotation(SelendroidFindAll.class);
  iOSFindBy iOSBy=mobileField.getAnnotation(iOSFindBy.class);
  iOSFindBys iOSBys=mobileField.getAnnotation(iOSFindBys.class);
  iOSFindAll iOSFindAll=mobileField.getAnnotation(iOSFindAll.class);
  checkDisallowedAnnotationPairs(androidBy,androidBys);
  checkDisallowedAnnotationPairs(androidBy,selendroidBys);
  checkDisallowedAnnotationPairs(androidBy,androidFindAll);
  checkDisallowedAnnotationPairs(androidBy,selendroidFindAll);
  checkDisallowedAnnotationPairs(androidBys,androidFindAll);
  checkDisallowedAnnotationPairs(androidBys,selendroidFindAll);
  checkDisallowedAnnotationPairs(selendroidBy,androidBys);
  checkDisallowedAnnotationPairs(selendroidBy,selendroidBys);
  checkDisallowedAnnotationPairs(selendroidBy,androidFindAll);
  checkDisallowedAnnotationPairs(selendroidBy,selendroidFindAll);
  checkDisallowedAnnotationPairs(selendroidBys,androidFindAll);
  checkDisallowedAnnotationPairs(selendroidBys,selendroidFindAll);
  checkDisallowedAnnotationPairs(iOSBy,iOSBys);
  checkDisallowedAnnotationPairs(iOSBy,iOSFindAll);
  checkDisallowedAnnotationPairs(iOSBys,iOSFindAll);
}

Fixed version (ground truth):
private void assertValidAnnotations(){
  AndroidFindBy androidBy=mobileField.getAnnotation(AndroidFindBy.class);
  AndroidFindBys androidBys=mobileField.getAnnotation(AndroidFindBys.class);
  AndroidFindAll androidFindAll=mobileField.getAnnotation(AndroidFindAll.class);
  SelendroidFindBy selendroidBy=mobileField.getAnnotation(SelendroidFindBy.class);
  SelendroidFindBys selendroidBys=mobileField.getAnnotation(SelendroidFindBys.class);
  SelendroidFindAll selendroidFindAll=mobileField.getAnnotation(SelendroidFindAll.class);
  iOSFindBy iOSBy=mobileField.getAnnotation(iOSFindBy.class);
  iOSFindBys iOSBys=mobileField.getAnnotation(iOSFindBys.class);
  iOSFindAll iOSFindAll=mobileField.getAnnotation(iOSFindAll.class);
  checkDisallowedAnnotationPairs(androidBy,androidBys);
  checkDisallowedAnnotationPairs(androidBy,androidFindAll);
  checkDisallowedAnnotationPairs(androidBys,androidFindAll);
  checkDisallowedAnnotationPairs(selendroidBy,selendroidBys);
  checkDisallowedAnnotationPairs(selendroidBy,selendroidFindAll);
  checkDisallowedAnnotationPairs(selendroidBys,selendroidFindAll);
  checkDisallowedAnnotationPairs(iOSBy,iOSBys);
  checkDisallowedAnnotationPairs(iOSBy,iOSFindAll);
  checkDisallowedAnnotationPairs(iOSBys,iOSFindAll);
}
Program: 20417
Project: 20417
Buggy source:
@Test public void dragNDropTest(){
  driver.findElement(MobileBy.AndroidUIAutomator("String_Node_Str")).click();
  WebElement actionBarTitle=driver.findElement(By.id("String_Node_Str"));
  assertEquals("String_Node_Str","String_Node_Str",actionBarTitle.getText());
  WebElement dragDot1=driver.findElement(By.id("String_Node_Str"));
  WebElement dragDot3=driver.findElement(By.id("String_Node_Str"));
  WebElement dragText=driver.findElement(By.id("String_Node_Str"));
  assertEquals("String_Node_Str","String_Node_Str",dragText.getText());
  TouchAction dragNDrop=new TouchAction(driver).longPress(dragDot1).moveTo(dragDot3).release();
  dragNDrop.perform();
  assertNotEquals("String_Node_Str","String_Node_Str",dragText.getText());
}

Fixed version (ground truth):
@Test public void dragNDropTest(){
  driver.findElementByAndroidUIAutomator("String_Node_Str");
  driver.findElementByAccessibilityId("String_Node_Str").click();
  driver.findElement(MobileBy.AndroidUIAutomator("String_Node_Str")).click();
  WebElement actionBarTitle=driver.findElement(By.id("String_Node_Str"));
  assertEquals("String_Node_Str","String_Node_Str",actionBarTitle.getText());
  WebElement dragDot1=driver.findElement(By.id("String_Node_Str"));
  WebElement dragDot3=driver.findElement(By.id("String_Node_Str"));
  WebElement dragText=driver.findElement(By.id("String_Node_Str"));
  assertEquals("String_Node_Str","String_Node_Str",dragText.getText());
  TouchAction dragNDrop=new TouchAction(driver).longPress(dragDot1).moveTo(dragDot3).release();
  dragNDrop.perform();
  assertNotEquals("String_Node_Str","String_Node_Str",dragText.getText());
}
Program: 20418
Project: 20418
Buggy source:
public boolean equals(Object obj){
  if (obj instanceof Integer) {
    return value == obj;
  }
  if (obj instanceof NetworkConnectionSetting) {
    return value == ((NetworkConnectionSetting)obj).value;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean equals(Object obj){
  if (obj instanceof Integer) {
    return value == (Integer)obj;
  }
  if (obj instanceof NetworkConnectionSetting) {
    return value == ((NetworkConnectionSetting)obj).value;
  }
 else {
    return false;
  }
}
Program: 20419
Project: 20419
Buggy source:
private boolean copyToDestination(File source){
  boolean result=false;
  InputStream is=null;
  OutputStream os=null;
  try {
    File parent=destination.getParentFile();
    if (!parent.mkdirs() && !parent.isDirectory()) {
      throw new IOException("String_Node_Str");
    }
    if (destination.isDirectory()) {
      throw new IOException("String_Node_Str");
    }
    is=new FileInputStream(source);
    os=new FileOutputStream(destination);
    IOUtils.copy(is,os);
    result=true;
  }
 catch (  IOException e) {
    Logger.e(TAG,"String_Node_Str",e);
  }
 finally {
    IOUtils.closeQuietly(is);
    IOUtils.closeQuietly(os);
  }
  return result;
}

Fixed version (ground truth):
private boolean copyToDestination(File source){
  boolean result=false;
  try {
    File parent=destination.getParentFile();
    if (!parent.mkdirs() && !parent.isDirectory()) {
      throw new IOException("String_Node_Str");
    }
    if (destination.isDirectory()) {
      throw new IOException("String_Node_Str");
    }
    IOUtils.copyFile(source,destination);
    result=true;
  }
 catch (  IOException e) {
    Logger.e(TAG,"String_Node_Str",e);
  }
  return result;
}
Program: 20420
Project: 20420
Buggy source:
public ThumbDrawable(){
  width=dp(40);
  height=dp(40);
  paint.setStrokeWidth(dp(2));
  paint.setStyle(Paint.Style.STROKE);
  paint.setStrokeCap(Paint.Cap.ROUND);
  paint.setColor(0xff757575);
  path.reset();
  for (int i=0; i < 3; i++) {
    int top=(int)(getMinimumHeight() / 2f + (i - 1) * dp(6));
    path.moveTo(dp(8),top);
    path.lineTo(getMinimumWidth() - dp(8),top);
  }
  path.moveTo(0f,0f);
  path.close();
}

Fixed version (ground truth):
public ThumbDrawable(){
  width=dp(40);
  height=dp(40);
  paint.setStrokeWidth(dp(2));
  paint.setStyle(Paint.Style.STROKE);
  paint.setStrokeCap(Paint.Cap.BUTT);
  paint.setColor(0xff757575);
  path.reset();
  for (int i=0; i < 3; i++) {
    int top=(int)(getMinimumHeight() / 2f + (i - 1) * dp(6));
    path.moveTo(dp(8),top);
    path.lineTo(getMinimumWidth() - dp(8),top);
  }
  path.close();
}
Program: 20424
Project: 20424
Buggy source:
private void updateLayout(){
  if (!TextUtils.isEmpty(text)) {
    if (update) {
      int layoutWidth=width - getPaddingLeft() - getPaddingRight();
      if (layoutWidth > 0) {
        long cacheKey=text.toString().hashCode();
        cacheKey=31 * cacheKey + paint.getColor();
        cacheKey=31 * cacheKey + Float.floatToIntBits(paint.getTextSize());
        cacheKey=31 * cacheKey + layoutWidth;
        StaticLayout cached=textCache.get(cacheKey);
        if (cached == null) {
          cached=getStaticLayout(layoutWidth);
          textCache.put(cacheKey,cached);
        }
 else {
          Paint cachedPaint=cached.getPaint();
          if (!text.toString().equals(cached.getText().toString()) || cachedPaint.getColor() != paint.getColor() || cachedPaint.getTextSize() != paint.getTextSize() || cached.getWidth() != layoutWidth) {
            Logger.w(TAG,"String_Node_Str",cacheKey,text.toString(),cached.getText().toString());
            cached=getStaticLayout(layoutWidth);
          }
        }
        layout=cached;
      }
 else {
        layout=null;
      }
    }
  }
 else {
    layout=null;
  }
  update=false;
}

Fixed version (ground truth):
private void updateLayout(){
  if (!TextUtils.isEmpty(text)) {
    if (update) {
      int layoutWidth=width - getPaddingLeft() - getPaddingRight();
      if (layoutWidth > 0) {
        FastTextViewItem item=new FastTextViewItem(text,paint,layoutWidth);
        StaticLayout cached=textCache.get(item);
        if (cached == null) {
          cached=getStaticLayout(layoutWidth);
          textCache.put(item,cached);
        }
        layout=cached;
      }
 else {
        layout=null;
      }
    }
  }
 else {
    layout=null;
  }
  update=false;
}
Program: 20426
Project: 20426
Buggy source:
@Override public boolean onMeasured(View view){
  Animator fromAlpha=ObjectAnimator.ofFloat(from.view,View.ALPHA,1f,0.7f);
  fromAlpha.setDuration(217);
  fromAlpha.setInterpolator(new AccelerateDecelerateInterpolator());
  Animator toAlpha=ObjectAnimator.ofFloat(to.view,View.ALPHA,0f,1f);
  toAlpha.setDuration(200);
  toAlpha.setInterpolator(new DecelerateInterpolator(2f));
  Animator toY=ObjectAnimator.ofFloat(to.view,View.TRANSLATION_Y,to.view.getHeight() * 0.08f,0f);
  toY.setDuration(350);
  toY.setInterpolator(new DecelerateInterpolator(2.5f));
  toY.addListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      onCompleted();
    }
  }
);
  AnimatorSet set=new AnimatorSet();
  set.playTogether(toAlpha,toY);
  set.start();
  return false;
}

Fixed version (ground truth):
@Override public boolean onMeasured(View view){
  Animator toAlpha=ObjectAnimator.ofFloat(to.view,View.ALPHA,0f,1f);
  toAlpha.setDuration(200);
  toAlpha.setInterpolator(new DecelerateInterpolator(2f));
  Animator toY=ObjectAnimator.ofFloat(to.view,View.TRANSLATION_Y,to.view.getHeight() * 0.08f,0f);
  toY.setDuration(350);
  toY.setInterpolator(new DecelerateInterpolator(2.5f));
  toY.addListener(new AnimatorListenerAdapter(){
    @Override public void onAnimationEnd(    Animator animation){
      onCompleted();
    }
  }
);
  AnimatorSet set=new AnimatorSet();
  set.playTogether(toAlpha,toY);
  set.start();
  return true;
}