@@ -463,42 +463,55 @@ public void createEmptyObjects(
463
463
final CountDownLatch latch = new CountDownLatch (resourceIds .size ());
464
464
for (final StorageResourceId resourceId : resourceIds ) {
465
465
final Storage .Objects .Insert insertObject = prepareEmptyInsert (resourceId , options );
466
- manualBatchingThreadPool .execute (new Runnable () {
467
- @ Override
468
- public void run () {
469
- try {
470
- insertObject .execute ();
471
- LOG .debug ("Successfully inserted {}" , resourceId .toString ());
472
- } catch (IOException ioe ) {
473
- boolean canIgnoreException = false ;
474
- try {
475
- canIgnoreException = canIgnoreExceptionForEmptyObject (ioe , resourceId , options );
476
- } catch (Throwable t ) {
477
- // Make sure to catch Throwable instead of only IOException so that we can
478
- // correctly wrap other such throwables and propagate them out cleanly inside
479
- // innerExceptions; common sources of non-IOExceptions include Preconditions
480
- // checks which get enforced at varous layers in the library stack.
481
- IOException toWrap =
482
- (t instanceof IOException ? (IOException ) t : new IOException (t ));
483
- innerExceptions .add (wrapException (toWrap ,
484
- "Error re-fetching after rate-limit error." ,
485
- resourceId .getBucketName (), resourceId .getObjectName ()));
486
- }
487
- if (canIgnoreException ) {
488
- LOG .info (
489
- "Ignoring exception; verified object already exists with desired state." , ioe );
490
- } else {
491
- innerExceptions .add (wrapException (ioe , "Error inserting." ,
492
- resourceId .getBucketName (), resourceId .getObjectName ()));
466
+ manualBatchingThreadPool .execute (
467
+ new Runnable () {
468
+ @ Override
469
+ public void run () {
470
+ try {
471
+ insertObject .execute ();
472
+ LOG .debug ("Successfully inserted {}" , resourceId );
473
+ } catch (IOException ioe ) {
474
+ boolean canIgnoreException = false ;
475
+ try {
476
+ canIgnoreException = canIgnoreExceptionForEmptyObject (ioe , resourceId , options );
477
+ } catch (Throwable t ) {
478
+ // Make sure to catch Throwable instead of only IOException so that we can
479
+ // correctly wrap other such throwables and propagate them out cleanly inside
480
+ // innerExceptions; common sources of non-IOExceptions include Preconditions
481
+ // checks which get enforced at varous layers in the library stack.
482
+ IOException toWrap =
483
+ (t instanceof IOException ? (IOException ) t : new IOException (t ));
484
+ innerExceptions .add (
485
+ wrapException (
486
+ toWrap ,
487
+ "Error re-fetching after rate-limit error." ,
488
+ resourceId .getBucketName (),
489
+ resourceId .getObjectName ()));
490
+ }
491
+ if (canIgnoreException ) {
492
+ LOG .info (
493
+ "Ignoring exception; verified object already exists with desired state." ,
494
+ ioe );
495
+ } else {
496
+ innerExceptions .add (
497
+ wrapException (
498
+ ioe ,
499
+ "Error inserting." ,
500
+ resourceId .getBucketName (),
501
+ resourceId .getObjectName ()));
502
+ }
503
+ } catch (Throwable t ) {
504
+ innerExceptions .add (
505
+ wrapException (
506
+ new IOException (t ),
507
+ "Error inserting." ,
508
+ resourceId .getBucketName (),
509
+ resourceId .getObjectName ()));
510
+ } finally {
511
+ latch .countDown ();
512
+ }
493
513
}
494
- } catch (Throwable t ) {
495
- innerExceptions .add (wrapException (new IOException (t ), "Error inserting." ,
496
- resourceId .getBucketName (), resourceId .getObjectName ()));
497
- } finally {
498
- latch .countDown ();
499
- }
500
- }
501
- });
514
+ });
502
515
}
503
516
504
517
try {
@@ -611,7 +624,7 @@ public void create(String bucketName, CreateBucketOptions options)
611
624
@ Override
612
625
public void deleteBuckets (List <String > bucketNames )
613
626
throws IOException {
614
- LOG .debug ("deleteBuckets({})" , bucketNames . toString () );
627
+ LOG .debug ("deleteBuckets({})" , bucketNames );
615
628
616
629
// Validate all the inputs first.
617
630
for (String bucketName : bucketNames ) {
@@ -657,7 +670,7 @@ public void deleteBuckets(List<String> bucketNames)
657
670
@ Override
658
671
public void deleteObjects (List <StorageResourceId > fullObjectNames )
659
672
throws IOException {
660
- LOG .debug ("deleteObjects({})" , fullObjectNames . toString () );
673
+ LOG .debug ("deleteObjects({})" , fullObjectNames );
661
674
662
675
// Validate that all the elements represent StorageObjects.
663
676
for (StorageResourceId fullObjectName : fullObjectNames ) {
@@ -699,8 +712,7 @@ private JsonBatchCallback<Void> getDeletionCallback(
699
712
return new JsonBatchCallback <Void >() {
700
713
@ Override
701
714
public void onSuccess (Void obj , HttpHeaders responseHeaders ) {
702
- LOG .debug (
703
- "Successfully deleted {} at generation {}" , fullObjectName .toString (), generation );
715
+ LOG .debug ("Successfully deleted {} at generation {}" , fullObjectName , generation );
704
716
}
705
717
706
718
@ Override
@@ -711,22 +723,22 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOE
711
723
// receives the request but we get a retry-able error before we get a response.
712
724
// During a retry, we no longer find the item because the server had deleted
713
725
// it already.
714
- LOG .debug ("deleteObjects({}) : delete not found" , fullObjectName . toString () );
726
+ LOG .debug ("deleteObjects({}) : delete not found" , fullObjectName );
715
727
} else if (errorExtractor .preconditionNotMet (e )
716
728
&& attempt <= MAXIMUM_PRECONDITION_FAILURES_IN_DELETE ) {
717
729
LOG .info (
718
730
"Precondition not met while deleting {} at generation {}. Attempt {}. Retrying." ,
719
731
fullObjectName .toString (),
720
732
generation ,
721
733
attempt );
722
- queueSingleObjectDelete (
723
- fullObjectName , innerExceptions , batchHelper , attempt + 1 );
734
+ queueSingleObjectDelete (fullObjectName , innerExceptions , batchHelper , attempt + 1 );
724
735
} else {
725
- innerExceptions .add (wrapException (
726
- new IOException (e .toString ()),
727
- String .format ("Error deleting, stage 2 with generation %s" , generation ),
728
- bucketName ,
729
- objectName ));
736
+ innerExceptions .add (
737
+ wrapException (
738
+ new IOException (e .toString ()),
739
+ String .format ("Error deleting, stage 2 with generation %s" , generation ),
740
+ bucketName ,
741
+ objectName ));
730
742
}
731
743
}
732
744
};
@@ -774,7 +786,7 @@ public void onFailure(GoogleJsonError googleJsonError, HttpHeaders httpHeaders)
774
786
if (errorExtractor .itemNotFound (googleJsonError )) {
775
787
// If the item isn't found, treat it the same as if it's not found in the delete
776
788
// case: assume the user wanted the object gone and now it is.
777
- LOG .debug ("deleteObjects({}) : get not found" , fullObjectName . toString () );
789
+ LOG .debug ("deleteObjects({}) : get not found" , fullObjectName );
778
790
} else {
779
791
innerExceptions .add (
780
792
wrapException (
@@ -1432,7 +1444,7 @@ public static GoogleCloudStorageItemInfo createItemInfoForNotFound(StorageResour
1432
1444
@ Override
1433
1445
public List <GoogleCloudStorageItemInfo > getItemInfos (List <StorageResourceId > resourceIds )
1434
1446
throws IOException {
1435
- LOG .debug ("getItemInfos({})" , resourceIds . toString () );
1447
+ LOG .debug ("getItemInfos({})" , resourceIds );
1436
1448
1437
1449
final Map <StorageResourceId , GoogleCloudStorageItemInfo > itemInfos = new HashMap <>();
1438
1450
final List <IOException > innerExceptions = new ArrayList <>();
@@ -1518,7 +1530,7 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
1518
1530
@ Override
1519
1531
public List <GoogleCloudStorageItemInfo > updateItems (List <UpdatableItemInfo > itemInfoList )
1520
1532
throws IOException {
1521
- LOG .debug ("updateItems({})" , itemInfoList . toString () );
1533
+ LOG .debug ("updateItems({})" , itemInfoList );
1522
1534
1523
1535
final Map <StorageResourceId , GoogleCloudStorageItemInfo > resultItemInfos = new HashMap <>();
1524
1536
final List <IOException > innerExceptions = new ArrayList <>();
0 commit comments