summaryrefslogtreecommitdiffstats
path: root/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java')
-rw-r--r--gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
index a5bdacc77b..4a44348167 100644
--- a/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
+++ b/gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java
@@ -13,10 +13,12 @@ import com.google.common.hash.Funnels;
import com.google.common.hash.PrimitiveSink;
import com.google.inject.TypeLiteral;
+import org.h2.jdbc.JdbcSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.io.InvalidClassException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.sql.Connection;
@@ -390,6 +392,15 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> {
while (r.next()) {
b.put(keyType.get(r, 1));
}
+ } catch (JdbcSQLException e) {
+ if (e.getCause() instanceof InvalidClassException) {
+ log.warn("Entries cached for " + url
+ + " have an incompatible class and can't be deserialized. "
+ + "Cache is flushed.");
+ invalidateAll();
+ } else {
+ throw e;
+ }
} finally {
r.close();
}