Buggy code:
@ Entity @ Table ( name = "applications" ) public class Application extends Model { private static final int ONE_SECOND = 1000 ; @ Required @ Column ( updatable = false , unique = true , nullable = false ) public String pid ; @ Column ( updatable = false , nullable = false ) @ Required public VersionControlSystemType vcsType ; @ Column ( updatable = false , nullable = false ) @ Required public String vcsUrl ; public Boolean checkedOut = false ; public Boolean enabled ; @ Column ( updatable = true , nullable = false ) @ Required public Mode mode ; @ OneToMany ( fetch = FetchType . EAGER , mappedBy = "application" ) public Set < ApplicationProperty > properties ; public static Integer getCommandTimeout ( ) { } public void start ( boolean force , boolean enable ) throws Exception { if ( ( ! force ) && ( ! ( enabled ) ) ) { throw new Exception ( ( "Can<seq2seq4repair_space>not<seq2seq4repair_space>start<seq2seq4repair_space>disabled<seq2seq4repair_space>application<seq2seq4repair_space>" + ( pid ) ) ) ; } else if ( isRunning ( ) ) { throw new Exception ( ( ( "Application<seq2seq4repair_space>" + ( pid ) ) + "<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>running." ) ) ; } ConfigurationManager . generateConfigurationFiles ( this ) ; final String startPid = ( pid ) + ( ProcessManager . PROCESS_START_POSTFIX ) ; try { final ApplicationProperty address = ApplicationProperty . findHostProperty ( this ) ; final ApplicationProperty port = ApplicationProperty . findPortProperty ( this ) ; final String url = ( ( "http:////" + ( address == null ? "127.0.0.1" : address . value ) ) + ":" ) + ( port . value ) ; checkForOtherApplication ( url ) ; ProcessManager . executeCommand ( startPid , ( ( ProcessManager . getFullPlayPath ( ) ) + "<seq2seq4repair_space>start<seq2seq4repair_space>." ) , new StringBuffer ( ) , new File ( ( ( "apps//" + ( pid ) ) + "//" ) ) , true ) ; checkApplicationIsRunning ( url ) ; ProcessManager . executeCommand ( ( ( pid ) + "-status" ) , ( ( ProcessManager . getFullPlayPath ( ) ) + "<seq2seq4repair_space>status<seq2seq4repair_space>." ) , new StringBuffer ( ) , new File ( ( ( "apps//" + ( pid ) ) + "//" ) ) , false ) ; if ( enable ) { enabled = true ; save ( ) ; em ( ) . flush ( ) ; } Logger . info ( "Started<seq2seq4repair_space>%s" , pid ) ; } catch ( TimeoutException e ) { Logger . info ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>determine<seq2seq4repair_space>whether<seq2seq4repair_space>%s<seq2seq4repair_space>started,<seq2seq4repair_space>time-out<seq2seq4repair_space>value:<seq2seq4repair_space>%s<seq2seq4repair_space>reached" , pid , Application . getCommandTimeout ( ) ) ; Logger . info ( "Check<seq2seq4repair_space>status<seq2seq4repair_space>manually<seq2seq4repair_space>and<seq2seq4repair_space>remove<seq2seq4repair_space>server.pid<seq2seq4repair_space>manually<seq2seq4repair_space>when<seq2seq4repair_space>needed" ) ; throw e ; } catch ( Exception e ) { Logger . info ( e , "Failed<seq2seq4repair_space>to<seq2seq4repair_space>start<seq2seq4repair_space>%s" , pid ) ; final File serverPid = new File ( ( ( "apps//" + ( pid ) ) + "//server.pid" ) ) ; <START_BUG> if ( ( serverPid . exists ( ) ) && ( ! ( new File ( ( ( "apps//" + ( pid ) ) + "//server.pid" ) ) . delete ( ) ) ) ) { <END_BUG> throw new Exception ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>remove<seq2seq4repair_space>server.pid<seq2seq4repair_space>for<seq2seq4repair_space>falsely<seq2seq4repair_space>started<seq2seq4repair_space>application,<seq2seq4repair_space>remove<seq2seq4repair_space>manually" ) ; } throw e ; } finally { ProcessManager . removeKeptPid ( startPid ) ; } } private void checkApplicationIsRunning ( final String url ) throws InterruptedException , TimeoutException { } private void checkForOtherApplication ( final String url ) throws Exception { } private void resolveDependencies ( ) throws Exception { } public void stop ( ) throws Exception { } public void restart ( ) throws Exception { } @ Transient public boolean isRunning ( ) throws Exception { } public boolean isBooting ( ) throws Exception { } public void pull ( ) throws Exception { } public void checkout ( ) throws Exception { } public void clean ( ) throws Exception { } public synchronized String status ( ) throws Exception { } }

Fix:
if ( ( force && ( serverPid . exists ( ) ) ) && ( ! ( new File ( ( ( "apps//" + ( pid ) ) + "//server.pid" ) ) . delete ( ) ) ) ) {