Buggy code:
public class TCPSampler extends AbstractSampler implements ThreadListener { private static final long serialVersionUID = 233L ; private static final Logger log = LoggingManager . getLoggerForClass ( ) ; public static final String SERVER = "TCPSampler.server" ; public static final String PORT = "TCPSampler.port" ; public static final String FILENAME = "TCPSampler.filename" ; public static final String CLASSNAME = "TCPSampler.classname" ; public static final String NODELAY = "TCPSampler.nodelay" ; public static final String TIMEOUT = "TCPSampler.timeout" ; public static final String REQUEST = "TCPSampler.request" ; public static final String RE_USE_CONNECTION = "TCPSampler.reUseConnection" ; private static final String TCPKEY = "TCP" ; private static final String ERRKEY = "ERR" ; private static final String STATUS_PREFIX = JMeterUtils . getPropDefault ( "tcp.status.prefix" , "" ) ; private static final String STATUS_SUFFIX = JMeterUtils . getPropDefault ( "tcp.status.suffix" , "" ) ; private static final String STATUS_PROPERTIES = JMeterUtils . getPropDefault ( "tcp.status.properties" , "" ) ; private static final Properties statusProps = new Properties ( ) ; private static final boolean haveStatusProps ; private static final ThreadLocal < Map < String , Object > > tp = new ThreadLocal < Map < String , Object > > ( ) { @ Override protected Map < String , Object > initialValue ( ) { } } ; private transient TCPClient protocolHandler ; public TCPSampler ( ) { } private String getError ( ) { } private Socket getSocket ( ) { } public String getUsername ( ) { } public String getPassword ( ) { } public void setServer ( String newServer ) { } public String getServer ( ) { } public void setReUseConnection ( String reuse ) { } public boolean isReUseConnection ( ) { } public void setPort ( String newFilename ) { } public int getPort ( ) { } public void setFilename ( String newFilename ) { } public String getFilename ( ) { } public void setRequestData ( String newRequestData ) { } public String getRequestData ( ) { } public void setTimeout ( String newTimeout ) { } public int getTimeout ( ) { } public void setNoDelay ( String newNoDelay ) { } public boolean getNoDelay ( ) { } public void setClassname ( String classname ) { } public String getClassname ( ) { } public String getLabel ( ) { } private static final String protoPrefix = "org.apache.jmeter.protocol.tcp.sampler." ; private Class < ? > getClass ( String className ) { } private TCPClient getProtocol ( ) { } public SampleResult sample ( Entry e ) { TCPSampler . log . debug ( ( ( ( ( ( ( ( getLabel ( ) ) + "<seq2seq4repair_space>" ) + ( getFilename ( ) ) ) + "<seq2seq4repair_space>" ) + ( getUsername ( ) ) ) + "<seq2seq4repair_space>" ) + ( getPassword ( ) ) ) ) ; SampleResult res = new SampleResult ( ) ; boolean isSuccessful = false ; res . setSampleLabel ( getName ( ) ) ; res . setSamplerData ( ( ( ( "Host:<seq2seq4repair_space>" + ( getServer ( ) ) ) + "<seq2seq4repair_space>Port:<seq2seq4repair_space>" ) + ( getPort ( ) ) ) ) ; res . sampleStart ( ) ; try { Socket sock = getSocket ( ) ; if ( sock == null ) { res . setResponseCode ( "500" ) ; res . setResponseMessage ( getError ( ) ) ; } else if ( ( protocolHandler ) == null ) { res . setResponseCode ( "500" ) ; res . setResponseMessage ( "Protocol<seq2seq4repair_space>handler<seq2seq4repair_space>not<seq2seq4repair_space>found" ) ; } else { InputStream is = sock . getInputStream ( ) ; OutputStream os = sock . getOutputStream ( ) ; String req = getRequestData ( ) ; res . setSamplerData ( req ) ; protocolHandler . write ( os , req ) ; String in = protocolHandler . read ( is ) ; <START_BUG> res . setResponseData ( in . getBytes ( ) ) ; <END_BUG> res . setDataType ( TEXT ) ; res . setResponseCodeOK ( ) ; res . setResponseMessage ( "OK" ) ; isSuccessful = true ; if ( ( TCPSampler . STATUS_PREFIX . length ( ) ) > 0 ) { int i = in . indexOf ( TCPSampler . STATUS_PREFIX ) ; int j = in . indexOf ( TCPSampler . STATUS_SUFFIX , ( i + ( TCPSampler . STATUS_PREFIX . length ( ) ) ) ) ; if ( ( i != ( - 1 ) ) && ( j > i ) ) { String rc = in . substring ( ( i + ( TCPSampler . STATUS_PREFIX . length ( ) ) ) , j ) ; res . setResponseCode ( rc ) ; isSuccessful = checkResponseCode ( rc ) ; if ( TCPSampler . haveStatusProps ) { res . setResponseMessage ( TCPSampler . statusProps . getProperty ( rc , "Status<seq2seq4repair_space>code<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>in<seq2seq4repair_space>properties" ) ) ; } else { res . setResponseMessage ( "No<seq2seq4repair_space>status<seq2seq4repair_space>property<seq2seq4repair_space>file" ) ; } } else { res . setResponseCode ( "999" ) ; res . setResponseMessage ( "Status<seq2seq4repair_space>value<seq2seq4repair_space>not<seq2seq4repair_space>found" ) ; isSuccessful = false ; } } } } catch ( IOException ex ) { TCPSampler . log . debug ( "" , ex ) ; res . setResponseCode ( "500" ) ; res . setResponseMessage ( ex . toString ( ) ) ; closeSocket ( ) ; } catch ( Exception ex ) { TCPSampler . log . error ( "" , ex ) ; isSuccessful = false ; res . setResponseCode ( "500" ) ; res . setResponseMessage ( ex . toString ( ) ) ; } finally { res . sampleEnd ( ) ; res . setSuccessful ( isSuccessful ) ; if ( ! ( isReUseConnection ( ) ) ) { closeSocket ( ) ; } } return res ; } private boolean checkResponseCode ( String rc ) { } public void threadStarted ( ) { } private void closeSocket ( ) { } public void threadFinished ( ) { } }

Fix:
res . setResponseData ( in , null ) ;