Buggy code:
public class Proxy extends Thread { private static final Logger log = LoggingManager . getLoggerForClass ( ) ; private static final byte [ ] CRLF_BYTES = new byte [ ] { 13 , 10 } ; private static final String CRLF_STRING = "\r\n" ; private static final String NEW_LINE = "\n" ; private static final String [ ] headersToRemove ; private static final String PROXY_HEADERS_REMOVE = "proxy.headers.remove" ; private static final String PROXY_HEADERS_REMOVE_DEFAULT = "If-Modified-Since,If-None-Match,Host" ; private static final String PROXY_HEADERS_REMOVE_SEPARATOR = "," ; private static final String KEYSTORE_TYPE = JMeterUtils . getPropDefault ( "proxy.cert.type" , "JKS" ) ; private static final String KEYMANAGERFACTORY = JMeterUtils . getPropDefault ( "proxy.cert.factory" , "SunX509" ) ; private static final String SSLCONTEXT_PROTOCOL = JMeterUtils . getPropDefault ( "proxy.ssl.protocol" , "SSLv3" ) ; private static final HashMap < String , SSLSocketFactory > hashHost = new HashMap < String , SSLSocketFactory > ( ) ; private static final String CERT_DIRECTORY = JMeterUtils . getPropDefault ( "proxy.cert.directory" , JMeterUtils . getJMeterBinDir ( ) ) ; private static final String CERT_FILE_DEFAULT = "proxyserver.jks" ; private static final String CERT_FILE = JMeterUtils . getPropDefault ( "proxy.cert.file" , Proxy . CERT_FILE_DEFAULT ) ; private static final String JMETER_SERVER_ALIAS = ":jmeter:" ; private static final int CERT_VALIDITY = JMeterUtils . getPropDefault ( "proxy.cert.validity" , 7 ) ; private static final String DEFAULT_PASSWORD = "password" ; private static final SamplerCreatorFactory factory = new SamplerCreatorFactory ( ) ; private static final String USER_PASSWORD_KEY = "proxy_cert_PASSWORD" ; private static final Preferences prefs = Preferences . userNodeForPackage ( Proxy . class ) ; private OutputStream outStreamClient = null ; private Socket clientSocket = null ; private ProxyControl target ; private boolean captureHttpHeaders ; private Map < String , String > pageEncodings ; private Map < String , String > formEncodings ; private String port ; public Proxy ( ) { } void configure ( Socket _clientSocket , ProxyControl _target , Map < String , String > _pageEncodings , Map < String , String > _formEncodings ) { } @ Override public void run ( ) { } private SSLSocketFactory getSSLSocketFactory ( String host ) { } private KeyManager [ ] getKeyManagers ( String host ) throws IOException , GeneralSecurityException { } private KeyStore getKeyStore ( char [ ] password ) throws IOException , GeneralSecurityException { } private KeyStore getJMeterKeyStore ( String keyStorePass , String host ) throws IOException , GeneralSecurityException { final File certFile = new File ( Proxy . CERT_DIRECTORY , Proxy . CERT_FILE ) ; final String subject = ( host == null ) ? Proxy . JMETER_SERVER_ALIAS : host ; KeyStore keyStore = null ; final String canonicalPath = certFile . getCanonicalPath ( ) ; if ( keyStorePass != null ) { try { keyStore = getKeyStore ( keyStorePass . toCharArray ( ) ) ; } catch ( Exception e ) { Proxy . log . warn ( ( ( ( ( ( port ) + "Could<seq2seq4repair_space>not<seq2seq4repair_space>open<seq2seq4repair_space>expected<seq2seq4repair_space>file<seq2seq4repair_space>" ) + canonicalPath ) + "<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) ) ; } } if ( keyStore == null ) { keyStorePass = RandomStringUtils . randomAscii ( 20 ) ; setPassword ( keyStorePass ) ; if ( host != null ) { Proxy . log . info ( ( ( ( port ) + "Creating<seq2seq4repair_space>Proxy<seq2seq4repair_space>CA<seq2seq4repair_space>in<seq2seq4repair_space>" ) + canonicalPath ) ) ; KeyToolUtils . generateProxyCA ( certFile , keyStorePass , Proxy . CERT_VALIDITY ) ; Proxy . log . info ( ( ( ( ( ( port ) + "Creating<seq2seq4repair_space>entry<seq2seq4repair_space>" ) + subject ) + "<seq2seq4repair_space>in<seq2seq4repair_space>" ) + canonicalPath ) ) ; KeyToolUtils . generateHostCert ( certFile , keyStorePass , subject , Proxy . CERT_VALIDITY ) ; Proxy . log . info ( ( ( ( port ) + "Created<seq2seq4repair_space>keystore<seq2seq4repair_space>in<seq2seq4repair_space>" ) + canonicalPath ) ) ; } else { Proxy . log . info ( ( ( ( port ) + "Generating<seq2seq4repair_space>standard<seq2seq4repair_space>keypair<seq2seq4repair_space>in<seq2seq4repair_space>" ) + canonicalPath ) ) ; <START_BUG> if ( ! ( certFile . delete ( ) ) ) { <END_BUG> throw new IOException ( ( ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>delete<seq2seq4repair_space>file:" + ( certFile . getAbsolutePath ( ) ) ) + ",<seq2seq4repair_space>this<seq2seq4repair_space>is<seq2seq4repair_space>needed<seq2seq4repair_space>for<seq2seq4repair_space>certificate<seq2seq4repair_space>generation" ) ) ; } KeyToolUtils . genkeypair ( certFile , Proxy . JMETER_SERVER_ALIAS , keyStorePass , Proxy . CERT_VALIDITY , null , null ) ; } keyStore = getKeyStore ( keyStorePass . toCharArray ( ) ) ; } if ( ( ( keyStorePass != null ) && ( host != null ) ) && ( ! ( keyStore . containsAlias ( host ) ) ) ) { Proxy . log . info ( ( ( ( ( ( port ) + "Creating<seq2seq4repair_space>entry<seq2seq4repair_space>'" ) + host ) + "'<seq2seq4repair_space>in<seq2seq4repair_space>" ) + canonicalPath ) ) ; KeyToolUtils . generateHostCert ( certFile , keyStorePass , host , Proxy . CERT_VALIDITY ) ; keyStore = getKeyStore ( keyStorePass . toCharArray ( ) ) ; } return keyStore ; } private Socket startSSL ( Socket sock , String host ) throws IOException { } private SampleResult generateErrorResult ( SampleResult result , HttpRequestHdr request , Exception e ) { } private static SampleResult generateErrorResult ( SampleResult result , HttpRequestHdr request , Exception e , String msg ) { } private void writeToClient ( SampleResult res , OutputStream out ) throws IOException { } private String messageResponseHeaders ( SampleResult res ) { } private void writeErrorToClient ( String message ) { } private String addPageEncoding ( SampleResult result ) { } private void addFormEncodings ( SampleResult result , String pageEncoding ) { } private String getUrlWithoutQuery ( URL url ) { } private String getPassword ( ) { } private void setPassword ( String password ) { } }

Fix:
if ( ( certFile . exists ( ) ) && ( ! ( certFile . delete ( ) ) ) ) {