39
39
import java .util .concurrent .TimeUnit ;
40
40
41
41
import org .apache .hadoop .thirdparty .com .google .common .annotations .VisibleForTesting ;
42
+ import org .apache .hadoop .thirdparty .com .google .common .base .Preconditions ;
42
43
import org .apache .hadoop .thirdparty .com .google .common .base .Strings ;
43
44
import org .apache .hadoop .thirdparty .com .google .common .util .concurrent .FutureCallback ;
44
45
import org .apache .hadoop .thirdparty .com .google .common .util .concurrent .Futures ;
@@ -383,6 +384,10 @@ public AbfsRestOperation createPath(final String path, final boolean isFile, fin
383
384
try {
384
385
op .execute (tracingContext );
385
386
} catch (AzureBlobFileSystemException ex ) {
387
+ // If we have no HTTP response, throw the original exception.
388
+ if (!op .hasResult ()) {
389
+ throw ex ;
390
+ }
386
391
if (!isFile && op .getResult ().getStatusCode () == HttpURLConnection .HTTP_CONFLICT ) {
387
392
String existingResource =
388
393
op .getResult ().getResponseHeader (X_MS_EXISTING_RESOURCE_TYPE );
@@ -506,6 +511,10 @@ public AbfsRestOperation renamePath(String source, final String destination,
506
511
try {
507
512
op .execute (tracingContext );
508
513
} catch (AzureBlobFileSystemException e ) {
514
+ // If we have no HTTP response, throw the original exception.
515
+ if (!op .hasResult ()) {
516
+ throw e ;
517
+ }
509
518
final AbfsRestOperation idempotencyOp = renameIdempotencyCheckOp (
510
519
renameRequestStartTime , op , destination , tracingContext );
511
520
if (idempotencyOp .getResult ().getStatusCode ()
@@ -530,7 +539,7 @@ public AbfsRestOperation renamePath(String source, final String destination,
530
539
* the one initiated from this ABFS filesytem instance as it was retried. This
531
540
* should be a corner case hence going ahead with LMT check.
532
541
* @param renameRequestStartTime startTime for the rename request
533
- * @param op Rename request REST operation response
542
+ * @param op Rename request REST operation response with non-null HTTP response
534
543
* @param destination rename destination path
535
544
* @param tracingContext Tracks identifiers for request header
536
545
* @return REST operation response post idempotency check
@@ -541,6 +550,7 @@ public AbfsRestOperation renameIdempotencyCheckOp(
541
550
final AbfsRestOperation op ,
542
551
final String destination ,
543
552
TracingContext tracingContext ) throws AzureBlobFileSystemException {
553
+ Preconditions .checkArgument (op .hasResult (), "Operations has null HTTP response" );
544
554
if ((op .isARetriedRequest ())
545
555
&& (op .getResult ().getStatusCode () == HttpURLConnection .HTTP_NOT_FOUND )) {
546
556
// Server has returned HTTP 404, which means rename source no longer
@@ -612,6 +622,10 @@ public AbfsRestOperation append(final String path, final byte[] buffer,
612
622
try {
613
623
op .execute (tracingContext );
614
624
} catch (AzureBlobFileSystemException e ) {
625
+ // If we have no HTTP response, throw the original exception.
626
+ if (!op .hasResult ()) {
627
+ throw e ;
628
+ }
615
629
if (reqParams .isAppendBlob ()
616
630
&& appendSuccessCheckOp (op , path ,
617
631
(reqParams .getPosition () + reqParams .getLength ()), tracingContext )) {
@@ -796,6 +810,10 @@ public AbfsRestOperation deletePath(final String path, final boolean recursive,
796
810
try {
797
811
op .execute (tracingContext );
798
812
} catch (AzureBlobFileSystemException e ) {
813
+ // If we have no HTTP response, throw the original exception.
814
+ if (!op .hasResult ()) {
815
+ throw e ;
816
+ }
799
817
final AbfsRestOperation idempotencyOp = deleteIdempotencyCheckOp (op );
800
818
if (idempotencyOp .getResult ().getStatusCode ()
801
819
== op .getResult ().getStatusCode ()) {
@@ -822,10 +840,11 @@ public AbfsRestOperation deletePath(final String path, final boolean recursive,
822
840
* delete issued from this filesystem instance.
823
841
* These are few corner cases and usually returning a success at this stage
824
842
* should help the job to continue.
825
- * @param op Delete request REST operation response
843
+ * @param op Delete request REST operation response with non-null HTTP response
826
844
* @return REST operation response post idempotency check
827
845
*/
828
846
public AbfsRestOperation deleteIdempotencyCheckOp (final AbfsRestOperation op ) {
847
+ Preconditions .checkArgument (op .hasResult (), "Operations has null HTTP response" );
829
848
if ((op .isARetriedRequest ())
830
849
&& (op .getResult ().getStatusCode () == HttpURLConnection .HTTP_NOT_FOUND )
831
850
&& DEFAULT_DELETE_CONSIDERED_IDEMPOTENT ) {
0 commit comments