Buggy code:
public class PostWriter { private static final String DASH_DASH = "--" ; protected static final String BOUNDARY = "---------------------------7d159c1302d0y0" ; private static final byte [ ] CRLF = new byte [ ] { 13 , 10 } ; public static final String ENCODING = "ISO-8859-1" ; private byte [ ] formDataUrlEncoded ; private byte [ ] formDataPostBody ; private byte [ ] formDataFileStartMultipart ; private String boundary ; public PostWriter ( ) { } public PostWriter ( String boundary ) { } public String sendPostData ( URLConnection connection , HTTPSampler sampler ) throws IOException { } public void setHeaders ( URLConnection connection , HTTPSampler sampler ) throws IOException { String contentEncoding = sampler . getContentEncoding ( ) ; if ( ( contentEncoding == null ) || ( ( contentEncoding . length ( ) ) == 0 ) ) { contentEncoding = PostWriter . ENCODING ; } long contentLength = 0L ; if ( sampler . getUseMultipartForPost ( ) ) { connection . setRequestProperty ( HEADER_CONTENT_TYPE , ( ( ( HTTPSamplerBase . MULTIPART_FORM_DATA ) + ";<seq2seq4repair_space>boundary=" ) + ( getBoundary ( ) ) ) ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; bos . write ( getMultipartDivider ( ) ) ; PropertyIterator args = sampler . getArguments ( ) . iterator ( ) ; while ( args . hasNext ( ) ) { HTTPArgument arg = ( ( HTTPArgument ) ( args . next ( ) . getObjectValue ( ) ) ) ; bos . write ( PostWriter . CRLF ) ; writeFormMultipart ( bos , arg . getName ( ) , arg . getValue ( ) , contentEncoding ) ; } if ( sampler . hasUploadableFiles ( ) ) { bos . write ( PostWriter . CRLF ) ; } bos . flush ( ) ; formDataPostBody = bos . toByteArray ( ) ; bos . close ( ) ; contentLength = formDataPostBody . length ; if ( sampler . hasUploadableFiles ( ) ) { bos = new ByteArrayOutputStream ( ) ; writeStartFileMultipart ( bos , sampler . getFilename ( ) , sampler . getFileField ( ) , sampler . getMimetype ( ) ) ; bos . flush ( ) ; formDataFileStartMultipart = bos . toByteArray ( ) ; bos . close ( ) ; contentLength += formDataFileStartMultipart . length ; File uploadFile = new File ( sampler . getFilename ( ) ) ; contentLength += uploadFile . length ( ) ; contentLength += getFileMultipartEndDivider ( ) . length ; } contentLength += getMultipartEndDivider ( ) . length ; connection . setRequestProperty ( HEADER_CONTENT_LENGTH , Long . toString ( contentLength ) ) ; connection . setDoOutput ( true ) ; connection . setDoInput ( true ) ; } else { String contentTypeHeader = connection . getRequestProperty ( HEADER_CONTENT_TYPE ) ; boolean hasContentTypeHeader = ( contentTypeHeader != null ) && ( ( contentTypeHeader . length ( ) ) > 0 ) ; if ( ( ( ( sampler . getArguments ( ) ) != null ) && ( ( sampler . getArguments ( ) . getArgumentCount ( ) ) == 0 ) ) && ( sampler . getSendFileAsPostBody ( ) ) ) { if ( ! hasContentTypeHeader ) { if ( ( ( sampler . getMimetype ( ) ) != null ) && ( ( sampler . getMimetype ( ) . length ( ) ) > 0 ) ) { connection . setRequestProperty ( HEADER_CONTENT_TYPE , sampler . getMimetype ( ) ) ; } else { connection . setRequestProperty ( HEADER_CONTENT_TYPE , APPLICATION_X_WWW_FORM_URLENCODED ) ; } } File inputFile = new File ( sampler . getFilename ( ) ) ; contentLength = inputFile . length ( ) ; } else { if ( ! hasContentTypeHeader ) { connection . setRequestProperty ( HEADER_CONTENT_TYPE , APPLICATION_X_WWW_FORM_URLENCODED ) ; } ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; String postBody = null ; if ( ! ( sampler . getSendParameterValuesAsPostBody ( ) ) ) { postBody = sampler . getQueryString ( contentEncoding ) ; } else { StringBuffer postBodyBuffer = new StringBuffer ( ) ; PropertyIterator args = sampler . getArguments ( ) . iterator ( ) ; while ( args . hasNext ( ) ) { HTTPArgument arg = ( ( HTTPArgument ) ( args . next ( ) . getObjectValue ( ) ) ) ; <START_BUG> postBodyBuffer . append ( arg . getValue ( ) ) ; <END_BUG> } postBody = postBodyBuffer . toString ( ) ; } bos . write ( postBody . getBytes ( "UTF-8" ) ) ; bos . flush ( ) ; bos . close ( ) ; formDataUrlEncoded = bos . toByteArray ( ) ; contentLength = bos . toByteArray ( ) . length ; } connection . setRequestProperty ( HEADER_CONTENT_LENGTH , Long . toString ( contentLength ) ) ; connection . setDoOutput ( true ) ; } } protected String getBoundary ( ) { } private byte [ ] getMultipartDivider ( ) throws IOException { } private byte [ ] getFileMultipartEndDivider ( ) throws IOException { } private byte [ ] getMultipartEndDivider ( ) throws IOException { } private void writeStartFileMultipart ( OutputStream out , String filename , String nameField , String mimetype ) throws IOException { } private void writeFileToStream ( String filename , OutputStream out ) throws IOException { } private void writeFormMultipart ( OutputStream out , String name , String value , String charSet ) throws IOException { } private void write ( OutputStream out , String value ) throws IOException , UnsupportedEncodingException { } private void writeln ( OutputStream out , String value ) throws IOException , UnsupportedEncodingException { } }

Fix:
postBodyBuffer . append ( arg . getEncodedValue ( contentEncoding ) ) ;