Merge branch 'stable-2.15' * stable-2.15: Adapt to the latest Gerrit on stable-2.14 Change-Id: Idc88756deaa419c4ecdfc5663fcd58c14872f941
diff --git a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java index 0d29720..969ccef 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java +++ b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCache.java
@@ -17,6 +17,7 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheStats; import com.google.common.collect.ImmutableMap; +import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import com.google.gerrit.httpd.WebSessionManager; import com.google.gerrit.httpd.WebSessionManager.Val; @@ -43,12 +44,10 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; @Singleton public class FlatFileWebSessionCache implements Cache<String, WebSessionManager.Val> { - private static final Logger log = LoggerFactory.getLogger(FlatFileWebSessionCache.class); + private static final FluentLogger log = FluentLogger.forEnclosingClass(); /** Provides static methods to set the system clock for testing purposes only. */ static class TimeMachine { @@ -178,7 +177,7 @@ StandardCopyOption.ATOMIC_MOVE); } } catch (IOException e) { - log.warn("Cannot put into cache " + websessionsDir, e); + log.atWarning().withCause(e).log("Cannot put into cache %s", websessionsDir); } } @@ -196,7 +195,7 @@ @Override public CacheStats stats() { - log.warn("stats() unimplemented"); + log.atWarning().log("stats() unimplemented"); return null; } @@ -206,16 +205,14 @@ ObjectInputStream objStream = new ObjectInputStream(fileStream)) { return (Val) objStream.readObject(); } catch (ClassNotFoundException e) { - log.warn( - "Entry " - + path - + " in cache " - + websessionsDir - + " has an incompatible " - + "class and can't be deserialized. Invalidating entry."); + log.atWarning().log( + "Entry %s in cache %s has an incompatible class and can't be" + + " deserialized. Invalidating entry.", + path, websessionsDir); + log.atFine().withCause(e).log(e.getMessage()); invalidate(path.getFileName().toString()); } catch (IOException e) { - log.warn("Cannot read cache " + websessionsDir, e); + log.atWarning().withCause(e).log("Cannot read cache %s", websessionsDir); } } return null; @@ -225,7 +222,7 @@ try { Files.deleteIfExists(path); } catch (IOException e) { - log.error("Error trying to delete " + path + " from " + websessionsDir, e); + log.atSevere().withCause(e).log("Error trying to delete %s from %s", path, websessionsDir); } } @@ -236,7 +233,7 @@ files.add(path); } } catch (IOException e) { - log.error("Cannot list files in cache " + websessionsDir, e); + log.atSevere().withCause(e).log("Cannot list files in cache %s", websessionsDir); } return files; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCacheCleaner.java b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCacheCleaner.java index 5c88f92..64d1e70 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCacheCleaner.java +++ b/src/main/java/com/googlesource/gerrit/plugins/websession/flatfile/FlatFileWebSessionCacheCleaner.java
@@ -17,6 +17,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; +import com.google.common.flogger.FluentLogger; import com.google.gerrit.extensions.annotations.PluginName; import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.server.git.WorkQueue; @@ -34,6 +35,7 @@ private ScheduledFuture<?> scheduledCleanupTask; static class CleanupTask implements Runnable { + private static final FluentLogger log = FluentLogger.forEnclosingClass(); private final FlatFileWebSessionCache flatFileWebSessionCache; private final String pluginName; @@ -45,7 +47,9 @@ @Override public void run() { + log.atInfo().log("Cleaning up expired file based websessions..."); flatFileWebSessionCache.cleanUp(); + log.atInfo().log("Cleaning up expired file based websessions...Done"); } @Override
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index 7e87215..e4ce302 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -24,7 +24,7 @@ The output is created in ``` - bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar + bazel-bin/plugins/@PLUGIN@/@PLUGIN@.jar ``` This project can be imported into the Eclipse IDE.