Fix 'illegal format conversion' compilation error
Using '{}' instead of '%s' to format objects causes a compilation error.
Refactor code to use '%s' instead of '{}' to format log message.
Bug: Issue 15883
Change-Id: Ia4f4d0984b7d1444c0669c0bc0ef5621d2dd3b47
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/DeleteProjectTask.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/DeleteProjectTask.java
index 44c6556..527b746 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/DeleteProjectTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/DeleteProjectTask.java
@@ -63,7 +63,7 @@
if (!httpResult.isSuccessful()) {
throw new IOException(httpResult.getMessage().orElse("Unknown"));
}
- logger.atFine().log("Successfully deleted project {} on remote {}", project.get(), uri);
+ logger.atFine().log("Successfully deleted project %s on remote %s", project.get(), uri);
} catch (URISyntaxException | IOException e) {
String errorMessage =
String.format("Cannot delete project %s on remote site %s.", project, uri);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
index 28aa541..71ec666 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -775,7 +775,7 @@
updateHeadFactory.create(this, apiURI, project, newHead), 0, TimeUnit.SECONDS);
} catch (URISyntaxException e) {
logger.atSevere().withCause(e).log(
- "Could not schedule HEAD pull-replication for project {}", project.get());
+ "Could not schedule HEAD pull-replication for project %s", project.get());
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/UpdateHeadTask.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/UpdateHeadTask.java
index bded7d1..e169eb3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/UpdateHeadTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/UpdateHeadTask.java
@@ -65,9 +65,8 @@
throw new IOException(httpResult.getMessage().orElse("Unknown"));
}
logger.atFine().log(
- "Successfully updated HEAD of project {} on remote {}",
- project.get(),
- apiURI.toASCIIString());
+ "Successfully updated HEAD of project %s on remote %s",
+ project.get(), apiURI.toASCIIString());
} catch (IOException e) {
String errorMessage =
String.format(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java
index 01635e6..3426c03 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java
@@ -109,7 +109,7 @@
Optional<URIish> maybeUri = gerritConfigOps.getGitRepositoryURI(projectName);
if (!maybeUri.isPresent()) {
- logger.atSevere().log("Cannot initialize project '{}'", projectName);
+ logger.atSevere().log("Cannot initialize project '%s'", projectName);
return false;
}
LocalFS localFS = new LocalFS(maybeUri.get());