@@ -298,8 +298,8 @@ void setBackOffFactory(BackOffFactory factory) {
298
298
public WritableByteChannel create (StorageResourceId resourceId , CreateObjectOptions options )
299
299
throws IOException {
300
300
LOG .debug ("create({})" , resourceId );
301
- Preconditions .checkArgument (resourceId . isStorageObject (),
302
- "Expected full StorageObject id, got " + resourceId );
301
+ Preconditions .checkArgument (
302
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
303
303
304
304
/*
305
305
* When performing mutations in GCS, even when we aren't concerned with parallel writers,
@@ -405,17 +405,17 @@ public WritableByteChannel create(StorageResourceId resourceId, CreateObjectOpti
405
405
public WritableByteChannel create (StorageResourceId resourceId )
406
406
throws IOException {
407
407
LOG .debug ("create({})" , resourceId );
408
- Preconditions .checkArgument (resourceId . isStorageObject (),
409
- "Expected full StorageObject id, got " + resourceId );
408
+ Preconditions .checkArgument (
409
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
410
410
411
411
return create (resourceId , CreateObjectOptions .DEFAULT );
412
412
}
413
413
414
414
@ Override
415
415
public void createEmptyObject (StorageResourceId resourceId , CreateObjectOptions options )
416
416
throws IOException {
417
- Preconditions .checkArgument (resourceId . isStorageObject (),
418
- "Expected full StorageObject id, got " + resourceId );
417
+ Preconditions .checkArgument (
418
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
419
419
420
420
Storage .Objects .Insert insertObject = prepareEmptyInsert (resourceId , options );
421
421
try {
@@ -438,8 +438,8 @@ public void createEmptyObject(StorageResourceId resourceId, CreateObjectOptions
438
438
public void createEmptyObject (StorageResourceId resourceId )
439
439
throws IOException {
440
440
LOG .debug ("createEmptyObject({})" , resourceId );
441
- Preconditions .checkArgument (resourceId . isStorageObject (),
442
- "Expected full StorageObject id, got " + resourceId );
441
+ Preconditions .checkArgument (
442
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
443
443
createEmptyObject (resourceId , CreateObjectOptions .DEFAULT );
444
444
}
445
445
@@ -552,8 +552,8 @@ public SeekableByteChannel open(
552
552
StorageResourceId resourceId , GoogleCloudStorageReadOptions readOptions )
553
553
throws IOException {
554
554
LOG .debug ("open({}, {})" , resourceId , readOptions );
555
- Preconditions .checkArgument (resourceId . isStorageObject (),
556
- "Expected full StorageObject id, got " + resourceId );
555
+ Preconditions .checkArgument (
556
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
557
557
558
558
// The underlying channel doesn't initially read data, which means that we won't see a
559
559
// FileNotFoundException until read is called. As a result, in order to find out if the object
@@ -674,8 +674,10 @@ public void deleteObjects(List<StorageResourceId> fullObjectNames)
674
674
675
675
// Validate that all the elements represent StorageObjects.
676
676
for (StorageResourceId fullObjectName : fullObjectNames ) {
677
- Preconditions .checkArgument (fullObjectName .isStorageObject (),
678
- "Expected full StorageObject names only, got: " + fullObjectName .toString ());
677
+ Preconditions .checkArgument (
678
+ fullObjectName .isStorageObject (),
679
+ "Expected full StorageObject names only, got: %s" ,
680
+ fullObjectName );
679
681
}
680
682
681
683
// Gather exceptions to wrap in a composite exception at the end.
@@ -1335,11 +1337,12 @@ public static GoogleCloudStorageItemInfo createItemInfoForBucket(
1335
1337
StorageResourceId resourceId , Bucket bucket ) {
1336
1338
Preconditions .checkArgument (resourceId != null , "resourceId must not be null" );
1337
1339
Preconditions .checkArgument (bucket != null , "bucket must not be null" );
1338
- Preconditions .checkArgument (resourceId .isBucket (),
1339
- String .format ("resourceId must be a Bucket. resourceId: %s" , resourceId ));
1340
- Preconditions .checkArgument (resourceId .getBucketName ().equals (bucket .getName ()),
1341
- String .format ("resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'" ,
1342
- resourceId .getBucketName (), bucket .getName ()));
1340
+ Preconditions .checkArgument (
1341
+ resourceId .isBucket (), "resourceId must be a Bucket. resourceId: %s" , resourceId );
1342
+ Preconditions .checkArgument (
1343
+ resourceId .getBucketName ().equals (bucket .getName ()),
1344
+ "resourceId.getBucketName() must equal bucket.getName(): '%s' vs '%s'" ,
1345
+ resourceId .getBucketName (), bucket .getName ());
1343
1346
1344
1347
// For buckets, size is 0.
1345
1348
return new GoogleCloudStorageItemInfo (resourceId , bucket .getTimeCreated ().getValue (),
@@ -1353,14 +1356,18 @@ public static GoogleCloudStorageItemInfo createItemInfoForStorageObject(
1353
1356
StorageResourceId resourceId , StorageObject object ) {
1354
1357
Preconditions .checkArgument (resourceId != null , "resourceId must not be null" );
1355
1358
Preconditions .checkArgument (object != null , "object must not be null" );
1356
- Preconditions .checkArgument (resourceId .isStorageObject (),
1357
- String .format ("resourceId must be a StorageObject. resourceId: %s" , resourceId ));
1358
- Preconditions .checkArgument (resourceId .getBucketName ().equals (object .getBucket ()),
1359
- String .format ("resourceId.getBucketName() must equal object.getBucket(): '%s' vs '%s'" ,
1360
- resourceId .getBucketName (), object .getBucket ()));
1361
- Preconditions .checkArgument (resourceId .getObjectName ().equals (object .getName ()),
1362
- String .format ("resourceId.getObjectName() must equal object.getName(): '%s' vs '%s'" ,
1363
- resourceId .getObjectName (), object .getName ()));
1359
+ Preconditions .checkArgument (
1360
+ resourceId .isStorageObject (),
1361
+ "resourceId must be a StorageObject. resourceId: %s" ,
1362
+ resourceId );
1363
+ Preconditions .checkArgument (
1364
+ resourceId .getBucketName ().equals (object .getBucket ()),
1365
+ "resourceId.getBucketName() must equal object.getBucket(): '%s' vs '%s'" ,
1366
+ resourceId .getBucketName (), object .getBucket ());
1367
+ Preconditions .checkArgument (
1368
+ resourceId .getObjectName ().equals (object .getName ()),
1369
+ "resourceId.getObjectName() must equal object.getName(): '%s' vs '%s'" ,
1370
+ resourceId .getObjectName (), object .getName ());
1364
1371
1365
1372
Map <String , byte []> decodedMetadata =
1366
1373
object .getMetadata () == null ? null : decodeMetadata (object .getMetadata ());
@@ -1515,15 +1522,18 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
1515
1522
// Assemble the return list in the same order as the input arguments.
1516
1523
List <GoogleCloudStorageItemInfo > sortedItemInfos = new ArrayList <>();
1517
1524
for (StorageResourceId resourceId : resourceIds ) {
1518
- Preconditions .checkState (itemInfos .containsKey (resourceId ),
1519
- String .format ("Somehow missing resourceId '%s' from map: %s" , resourceId , itemInfos ));
1525
+ Preconditions .checkState (
1526
+ itemInfos .containsKey (resourceId ),
1527
+ "Somehow missing resourceId '%s' from map: %s" ,
1528
+ resourceId , itemInfos );
1520
1529
sortedItemInfos .add (itemInfos .get (resourceId ));
1521
1530
}
1522
1531
1523
1532
// We expect the return list to be the same size, even if some entries were "not found".
1524
- Preconditions .checkState (sortedItemInfos .size () == resourceIds .size (), String .format (
1525
- "sortedItemInfos.size() (%d) != resourceIds.size() (%d). infos: %s, ids: %s" ,
1526
- sortedItemInfos .size (), resourceIds .size (), sortedItemInfos , resourceIds ));
1533
+ Preconditions .checkState (
1534
+ sortedItemInfos .size () == resourceIds .size (),
1535
+ "sortedItemInfos.size() (%s) != resourceIds.size() (%s). infos: %s, ids: %s" ,
1536
+ sortedItemInfos .size (), resourceIds .size (), sortedItemInfos , resourceIds );
1527
1537
return sortedItemInfos ;
1528
1538
}
1529
1539
@@ -1589,18 +1599,18 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
1589
1599
// Assemble the return list in the same order as the input arguments.
1590
1600
List <GoogleCloudStorageItemInfo > sortedItemInfos = new ArrayList <>();
1591
1601
for (UpdatableItemInfo itemInfo : itemInfoList ) {
1592
- Preconditions .checkState (resultItemInfos .containsKey (itemInfo .getStorageResourceId ()),
1593
- String .format (
1594
- "Missing resourceId '%s' from map: %s" ,
1595
- itemInfo .getStorageResourceId (),
1596
- resultItemInfos ));
1602
+ Preconditions .checkState (
1603
+ resultItemInfos .containsKey (itemInfo .getStorageResourceId ()),
1604
+ "Missing resourceId '%s' from map: %s" ,
1605
+ itemInfo .getStorageResourceId (), resultItemInfos );
1597
1606
sortedItemInfos .add (resultItemInfos .get (itemInfo .getStorageResourceId ()));
1598
1607
}
1599
1608
1600
1609
// We expect the return list to be the same size, even if some entries were "not found".
1601
- Preconditions .checkState (sortedItemInfos .size () == itemInfoList .size (), String .format (
1602
- "sortedItemInfos.size() (%d) != resourceIds.size() (%d). infos: %s, updateItemInfos: %s" ,
1603
- sortedItemInfos .size (), itemInfoList .size (), sortedItemInfos , itemInfoList ));
1610
+ Preconditions .checkState (
1611
+ sortedItemInfos .size () == itemInfoList .size (),
1612
+ "sortedItemInfos.size() (%s) != resourceIds.size() (%s). infos: %s, updateItemInfos: %s" ,
1613
+ sortedItemInfos .size (), itemInfoList .size (), sortedItemInfos , itemInfoList );
1604
1614
return sortedItemInfos ;
1605
1615
}
1606
1616
@@ -1733,8 +1743,8 @@ IOException wrapException(IOException e, String message,
1733
1743
private StorageObject getObject (StorageResourceId resourceId )
1734
1744
throws IOException {
1735
1745
LOG .debug ("getObject({})" , resourceId );
1736
- Preconditions .checkArgument (resourceId . isStorageObject (),
1737
- "Expected full StorageObject id, got " + resourceId );
1746
+ Preconditions .checkArgument (
1747
+ resourceId . isStorageObject (), "Expected full StorageObject id, got %s" , resourceId );
1738
1748
String bucketName = resourceId .getBucketName ();
1739
1749
String objectName = resourceId .getObjectName ();
1740
1750
StorageObject object = null ;
0 commit comments