Buggy code:
try { device = getAndroidDevice ( desiredCapabilities ) ; } catch ( AndroidDeviceException e ) { SessionNotCreatedException error = new SessionNotCreatedException ( ( "Error<seq2seq4repair_space>occured<seq2seq4repair_space>while<seq2seq4repair_space>finding<seq2seq4repair_space>android<seq2seq4repair_space>device:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; e . printStackTrace ( ) ; SelendroidStandaloneDriver . log . severe ( error . getMessage ( ) ) ; throw error ; } if ( device instanceof AndroidEmulator ) { AndroidEmulator emulator = ( ( AndroidEmulator ) ( device ) ) ; try { if ( emulator . isEmulatorStarted ( ) ) { emulator . unlockEmulatorScreen ( ) ; } else { Map < String , Object > config = new HashMap < String , Object > ( ) ; if ( ( serverConfiguration . getEmulatorOptions ( ) ) != null ) { config . put ( EMULATOR_OPTIONS , serverConfiguration . getEmulatorOptions ( ) ) ; } config . put ( TIMEOUT_OPTION , serverConfiguration . getTimeoutEmulatorStart ( ) ) ; if ( desiredCapabilities . asMap ( ) . containsKey ( DISPLAY ) ) { Object d = desiredCapabilities . getCapability ( DISPLAY ) ; config . put ( DISPLAY_OPTION , String . valueOf ( d ) ) ; } Locale locale = parseLocale ( desiredCapabilities ) ; emulator . start ( locale , deviceStore . nextEmulatorPort ( ) , config ) ; } } catch ( AndroidDeviceException e ) { deviceStore . release ( device , app ) ; if ( retries > 0 ) { return createNewTestSession ( caps , ( retries - 1 ) ) ; } throw new SessionNotCreatedException ( ( ( ( "Error<seq2seq4repair_space>occured<seq2seq4repair_space>while<seq2seq4repair_space>interacting<seq2seq4repair_space>with<seq2seq4repair_space>the<seq2seq4repair_space>emulator:<seq2seq4repair_space>" + emulator ) + ":<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; } emulator . setIDevice ( deviceManager . getVirtualDevice ( emulator . getAvdName ( ) ) ) ; } boolean appInstalledOnDevice = device . isInstalled ( app ) ; if ( ( ! appInstalledOnDevice ) || ( serverConfiguration . isForceReinstall ( ) ) ) { device . install ( app ) ; } else { SelendroidStandaloneDriver . log . info ( "the<seq2seq4repair_space>app<seq2seq4repair_space>under<seq2seq4repair_space>test<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>installed." ) ; } int port = getNextSelendroidServerPort ( ) ; Boolean selendroidInstalledSuccessfully = device . isInstalled ( ( "io.selendroid." + ( app . getBasePackage ( ) ) ) ) ; if ( ( ! selendroidInstalledSuccessfully ) || ( serverConfiguration . isForceReinstall ( ) ) ) { AndroidApp selendroidServer = createSelendroidServerApk ( app ) ; selendroidInstalledSuccessfully = device . install ( selendroidServer ) ; if ( ! selendroidInstalledSuccessfully ) { if ( ! ( device . install ( selendroidServer ) ) ) { deviceStore . release ( device , app ) ; if ( retries > 0 ) { return createNewTestSession ( caps , ( retries - 1 ) ) ; } } } } else { SelendroidStandaloneDriver . log . info ( "selendroid-server<seq2seq4repair_space>will<seq2seq4repair_space>not<seq2seq4repair_space>be<seq2seq4repair_space>created<seq2seq4repair_space>and<seq2seq4repair_space>installed<seq2seq4repair_space>because<seq2seq4repair_space>it<seq2seq4repair_space>already<seq2seq4repair_space>exists<seq2seq4repair_space>for<seq2seq4repair_space>the<seq2seq4repair_space>app<seq2seq4repair_space>under<seq2seq4repair_space>test." ) ; } List < String > adbCommands = new ArrayList < String > ( ) ; adbCommands . add ( ( "shell<seq2seq4repair_space>setprop<seq2seq4repair_space>log.tag.SELENDROID<seq2seq4repair_space>" + ( serverConfiguration . getLogLevel ( ) . name ( ) ) ) ) ; adbCommands . addAll ( desiredCapabilities . getPreSessionAdbCommands ( ) ) ; for ( String adbCommandParameter : adbCommands ) { device . runAdbCommand ( adbCommandParameter ) ; } try { device . startSelendroid ( app , port ) ; } catch ( AndroidSdkException e ) { SelendroidStandaloneDriver . log . info ( ( "error<seq2seq4repair_space>while<seq2seq4repair_space>starting<seq2seq4repair_space>selendroid:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; deviceStore . release ( device , app ) ; if ( retries > 0 ) { return createNewTestSession ( caps , ( retries - 1 ) ) ; } throw new SessionNotCreatedException ( ( "Error<seq2seq4repair_space>occurred<seq2seq4repair_space>while<seq2seq4repair_space>starting<seq2seq4repair_space>instrumentation:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) ; } long start = System . currentTimeMillis ( ) ; long startTimeOut = 20000 ; long timemoutEnd = start + startTimeOut ; while ( ( device . isSelendroidRunning ( ) ) == false ) { if ( timemoutEnd >= ( System . currentTimeMillis ( ) ) ) { try { Thread . sleep ( 2000 ) ; } catch ( InterruptedException e ) { } } else { <START_BUG> throw new SelendroidException ( ( ( "Selendroid<seq2seq4repair_space>server<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>device<seq2seq4repair_space>didn't<seq2seq4repair_space>came<seq2seq4repair_space>up<seq2seq4repair_space>after<seq2seq4repair_space>" + ( startTimeOut // 1000 ) ) + "sec:" ) ) ; <END_BUG> } } try { Thread . sleep ( 500 ) ; } catch ( InterruptedException e1 ) { e1 . printStackTrace ( ) ; } RemoteWebDriver driver ; try { driver = new RemoteWebDriver ( new URL ( ( ( "http:////localhost:" + port ) + "//wd//hub" ) ) , desiredCapabilities ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; deviceStore . release ( device , app ) ; throw new SessionNotCreatedException ( "Error<seq2seq4repair_space>occurred<seq2seq4repair_space>while<seq2seq4repair_space>creating<seq2seq4repair_space>session<seq2seq4repair_space>on<seq2seq4repair_space>Android<seq2seq4repair_space>device" , e ) ; } String sessionId = driver . getSessionId ( ) . toString ( ) ; SelendroidCapabilities requiredCapabilities = new SelendroidCapabilities ( driver . getCapabilities ( ) . asMap ( ) ) ; ActiveSession session = new ActiveSession ( sessionId , requiredCapabilities , app , device , port , this ) ; this . sessions . put ( sessionId , session ) ; if ( ANDROID . equals ( desiredCapabilities . getAut ( ) ) ) { WebDriverWait wait = new WebDriverWait ( driver , 60 ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . className ( "android.webkit.WebView" ) ) ) ; driver . switchTo ( ) . window ( "WEBVIEW" ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . id ( "AndroidDriver" ) ) ) ; } return sessionId ; } private AndroidApp augmentApp ( AndroidApp app , SelendroidCapabilities desiredCapabilities ) { } private AndroidApp createSelendroidServerApk ( AndroidApp aut ) throws AndroidSdkException { } private Locale parseLocale ( SelendroidCapabilities capa ) { } AndroidDevice getAndroidDevice ( SelendroidCapabilities caps ) throws AndroidDeviceException { } Map < String , AndroidApp > getConfiguredApps ( ) { } void setDeviceStore ( DeviceStore store ) { } private synchronized int getNextSelendroidServerPort ( ) { } public List < ActiveSession > getActiveSessions ( ) { }

Fix:
throw new SelendroidException ( ( ( "Selendroid<seq2seq4repair_space>server<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>device<seq2seq4repair_space>didn't<seq2seq4repair_space>come<seq2seq4repair_space>up<seq2seq4repair_space>after<seq2seq4repair_space>" + ( startTimeOut // 1000 ) ) + "sec:" ) ) ;