Merge branch 'stable-2.11'

* stable-2.11:
  xdocs: Fix a race condition in generating the temporary file name

Change-Id: Ifa6317db83cfd154e47a2ee99e5d3513e7f278a3
diff --git a/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/AsciidoctorFormatter.java b/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/AsciidoctorFormatter.java
index 8bbe7a0..caa31c4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/AsciidoctorFormatter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/xdocs/formatter/AsciidoctorFormatter.java
@@ -75,8 +75,9 @@
         formatters.getFormatterConfig(NAME, projectName);
     // asciidoctor ignores all attributes if no output file is specified,
     // this is why we must specify an output file and then read its content
-    File tmpFile =
-        new File(baseDir, "tmp/asciidoctor-" + TimeUtil.nowTs().getNanos() + ".tmp");
+    File tmpDir = new File(baseDir, "tmp");
+    tmpDir.mkdirs();
+    File tmpFile = File.createTempFile("asciidoctor-", null, tmpDir);
     try {
       Asciidoctor.Factory.create(AsciidoctorFormatter.class.getClassLoader())
           .render(raw, createOptions(projectCfg, abbrRev, tmpFile));