diff options
author | Shawn O. Pearce <sop@google.com> | 2012-10-16 12:09:33 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-10-16 12:13:32 -0700 |
commit | 7dd18f5f2c14ad470c87190c60562f5d1ad49226 (patch) | |
tree | 8d35de5ae0ccf22e595ca14ea40a70dc84f935c0 /gerrit-cache-h2 | |
parent | 02e94fc6c61fc7efa87f15121acdce41989d5c2b (diff) | |
parent | b2b6bf3c1e506c2be670f9ba3c2db2e3cb551443 (diff) |
Merge branch 'stable-2.5'
* stable-2.5:
Fix order of top-level menus
Ensure that ObjectOutputStream in H2CacheImpl is closed
Flush persistent H2 cache if the existing entries are incompatible
Fix plugin loading when running as hosted WAR or GWT DevMode.
ChangeMessageAccess: Add index for byPathSet method.
File indentation is sometimes wrong in Side-By-Side
Move the Groups and Plugins menu items to the top level.
Call inserter.flush() when creating code review notes
Add ssh command "test-submit-rule"
Split up canSubmit()
Add submit records to query output.
Conflicts:
Documentation/json.txt
gerrit-gwtui/src/main/java/com/google/gerrit/client/Gerrit.java
gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java
Change-Id: I6f9d44cfbd7060d65c8eb8a399d089a88f9bc697
Diffstat (limited to 'gerrit-cache-h2')
-rw-r--r-- | gerrit-cache-h2/src/main/java/com/google/gerrit/server/cache/h2/H2CacheImpl.java | 19 |
1 files changed, 17 insertions, 2 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..a196b07054 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; @@ -277,8 +279,12 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> { try { ObjectOutputStream ser = new ObjectOutputStream(new SinkOutputStream(into)); - ser.writeObject(from); - ser.flush(); + try { + ser.writeObject(from); + ser.flush(); + } finally { + ser.close(); + } } catch (IOException err) { throw new RuntimeException("Cannot hash as Serializable", err); } @@ -390,6 +396,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(); } |