Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-12 04:27:04 -0400
committerEike Stepper2013-03-12 04:27:04 -0400
commitcb7c825bc51e11e05faa66a0636c381b1d43c30d (patch)
tree70334743deae3e7e613a3bf0e050472a27f0f9eb
parent04de0cff4590a8df809e26769bff8e6edaa62811 (diff)
downloadcdo-cb7c825bc51e11e05faa66a0636c381b1d43c30d.tar.gz
cdo-cb7c825bc51e11e05faa66a0636c381b1d43c30d.tar.xz
cdo-cb7c825bc51e11e05faa66a0636c381b1d43c30d.zip
[401763] Make CDO Server more robust against data dictionary changes drops/S20130312-0531drops/I20130312-0633
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java12
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java12
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java6
3 files changed, 23 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index f2e85abdf1..3bd14d1340 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -620,8 +620,16 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
database = DBUtil.openDatabase(dbAdapter, dbConnectionProvider, repository.getName());
IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
- schemaTransaction.ensureSchema(CDODBSchema.INSTANCE);
- schemaTransaction.commit();
+
+ try
+ {
+ schemaTransaction.ensureSchema(CDODBSchema.INSTANCE);
+ schemaTransaction.commit();
+ }
+ finally
+ {
+ schemaTransaction.close();
+ }
LifecycleUtil.activate(idHandler);
LifecycleUtil.activate(metaDataManager);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index ea485c7c4b..8f1106166a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -40,8 +40,10 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
* A utility class with various static factory and convenience methods.
@@ -387,7 +389,7 @@ public final class DBUtil
@Deprecated
public static List<String> getAllSchemaTableNames(DatabaseMetaData metaData)
{
- return getAllSchemaNames(metaData);
+ return new ArrayList<String>(getAllSchemaNames(metaData));
}
/**
@@ -398,7 +400,7 @@ public final class DBUtil
try
{
DatabaseMetaData metaData = connection.getMetaData();
- return getAllSchemaNames(metaData);
+ return new ArrayList<String>(getAllSchemaNames(metaData));
}
catch (SQLException ex)
{
@@ -409,13 +411,13 @@ public final class DBUtil
/**
* @since 4.2
*/
- public static List<String> getAllSchemaNames(DatabaseMetaData metaData)
+ public static Set<String> getAllSchemaNames(DatabaseMetaData metaData)
{
ResultSet schemas = null;
try
{
- List<String> names = new ArrayList<String>();
+ Set<String> names = new HashSet<String>();
schemas = metaData.getSchemas();
while (schemas.next())
{
@@ -446,7 +448,7 @@ public final class DBUtil
if (dbName != null)
{
dbName = dbName.toUpperCase();
- List<String> schemaNames = getAllSchemaNames(metaData);
+ Set<String> schemaNames = getAllSchemaNames(metaData);
if (!schemaNames.contains(dbName))
{
dbName = null;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index d111d42838..ca043bc934 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -152,6 +152,12 @@ public abstract class DBAdapter implements IDBAdapter
String schemaName = schema.getName();
DatabaseMetaData metaData = connection.getMetaData();
+ Set<String> schemaNames = DBUtil.getAllSchemaNames(metaData);
+ if (!schemaNames.contains(schemaName))
+ {
+ schemaName = null;
+ }
+
ResultSet tables = metaData.getTables(null, schemaName, null, new String[] { "TABLE" });
while (tables.next())
{

Back to the top