Buggy code:
public class ExampleRunner { public static void main ( String [ ] args ) { BufferedOutputStream os = null ; BufferedInputStream is = null ; try { WebArchive archive = ShrinkWrap . create ( WebArchive . class , "war-example.war" ) ; archive . addPackage ( SimpleServlet . class . getPackage ( ) ) ; ExampleRunner . addResources ( "archives//war-example.war" , archive ) ; is = new BufferedInputStream ( archive . as ( ZipExporter . class ) . exportZip ( ) ) ; URL uploadContent = new URL ( "http:////localhost:9990//domain-api//add-content" ) ; HttpURLConnection connection = ( ( HttpURLConnection ) ( uploadContent . openConnection ( ) ) ) ; connection . setDoInput ( true ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( "POST" ) ; <START_BUG> connection . setRequestProperty ( "Content-Type" , "multipart//form-data;boundary=-----------------------------261773107125236" ) ; <END_BUG> os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; StringBuilder builder = new StringBuilder ( ) ; builder . append ( "-----------------------------261773107125236" ) ; builder . append ( "\r\n" ) ; builder . append ( "Content-Disposition:<seq2seq4repair_space>form-data;<seq2seq4repair_space>name=\"file\";<seq2seq4repair_space>filename=\"war-example.war\"" ) ; builder . append ( "\r\n" ) ; builder . append ( "Content-Type:<seq2seq4repair_space>application//octet-stream" ) ; builder . append ( "\r\n" ) ; builder . append ( "\r\n" ) ; os . write ( builder . toString ( ) . getBytes ( ) ) ; final byte [ ] buffer = new byte [ 1024 ] ; int numRead = 0 ; while ( numRead > ( - 1 ) ) { numRead = is . read ( buffer ) ; if ( numRead > 0 ) { os . write ( buffer , 0 , numRead ) ; } } is . close ( ) ; builder = new StringBuilder ( ) ; builder . append ( "\r\n" ) ; builder . append ( "-----------------------------261773107125236" ) ; builder . append ( "--" ) ; builder . append ( "\r\n" ) ; os . write ( builder . toString ( ) . getBytes ( ) ) ; os . flush ( ) ; ModelNode node = ModelNode . fromJSONStream ( connection . getInputStream ( ) ) ; System . out . println ( "Response<seq2seq4repair_space>to<seq2seq4repair_space>content<seq2seq4repair_space>upload<seq2seq4repair_space>request:" ) ; System . out . println ( node ) ; if ( ! ( "success" . equals ( node . require ( "outcome" ) . asString ( ) ) ) ) { throw new IllegalStateException ( "Deployment<seq2seq4repair_space>request<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>succeed" ) ; } byte [ ] hash = node . require ( "result" ) . asBytes ( ) ; connection = ( ( HttpURLConnection ) ( new URL ( "http:////localhost:9990//domain-api//" ) . openConnection ( ) ) ) ; connection . setDoInput ( true ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( "POST" ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; ModelNode op = new ModelNode ( ) ; op . get ( "operation" ) . set ( "add" ) ; op . get ( "address" ) . add ( "deployment" , "war-example.war" ) ; op . get ( "hash" ) . set ( hash ) ; op . get ( "enabled" ) . set ( true ) ; String json = op . toJSONString ( true ) ; System . out . println ( json ) ; os . write ( json . getBytes ( ) ) ; os . flush ( ) ; node = ModelNode . fromJSONStream ( connection . getInputStream ( ) ) ; System . out . println ( "Response<seq2seq4repair_space>to<seq2seq4repair_space>deployment<seq2seq4repair_space>add<seq2seq4repair_space>request:" ) ; System . out . println ( node ) ; if ( ! ( "success" . equals ( node . require ( "outcome" ) . asString ( ) ) ) ) { throw new IllegalStateException ( "Deployment<seq2seq4repair_space>request<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>succeed" ) ; } URL url = new URL ( "http:////localhost:8080//war-example//simple?input=Hello" ) ; System . out . println ( ( ( "Reading<seq2seq4repair_space>response<seq2seq4repair_space>from<seq2seq4repair_space>" + url ) + ":" ) ) ; connection = ( ( HttpURLConnection ) ( url . openConnection ( ) ) ) ; connection . setDoInput ( true ) ; is = new BufferedInputStream ( connection . getInputStream ( ) ) ; int i = is . read ( ) ; while ( i != ( - 1 ) ) { System . out . print ( ( ( char ) ( i ) ) ) ; i = is . read ( ) ; } System . out . println ( "" ) ; is . close ( ) ; connection = ( ( HttpURLConnection ) ( new URL ( "http:////localhost:9990//domain-api//" ) . openConnection ( ) ) ) ; connection . setDoInput ( true ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( "POST" ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; op = new ModelNode ( ) ; op . get ( "operation" ) . set ( "redeploy" ) ; op . get ( "address" ) . add ( "deployment" , "war-example.war" ) ; json = op . toJSONString ( true ) ; System . out . println ( json ) ; os . write ( json . getBytes ( ) ) ; os . flush ( ) ; node = ModelNode . fromJSONStream ( connection . getInputStream ( ) ) ; System . out . println ( "Response<seq2seq4repair_space>to<seq2seq4repair_space>deployment<seq2seq4repair_space>redeploy<seq2seq4repair_space>request:" ) ; System . out . println ( node ) ; if ( ! ( "success" . equals ( node . require ( "outcome" ) . asString ( ) ) ) ) { throw new IllegalStateException ( "Deployment<seq2seq4repair_space>request<seq2seq4repair_space>did<seq2seq4repair_space>not<seq2seq4repair_space>succeed" ) ; } connection = ( ( HttpURLConnection ) ( new URL ( "http:////localhost:9990//domain-api//" ) . openConnection ( ) ) ) ; connection . setDoInput ( true ) ; connection . setDoOutput ( true ) ; connection . setRequestMethod ( "POST" ) ; os = new BufferedOutputStream ( connection . getOutputStream ( ) ) ; op = new ModelNode ( ) ; op . get ( "operation" ) . set ( "remove" ) ;

Fix:
connection . setRequestProperty ( "Content-Type" , "multipart//form-data;boundary=---------------------------261773107125236" ) ;