Merge branch 'stable-2.15'

* stable-2.15:
  Log a warning when a hook exits with error status
  Include hook name in error message when logging output failed
  Log a warning when a hook times out
  Use Logger's built-in string formatting

Change-Id: Iac58aca64c9699f28ea105850e9fdefbea1e3e64
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
index 73b5ff5..06b664b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
@@ -49,7 +49,7 @@
     args.add("--project", projectName);
     args.add("--refname", refname);
     args.add("--uploader", receiveEvent.user.getNameEmail());
-    args.add("--uploader-username", receiveEvent.user.getUserName());
+    args.add("--uploader-username", receiveEvent.user.getUserName().orElse(null));
     args.add("--oldrev", old.name());
     args.add("--newrev", receiveEvent.commit.name());
     args.add("--cmdref", commandRef);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
index 5840874..36ab171 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
@@ -47,7 +47,7 @@
     HookArgs args = hookFactory.createArgs();
     args.add("--project", projectName);
     args.add("--uploader", refEvent.user.getNameEmail());
-    args.add("--uploader-username", refEvent.user.getUserName());
+    args.add("--uploader-username", refEvent.user.getUserName().orElse(null));
     args.add("--oldrev", getObjectId(refEvent.command.getOldId()).getName());
     args.add("--newrev", getObjectId(refEvent.command.getNewId()).getName());
     args.add("--refname", refEvent.command.getRefName());