Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-06 10:03:45 -0500
committerEike Stepper2013-03-07 08:44:51 -0500
commited8cc36a13e647f7841ee33fb84c8cb3aa309cd2 (patch)
tree97e9028bf82b0001dd23c8cccc4ec8145f9741b1
parent8ca05d4d1e64f58208b1390ad03a2176ade9121a (diff)
downloadcdo-ed8cc36a13e647f7841ee33fb84c8cb3aa309cd2.tar.gz
cdo-ed8cc36a13e647f7841ee33fb84c8cb3aa309cd2.tar.xz
cdo-ed8cc36a13e647f7841ee33fb84c8cb3aa309cd2.zip
[401763] Make CDO Server more robust against data dictionary changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java43
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java6
3 files changed, 51 insertions, 2 deletions
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
index 7e3bcda220..b0f0c066d9 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
@@ -40,6 +40,15 @@ public class DBField extends DBSchemaElement implements IDBField
public static final int DEFAULT_VARCHAR_LENGTH = 255;
+ private static final ThreadLocal<Boolean> TRACK_CONSTRUCTION = new InheritableThreadLocal<Boolean>()
+ {
+ @Override
+ protected Boolean initialValue()
+ {
+ return true;
+ }
+ };
+
private static final long serialVersionUID = 1L;
private DBTable table;
@@ -54,6 +63,11 @@ public class DBField extends DBSchemaElement implements IDBField
private int position;
+ /**
+ * Tracks the construction stack trace to provide better debug infos in DBTable.addIndex().
+ */
+ private transient Exception constructionStackTrace;
+
public DBField(DBTable table, String name, DBType type, int precision, int scale, boolean notNull, int position)
{
super(name);
@@ -63,6 +77,18 @@ public class DBField extends DBSchemaElement implements IDBField
this.scale = scale;
this.notNull = notNull;
this.position = position;
+
+ if (TRACK_CONSTRUCTION.get() == Boolean.TRUE)
+ {
+ try
+ {
+ throw new Exception("The field " + this + " has been constructed here:");
+ }
+ catch (Exception ex)
+ {
+ constructionStackTrace = ex;
+ }
+ }
}
/**
@@ -204,6 +230,11 @@ public class DBField extends DBSchemaElement implements IDBField
return "(" + getPrecision() + ", " + getScale() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+ public Exception getConstructionStackTrace()
+ {
+ return constructionStackTrace;
+ }
+
@Override
protected void collectElements(List<IDBSchemaElement> elements)
{
@@ -233,4 +264,16 @@ public class DBField extends DBSchemaElement implements IDBField
{
table.getSchema().assertUnlocked();
}
+
+ public static void trackConstruction(boolean on)
+ {
+ if (on)
+ {
+ TRACK_CONSTRUCTION.set(true);
+ }
+ else
+ {
+ TRACK_CONSTRUCTION.remove();
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
index 9eacac3886..9cc7c31681 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBIndex.java
@@ -106,9 +106,9 @@ public class DBIndex extends DBSchemaElement implements IDBIndex
{
assertUnlocked();
- if (!field.isNotNull())
+ if (type != Type.NON_UNIQUE && !field.isNotNull())
{
- throw new DBException("Index field is nullable: " + field); //$NON-NLS-1$
+ throw new DBException("Index field is nullable: " + field, ((DBField)field).getConstructionStackTrace()); //$NON-NLS-1$
}
if (field.getTable() != table)
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 5c88775b04..f678542cb9 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
@@ -25,6 +25,7 @@ import org.eclipse.net4j.db.ddl.delta.IDBIndexDelta;
import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
import org.eclipse.net4j.db.ddl.delta.IDBTableDelta;
import org.eclipse.net4j.internal.db.bundle.OM;
+import org.eclipse.net4j.internal.db.ddl.DBField;
import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -149,6 +150,7 @@ public abstract class DBAdapter implements IDBAdapter
{
try
{
+ DBField.trackConstruction(false);
String schemaName = schema.getName();
DatabaseMetaData metaData = connection.getMetaData();
@@ -166,6 +168,10 @@ public abstract class DBAdapter implements IDBAdapter
{
throw new DBException(ex);
}
+ finally
+ {
+ DBField.trackConstruction(true);
+ }
}
/**

Back to the top