xdocs: Fix a race condition in generating the temporary file name
TimeUtil.nowTs() has only millisecond resolution, so calling getNanos() on
it does not add any precision. With millisecond resolution it can happen
for a side-by-side diff that the same temporary file name is created for
the two files to compare, resulting in an exception like
com.google.common.util.concurrent.UncheckedExecutionException:
java.io.FileNotFoundException: [...]/xdocs/tmp/asciidoctor-891000000.tmp
(No such file or directory)
at com.google.common.cache.AbstractLoadingCache.getUnchecked(AbstractLoadingCache.java:55)
at com.googlesource.gerrit.plugins.xdocs.XDocCache.get(XDocCache.java:52)
at com.googlesource.gerrit.plugins.xdocs.XDocWebLink.getFileUrl(XDocWebLink.java:123)
at com.googlesource.gerrit.plugins.xdocs.XDocWebLink.getFileWebLink(XDocWebLink.java:92)
Fix this by letting Java determine a unique file name via
File.createTempFile() and let AsciiDoctor simply overwrite it.
Change-Id: Icf3843f8cd8c4c6f4ae10b3a8b264f2e52b72f89
1 file changed