@@ -426,36 +426,36 @@ public void testWriteLargeBlob() throws Exception {
426426 } else if ("PUT" .equals (requestComponents .method ())
427427 && requestComponents .query ().contains ("uploadId=TEST" )
428428 && requestComponents .query ().contains ("partNumber=" )) {
429- // upload part request
430- MD5DigestCalculatingInputStream md5 = new MD5DigestCalculatingInputStream (exchange .getRequestBody ());
431- BytesReference bytes = Streams .readFully (md5 );
432- assertThat ((long ) bytes .length (), anyOf (equalTo (lastPartSize ), equalTo (bufferSize .getBytes ())));
433- assertThat (contentLength , anyOf (equalTo (lastPartSize ), equalTo (bufferSize .getBytes ())));
434-
435- if (countDownUploads .decrementAndGet () % 2 == 0 ) {
436- exchange .getResponseHeaders ().add ("ETag" , Base16 .encodeAsString (md5 .getMd5Digest ()));
437- exchange .sendResponseHeaders (HttpStatus .SC_OK , -1 );
438- exchange .close ();
439- return ;
440- }
429+ // upload part request
430+ MD5DigestCalculatingInputStream md5 = new MD5DigestCalculatingInputStream (exchange .getRequestBody ());
431+ BytesReference bytes = Streams .readFully (md5 );
432+ assertThat ((long ) bytes .length (), anyOf (equalTo (lastPartSize ), equalTo (bufferSize .getBytes ())));
433+ assertThat (contentLength , anyOf (equalTo (lastPartSize ), equalTo (bufferSize .getBytes ())));
434+
435+ if (countDownUploads .decrementAndGet () % 2 == 0 ) {
436+ exchange .getResponseHeaders ().add ("ETag" , Base16 .encodeAsString (md5 .getMd5Digest ()));
437+ exchange .sendResponseHeaders (HttpStatus .SC_OK , -1 );
438+ exchange .close ();
439+ return ;
440+ }
441441
442- } else if ("POST" .equals (requestComponents .method ()) && requestComponents .query ().equals ("uploadId=TEST" )) {
443- // complete multipart upload request
444- if (countDownComplete .countDown ()) {
445- Streams .readFully (exchange .getRequestBody ());
446- byte [] response = ("""
442+ } else if ("POST" .equals (requestComponents .method ()) && requestComponents .query ().equals ("uploadId=TEST" )) {
443+ // complete multipart upload request
444+ if (countDownComplete .countDown ()) {
445+ Streams .readFully (exchange .getRequestBody ());
446+ byte [] response = ("""
447447 <?xml version="1.0" encoding="UTF-8"?>
448448 <CompleteMultipartUploadResult>
449449 <Bucket>bucket</Bucket>
450450 <Key>write_large_blob</Key>
451451 </CompleteMultipartUploadResult>""" ).getBytes (StandardCharsets .UTF_8 );
452- exchange .getResponseHeaders ().add ("Content-Type" , "application/xml" );
453- exchange .sendResponseHeaders (HttpStatus .SC_OK , response .length );
454- exchange .getResponseBody ().write (response );
455- exchange .close ();
456- return ;
452+ exchange .getResponseHeaders ().add ("Content-Type" , "application/xml" );
453+ exchange .sendResponseHeaders (HttpStatus .SC_OK , response .length );
454+ exchange .getResponseBody ().write (response );
455+ exchange .close ();
456+ return ;
457+ }
457458 }
458- }
459459
460460 // sends an error back or let the request time out
461461 if (useTimeout == false ) {
@@ -528,35 +528,35 @@ public void testWriteLargeBlobStreaming() throws Exception {
528528 } else if ("PUT" .equals (requestComponents .method ())
529529 && requestComponents .query ().contains ("uploadId=TEST" )
530530 && requestComponents .query ().contains ("partNumber=" )) {
531- // upload part request
532- MD5DigestCalculatingInputStream md5 = new MD5DigestCalculatingInputStream (exchange .getRequestBody ());
533- BytesReference bytes = Streams .readFully (md5 );
531+ // upload part request
532+ MD5DigestCalculatingInputStream md5 = new MD5DigestCalculatingInputStream (exchange .getRequestBody ());
533+ BytesReference bytes = Streams .readFully (md5 );
534534
535- if (counterUploads .incrementAndGet () % 2 == 0 ) {
536- bytesReceived .addAndGet (bytes .length ());
537- exchange .getResponseHeaders ().add ("ETag" , Base16 .encodeAsString (md5 .getMd5Digest ()));
538- exchange .sendResponseHeaders (HttpStatus .SC_OK , -1 );
539- exchange .close ();
540- return ;
541- }
535+ if (counterUploads .incrementAndGet () % 2 == 0 ) {
536+ bytesReceived .addAndGet (bytes .length ());
537+ exchange .getResponseHeaders ().add ("ETag" , Base16 .encodeAsString (md5 .getMd5Digest ()));
538+ exchange .sendResponseHeaders (HttpStatus .SC_OK , -1 );
539+ exchange .close ();
540+ return ;
541+ }
542542
543- } else if ("POST" .equals (requestComponents .method ()) && requestComponents .query ().equals ("uploadId=TEST" )) {
544- // complete multipart upload request
545- if (countDownComplete .countDown ()) {
546- Streams .readFully (exchange .getRequestBody ());
547- byte [] response = ("""
543+ } else if ("POST" .equals (requestComponents .method ()) && requestComponents .query ().equals ("uploadId=TEST" )) {
544+ // complete multipart upload request
545+ if (countDownComplete .countDown ()) {
546+ Streams .readFully (exchange .getRequestBody ());
547+ byte [] response = ("""
548548 <?xml version="1.0" encoding="UTF-8"?>
549549 <CompleteMultipartUploadResult>
550550 <Bucket>bucket</Bucket>
551551 <Key>write_large_blob_streaming</Key>
552552 </CompleteMultipartUploadResult>""" ).getBytes (StandardCharsets .UTF_8 );
553- exchange .getResponseHeaders ().add ("Content-Type" , "application/xml" );
554- exchange .sendResponseHeaders (HttpStatus .SC_OK , response .length );
555- exchange .getResponseBody ().write (response );
556- exchange .close ();
557- return ;
553+ exchange .getResponseHeaders ().add ("Content-Type" , "application/xml" );
554+ exchange .sendResponseHeaders (HttpStatus .SC_OK , response .length );
555+ exchange .getResponseBody ().write (response );
556+ exchange .close ();
557+ return ;
558+ }
558559 }
559- }
560560
561561 // sends an error back or let the request time out
562562 if (useTimeout == false ) {
0 commit comments