Skip to content

Commit 943eed2

Browse files
committed
Don't explicitly call toString method when logging.
Change on 2017/12/14 by idv <[email protected]> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179086674
1 parent 515a90f commit 943eed2

File tree

3 files changed

+66
-55
lines changed

3 files changed

+66
-55
lines changed

gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageFileSystem.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ public FileInfo getFileInfo(URI path)
10981098
// If the given file does not exist, see if a directory of
10991099
// the same name exists.
11001100
StorageResourceId newResourceId = FileInfo.convertToDirectoryPath(resourceId);
1101-
LOG.debug("getFileInfo({}) : not found. trying: {}", path, newResourceId.toString());
1101+
LOG.debug("getFileInfo({}) : not found. trying: {}", path, newResourceId);
11021102
GoogleCloudStorageItemInfo newItemInfo = gcs.getItemInfo(newResourceId);
11031103
// Only swap out the old not-found itemInfo if the "converted" itemInfo actually exists; if
11041104
// both forms do not exist, we will just go with the original non-converted itemInfo.
@@ -1119,8 +1119,7 @@ public FileInfo getFileInfo(URI path)
11191119
if (!FileInfo.isDirectory(itemInfo)) {
11201120
newResourceId = FileInfo.convertToDirectoryPath(resourceId);
11211121
}
1122-
LOG.debug("getFileInfo({}) : still not found, trying inferred: {}",
1123-
path, newResourceId.toString());
1122+
LOG.debug("getFileInfo({}) : still not found, trying inferred: {}", path, newResourceId);
11241123
GoogleCloudStorageItemInfo newItemInfo = getInferredItemInfo(resourceId);
11251124
if (newItemInfo.exists()) {
11261125
LOG.debug(
@@ -1243,7 +1242,7 @@ public List<FileInfo> getFileInfos(List<URI> paths)
12431242
*/
12441243
private List<FileInfo> getFileInfosRaw(List<URI> paths)
12451244
throws IOException {
1246-
LOG.debug("getFileInfosRaw({})", paths.toString());
1245+
LOG.debug("getFileInfosRaw({})", paths);
12471246
Preconditions.checkArgument(paths != null, "paths must not be null");
12481247

12491248
// First, parse all the URIs into StorageResourceIds while validating them.

gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageImpl.java

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -463,42 +463,55 @@ public void createEmptyObjects(
463463
final CountDownLatch latch = new CountDownLatch(resourceIds.size());
464464
for (final StorageResourceId resourceId : resourceIds) {
465465
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+
}
493513
}
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+
});
502515
}
503516

504517
try {
@@ -611,7 +624,7 @@ public void create(String bucketName, CreateBucketOptions options)
611624
@Override
612625
public void deleteBuckets(List<String> bucketNames)
613626
throws IOException {
614-
LOG.debug("deleteBuckets({})", bucketNames.toString());
627+
LOG.debug("deleteBuckets({})", bucketNames);
615628

616629
// Validate all the inputs first.
617630
for (String bucketName : bucketNames) {
@@ -657,7 +670,7 @@ public void deleteBuckets(List<String> bucketNames)
657670
@Override
658671
public void deleteObjects(List<StorageResourceId> fullObjectNames)
659672
throws IOException {
660-
LOG.debug("deleteObjects({})", fullObjectNames.toString());
673+
LOG.debug("deleteObjects({})", fullObjectNames);
661674

662675
// Validate that all the elements represent StorageObjects.
663676
for (StorageResourceId fullObjectName : fullObjectNames) {
@@ -699,8 +712,7 @@ private JsonBatchCallback<Void> getDeletionCallback(
699712
return new JsonBatchCallback<Void>() {
700713
@Override
701714
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);
704716
}
705717

706718
@Override
@@ -711,22 +723,22 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOE
711723
// receives the request but we get a retry-able error before we get a response.
712724
// During a retry, we no longer find the item because the server had deleted
713725
// it already.
714-
LOG.debug("deleteObjects({}) : delete not found", fullObjectName.toString());
726+
LOG.debug("deleteObjects({}) : delete not found", fullObjectName);
715727
} else if (errorExtractor.preconditionNotMet(e)
716728
&& attempt <= MAXIMUM_PRECONDITION_FAILURES_IN_DELETE) {
717729
LOG.info(
718730
"Precondition not met while deleting {} at generation {}. Attempt {}. Retrying.",
719731
fullObjectName.toString(),
720732
generation,
721733
attempt);
722-
queueSingleObjectDelete(
723-
fullObjectName, innerExceptions, batchHelper, attempt + 1);
734+
queueSingleObjectDelete(fullObjectName, innerExceptions, batchHelper, attempt + 1);
724735
} 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));
730742
}
731743
}
732744
};
@@ -774,7 +786,7 @@ public void onFailure(GoogleJsonError googleJsonError, HttpHeaders httpHeaders)
774786
if (errorExtractor.itemNotFound(googleJsonError)) {
775787
// If the item isn't found, treat it the same as if it's not found in the delete
776788
// 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);
778790
} else {
779791
innerExceptions.add(
780792
wrapException(
@@ -1432,7 +1444,7 @@ public static GoogleCloudStorageItemInfo createItemInfoForNotFound(StorageResour
14321444
@Override
14331445
public List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds)
14341446
throws IOException {
1435-
LOG.debug("getItemInfos({})", resourceIds.toString());
1447+
LOG.debug("getItemInfos({})", resourceIds);
14361448

14371449
final Map<StorageResourceId, GoogleCloudStorageItemInfo> itemInfos = new HashMap<>();
14381450
final List<IOException> innerExceptions = new ArrayList<>();
@@ -1518,7 +1530,7 @@ public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
15181530
@Override
15191531
public List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList)
15201532
throws IOException {
1521-
LOG.debug("updateItems({})", itemInfoList.toString());
1533+
LOG.debug("updateItems({})", itemInfoList);
15221534

15231535
final Map<StorageResourceId, GoogleCloudStorageItemInfo> resultItemInfos = new HashMap<>();
15241536
final List<IOException> innerExceptions = new ArrayList<>();

gcsio/src/main/java/com/google/cloud/hadoop/gcsio/MetadataReadOnlyGoogleCloudStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public List<GoogleCloudStorageItemInfo> listObjectInfo(
267267
@Override
268268
public List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds)
269269
throws IOException {
270-
LOG.debug("getItemInfos({})", resourceIds.toString());
270+
LOG.debug("getItemInfos({})", resourceIds);
271271
List<GoogleCloudStorageItemInfo> infos = new ArrayList<>();
272272
for (StorageResourceId resourceId : resourceIds) {
273273
infos.add(getItemInfo(resourceId));

0 commit comments

Comments
 (0)