Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-10-30 06:32:33 +0000
committerEike Stepper2012-10-30 06:32:33 +0000
commit67f5f89c73bc0061a373bc92cc05d8a6ebc777ae (patch)
tree9d9c4353f95c89c7f9ac229f2fcc825b26511d60
parentdba1cf4ec4f47020d1354297b57ba2617729790c (diff)
downloadcdo-67f5f89c73bc0061a373bc92cc05d8a6ebc777ae.tar.gz
cdo-67f5f89c73bc0061a373bc92cc05d8a6ebc777ae.tar.xz
cdo-67f5f89c73bc0061a373bc92cc05d8a6ebc777ae.zip
[393114] [DB] ClassCastException when starting CDO Server recovering
from crash, with Oracle DB https://bugs.eclipse.org/bugs/show_bug.cgi?id=393114
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java54
2 files changed, 36 insertions, 26 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
index d54993c9fd..81d4407e1d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
@@ -352,9 +352,13 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
{
public boolean handle(int row, final Object... values)
{
+ int index = DBUtil.asInt(values[1]);
+ long timestamp = DBUtil.asLong(values[2]);
+
InternalCDOPackageUnit packageUnit = createPackageUnit();
- packageUnit.setOriginalType(CDOPackageUnit.Type.values()[(Integer)values[1]]);
- packageUnit.setTimeStamp((Long)values[2]);
+ packageUnit.setOriginalType(CDOPackageUnit.Type.values()[index]);
+ packageUnit.setTimeStamp(timestamp);
+
packageUnits.put((String)values[0], packageUnit);
return true;
}
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 e33b30df23..2468a7f0dd 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
@@ -414,31 +414,47 @@ public final class DBUtil
}
/**
- * @since 3.0
+ * @since 4.2
*/
- public static int selectMinimumInt(Connection connection, IDBField field, String... where) throws DBException
+ public static int asInt(Object value)
{
- Number number = getFunctionResult(connection, field, "MIN", where); //$NON-NLS-1$
- if (number == null)
+ if (value instanceof Number)
{
- return 0;
+ return ((Number)value).intValue();
}
- return number.intValue();
+ return 0;
}
/**
- * @since 3.0
+ * @since 4.2
*/
- public static long selectMinimumLong(Connection connection, IDBField field, String... where) throws DBException
+ public static long asLong(Object value)
{
- Number number = getFunctionResult(connection, field, "MIN", where); //$NON-NLS-1$
- if (number == null)
+ if (value instanceof Number)
{
- return 0;
+ return ((Number)value).longValue();
}
- return number.longValue();
+ return 0L;
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static int selectMinimumInt(Connection connection, IDBField field, String... where) throws DBException
+ {
+ Number number = getFunctionResult(connection, field, "MIN", where); //$NON-NLS-1$
+ return asInt(number);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static long selectMinimumLong(Connection connection, IDBField field, String... where) throws DBException
+ {
+ Number number = getFunctionResult(connection, field, "MIN", where); //$NON-NLS-1$
+ return asLong(number);
}
/**
@@ -447,12 +463,7 @@ public final class DBUtil
public static int selectMaximumInt(Connection connection, IDBField field, String... where) throws DBException
{
Number number = getFunctionResult(connection, field, "MAX", where); //$NON-NLS-1$
- if (number == null)
- {
- return 0;
- }
-
- return number.intValue();
+ return asInt(number);
}
/**
@@ -461,12 +472,7 @@ public final class DBUtil
public static long selectMaximumLong(Connection connection, IDBField field, String... where) throws DBException
{
Number number = getFunctionResult(connection, field, "MAX", where); //$NON-NLS-1$
- if (number == null)
- {
- return 0;
- }
-
- return number.longValue();
+ return asLong(number);
}
private static Number getFunctionResult(Connection connection, IDBField field, String function, String... where)

Back to the top