Buggy code:
public static final String KARAF_SHUTDOWN_COMMAND = "karaf.shutdown.command" ; public static final String KARAF_SHUTDOWN_PID_FILE = "karaf.shutdown.pid.file" ; public static final String DEFAULT_SHUTDOWN_COMMAND = "SHUTDOWN" ; public static final String PROPERTY_LOCK_CLASS_DEFAULT = SimpleFileLock . class . getName ( ) ; public static final String INCLUDES_PROPERTY = "${includes}" ; public static final String OPTIONALS_PROPERTY = "${optionals}" ; public static final String KARAF_ACTIVATOR = "Karaf-Activator" ; public static final String SECURITY_PROVIDERS = "org.apache.karaf.security.providers" ; public static final String KARAF_STARTUP_MESSAGE = "karaf.startup.message" ; private static final String KARAF_DELAY_CONSOLE = "karaf.delay.console" ; public static final String OVERRIDE_PREFIX = "karaf.override." ; public static final String DEFAULT_LOCK_DELAY = "1000" ; Logger LOG = Logger . getLogger ( this . getClass ( ) . getName ( ) ) ; private File karafHome ; private File karafBase ; private File karafData ; private File karafEtc ; private File karafInstances ; private Properties configProps = null ; private Framework framework = null ; private final String [ ] args ; private int exitCode ; private Lock lock ; private int defaultStartLevel = 100 ; private int lockStartLevel = 1 ; private int lockDelay = Integer . parseInt ( Main . DEFAULT_LOCK_DELAY ) ; private int shutdownTimeout = ( 5 * 60 ) * 1000 ; private boolean exiting = false ; private ShutdownCallback shutdownCallback ; private List < BundleActivator > karafActivators = new ArrayList < BundleActivator > ( ) ; public Main ( String [ ] args ) { } public void setShutdownCallback ( ShutdownCallback shutdownCallback ) { } public void launch ( ) throws Exception { } private void startKarafActivators ( ClassLoader classLoader ) throws IOException { } private void stopKarafActivators ( ) { } public void awaitShutdown ( ) throws Exception { } public boolean destroy ( ) throws Exception { } public static void main ( String [ ] args ) throws Exception { } private static void processSecurityProperties ( Properties m_configProps ) { } private static void addProvider ( String provider ) { } private void updateInstancePid ( ) { } private static String getPid ( ) { } private void processAutoProperties ( BundleContext context ) { } private List < Bundle > autoInstall ( String propertyPrefix , BundleContext context , FrameworkStartLevel sl , boolean convertToMavenUrls , boolean start ) { } private static String [ ] convertToMavenUrlsIfNeeded ( String location , boolean convertToMavenUrls ) { } private static String nextLocation ( StringTokenizer st ) { } protected static void loadSystemProperties ( File karafEtc ) { } private Properties loadConfigProperties ( ) throws Exception { } private void loadStartupProperties ( Properties configProps ) throws Exception { } protected static Properties loadPropertiesFile ( URL configPropURL , boolean failIfNotFound ) throws Exception { } protected static void copySystemProperties ( Properties configProps ) { } private ClassLoader createClassLoader ( Properties configProps ) throws Exception { } private static void processConfigurationProperties ( Properties configProps , Properties startupProps , List < File > bundleDirs ) throws Exception { } private static File findFile ( List < File > bundleDirs , String name ) { } private static File findFile ( File dir , String name ) { } private static void findJars ( File dir , ArrayList < File > jars ) { } private static final String DELIM_START = "${" ; private static final String DELIM_STOP = "}" ; public static String substVars ( String val , String currentKey , Map < String , String > cycleMap , Properties configProps ) throws IllegalArgumentException { } public String [ ] getArgs ( ) { } public int getExitCode ( ) { } public void setExitCode ( int exitCode ) { } public Framework getFramework ( ) { } public void lock ( Properties props ) { } private void doLock ( Properties props ) throws Exception { } public void unlock ( ) throws Exception { } protected void setStartLevel ( int level , long timeout ) throws Exception { } protected void doSetStartLevel ( FrameworkStartLevel fsl , int level , long timeout ) throws InterruptedException { } private Random random = null ; private ServerSocket shutdownSocket ; protected void setupShutdown ( Properties props ) { writePid ( props ) ; try { int port = Integer . parseInt ( props . getProperty ( Main . KARAF_SHUTDOWN_PORT , "0" ) ) ; String host = props . getProperty ( Main . KARAF_SHUTDOWN_HOST , "localhost" ) ; String portFile = props . getProperty ( Main . KARAF_SHUTDOWN_PORT_FILE ) ; String shutdown = props . getProperty ( Main . KARAF_SHUTDOWN_COMMAND ) ; if ( shutdown == null ) { shutdown = UUID . randomUUID ( ) . toString ( ) ; File file = new File ( karafEtc , Main . CONFIG_PROPERTIES_FILE_NAME ) ; Writer writer = new FileWriter ( file , true ) ; try { <START_BUG> writer . write ( ( ( ( ( "\n#\n#<seq2seq4repair_space>Generated<seq2seq4repair_space>command<seq2seq4repair_space>shutdown\n,#\n" + ( Main . KARAF_SHUTDOWN_COMMAND ) ) + "<seq2seq4repair_space>=<seq2seq4repair_space>" ) + shutdown ) + "\n" ) ) ; <END_BUG> } finally { writer . close ( ) ; } } if ( port >= 0 ) { shutdownSocket = new ServerSocket ( port , 1 , InetAddress . getByName ( host ) ) ; if ( port == 0 ) { port = shutdownSocket . getLocalPort ( ) ; } if ( portFile != null ) { Writer w = new OutputStreamWriter ( new FileOutputStream ( portFile ) ) ; w . write ( Integer . toString ( port ) ) ; w . close ( ) ; } Thread thread = new Main . ShutdownSocketThread ( shutdown ) ; thread . setDaemon ( true ) ; thread . start ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } } private void writePid ( Properties props ) { } public Lock getLock ( ) { } private class ShutdownSocketThread extends Thread { private final String shutdown ; public ShutdownSocketThread ( String shutdown ) { } public void run ( ) { } } }

Fix:
writer . write ( ( ( ( ( "\n\n#\n#<seq2seq4repair_space>Generated<seq2seq4repair_space>shutdown<seq2seq4repair_space>command\n#\n" + ( Main . KARAF_SHUTDOWN_COMMAND ) ) + "<seq2seq4repair_space>=<seq2seq4repair_space>" ) + shutdown ) + "\n" ) ) ;