Buggy code:
public class FTPSampler extends AbstractSampler { private static final Logger log = LoggingManager . getLoggerForClass ( ) ; public static final String SERVER = "FTPSampler.server" ; public static final String REMOTE_FILENAME = "FTPSampler.filename" ; public static final String LOCAL_FILENAME = "FTPSampler.localfilename" ; public static final String INPUT_DATA = "FTPSampler.inputdata" ; public static final String BINARY_MODE = "FTPSampler.binarymode" ; public static final String UPLOAD_FILE = "FTPSampler.upload" ; public static final String SAVE_RESPONSE = "FTPSampler.saveresponse" ; public FTPSampler ( ) { } public String getUsername ( ) { } public String getPassword ( ) { } public void setServer ( String newServer ) { } public String getServer ( ) { } public String getRemoteFilename ( ) { } public String getLocalFilename ( ) { } private String getLocalFileContents ( ) { } public boolean isBinaryMode ( ) { } public boolean isSaveResponse ( ) { } public boolean isUpload ( ) { } public String getLabel ( ) { } public SampleResult sample ( Entry e ) { SampleResult res = new SampleResult ( ) ; res . setSuccessful ( false ) ; String remote = getRemoteFilename ( ) ; String local = getLocalFilename ( ) ; boolean binaryTransfer = isBinaryMode ( ) ; res . setSampleLabel ( getName ( ) ) ; final String label = getLabel ( ) ; res . setSamplerData ( label ) ; try { res . setURL ( new URL ( label ) ) ; } catch ( MalformedURLException e1 ) { FTPSampler . log . warn ( ( "Cannot<seq2seq4repair_space>set<seq2seq4repair_space>URL:<seq2seq4repair_space>" + ( e1 . getLocalizedMessage ( ) ) ) ) ; } InputStream input = null ; OutputStream output = null ; res . sampleStart ( ) ; FTPClient ftp = new FTPClient ( ) ; try { ftp . connect ( getServer ( ) ) ; res . latencyEnd ( ) ; int reply = ftp . getReplyCode ( ) ; if ( FTPReply . isPositiveCompletion ( reply ) ) { if ( ftp . login ( getUsername ( ) , getPassword ( ) ) ) { if ( binaryTransfer ) { ftp . setFileType ( BINARY_FILE_TYPE ) ; } ftp . enterLocalPassiveMode ( ) ; boolean ftpOK = false ; if ( isUpload ( ) ) { String contents = getLocalFileContents ( ) ; if ( ( contents . length ( ) ) > 0 ) { byte [ ] bytes = contents . getBytes ( ) ; input = new ByteArrayInputStream ( bytes ) ; res . setBytes ( bytes . length ) ; } else { File infile = new File ( local ) ; res . setBytes ( ( ( int ) ( infile . length ( ) ) ) ) ; input = new FileInputStream ( infile ) ; } ftpOK = ftp . storeFile ( remote , input ) ; } else { final boolean saveResponse = isSaveResponse ( ) ; ByteArrayOutputStream baos = null ; OutputStream target = null ; if ( saveResponse ) { baos = new ByteArrayOutputStream ( ) ; target = baos ; } if ( ( local . length ( ) ) > 0 ) { output = new FileOutputStream ( local ) ; if ( target == null ) { target = output ; } else { target = new TeeOutputStream ( output , baos ) ; } } if ( target == null ) { target = new NullOutputStream ( ) ; } input = ftp . retrieveFileStream ( remote ) ; if ( input == null ) { res . setResponseCode ( Integer . toString ( ftp . getReplyCode ( ) ) ) ; res . setResponseMessage ( ftp . getReplyString ( ) ) ; } else { long bytes = IOUtils . copy ( input , target ) ; ftpOK = bytes > 0 ; if ( saveResponse ) { res . setResponseData ( baos . toByteArray ( ) ) ; if ( ! binaryTransfer ) { res . setDataType ( TEXT ) ; } } else { res . setBytes ( ( ( int ) ( bytes ) ) ) ; } } } if ( ftpOK ) { res . setResponseCodeOK ( ) ; res . setResponseMessageOK ( ) ; res . setSuccessful ( true ) ; } else { res . setResponseCode ( Integer . toString ( ftp . getReplyCode ( ) ) ) ; res . setResponseMessage ( ftp . getReplyString ( ) ) ; } } else { res . setResponseCode ( Integer . toString ( ftp . getReplyCode ( ) ) ) ; res . setResponseMessage ( ftp . getReplyString ( ) ) ; } } else { res . setResponseCode ( "501" ) ; res . setResponseMessage ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>connect" ) ; res . setResponseMessage ( ftp . getReplyString ( ) ) ; } } catch ( IOException ex ) { res . setResponseCode ( "000" ) ; res . setResponseMessage ( ex . toString ( ) ) ; } finally { <START_BUG> if ( ( ftp != null ) && ( ftp . isConnected ( ) ) ) { <END_BUG> try { ftp . disconnect ( ) ; } catch ( IOException ignored ) { } } IOUtils . closeQuietly ( input ) ; IOUtils . closeQuietly ( output ) ; } res . sampleEnd ( ) ; return res ; } }

Fix:
if ( ftp . isConnected ( ) ) {