From e8d864c004ef88b79eab5886c173c0e7d5c95d2d Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Thu, 19 Dec 2013 23:33:38 +0000
Subject: [PATCH] Throw DbException if database encryption key is missing.

This can happen on Android if the app is automatically restarted after a
crash.
---
 briar-core/src/net/sf/briar/db/H2Database.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/briar-core/src/net/sf/briar/db/H2Database.java b/briar-core/src/net/sf/briar/db/H2Database.java
index d0dfa1da65..a9de1ad248 100644
--- a/briar-core/src/net/sf/briar/db/H2Database.java
+++ b/briar-core/src/net/sf/briar/db/H2Database.java
@@ -78,7 +78,7 @@ class H2Database extends JdbcDatabase {
 
 	protected Connection createConnection() throws SQLException {
 		byte[] key = config.getEncryptionKey();
-		if(key == null) throw new IllegalStateException();
+		if(key == null) return null;
 		char[] password = encodePassword(key);
 		Properties props = new Properties();
 		props.setProperty("user", "user");
-- 
GitLab