Author: shawkins
Date: 2012-09-03 07:25:19 -0400 (Mon, 03 Sep 2012)
New Revision: 4394
Modified:
trunk/client/src/main/java/org/teiid/client/BatchSerializer.java
trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java
trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
trunk/common-core/src/main/java/org/teiid/core/types/ArrayImpl.java
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestArray.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
Log:
TEIID-247 adding better array serialization
Modified: trunk/client/src/main/java/org/teiid/client/BatchSerializer.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/BatchSerializer.java 2012-09-01 11:34:08
UTC (rev 4393)
+++ trunk/client/src/main/java/org/teiid/client/BatchSerializer.java 2012-09-03 11:25:19
UTC (rev 4394)
@@ -29,6 +29,8 @@
import java.io.ObjectStreamConstants;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.sql.Array;
+import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -40,6 +42,7 @@
import java.util.TimeZone;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.ArrayImpl;
import org.teiid.core.types.BinaryType;
import org.teiid.core.types.BlobType;
import org.teiid.core.types.ClobType;
@@ -54,43 +57,117 @@
*/
public class BatchSerializer {
- private BatchSerializer() {} // Uninstantiable
+ private static final byte CURRENT_VERSION = (byte)2;
+
+ private BatchSerializer() {} // Uninstantiable
private static ColumnSerializer defaultSerializer = new ColumnSerializer();
- private static final Map<String, ColumnSerializer> serializers = new
HashMap<String, ColumnSerializer>(128);
+ private static final Map<String, ColumnSerializer[]> serializers = new
HashMap<String, ColumnSerializer[]>(128);
static {
- serializers.put(DataTypeManager.DefaultDataTypes.BIG_DECIMAL, new
BigDecimalColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new
BigIntegerColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.BOOLEAN, new
BooleanColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.BYTE, new
ByteColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.CHAR, new
CharColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.DATE, new
DateColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.DOUBLE, new
DoubleColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.FLOAT, new
FloatColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.INTEGER, new
IntColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.LONG, new
LongColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.SHORT, new
ShortColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.TIME, new
TimeColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new
TimestampColumnSerializer());
- serializers.put(DataTypeManager.DefaultDataTypes.VARBINARY, new
BinaryColumnSerializer());
+ serializers.put(DataTypeManager.DefaultDataTypes.BIG_DECIMAL, new
ColumnSerializer[] {new BigDecimalColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new
ColumnSerializer[] {new BigIntegerColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.BOOLEAN, new
ColumnSerializer[] {new BooleanColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.BYTE, new
ColumnSerializer[] {new ByteColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.CHAR, new
ColumnSerializer[] {new CharColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.DATE, new
ColumnSerializer[] {new DateColumnSerializer(), new DateColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.DOUBLE, new
ColumnSerializer[] {new DoubleColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.FLOAT, new
ColumnSerializer[] {new FloatColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.INTEGER, new
ColumnSerializer[] {new IntColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.LONG, new
ColumnSerializer[] {new LongColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.SHORT, new
ColumnSerializer[] {new ShortColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.TIME, new
ColumnSerializer[] {new TimeColumnSerializer(), new TimeColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new
ColumnSerializer[] {new TimestampColumnSerializer()});
+ serializers.put(DataTypeManager.DefaultDataTypes.STRING, new
ColumnSerializer[] {defaultSerializer, new StringColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.CLOB, new
ColumnSerializer[] {defaultSerializer, new ClobColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.BLOB, new
ColumnSerializer[] {defaultSerializer, new BlobColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.XML, new
ColumnSerializer[] {defaultSerializer, new XmlColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.NULL, new
ColumnSerializer[] {defaultSerializer, new NullColumnSerializer1()});
+ serializers.put(DataTypeManager.DefaultDataTypes.OBJECT, new
ColumnSerializer[] {defaultSerializer, new
ObjectColumnSerializer(DataTypeManager.DefaultTypeCodes.VARBINARY, (byte)1)});
+ serializers.put(DataTypeManager.DefaultDataTypes.VARBINARY, new
ColumnSerializer[] {new BinaryColumnSerializer(), new BinaryColumnSerializer1()});
}
- private static final Map<String, ColumnSerializer> version1serializers = new
HashMap<String, ColumnSerializer>(128);
- static {
- version1serializers.put(DataTypeManager.DefaultDataTypes.DATE, new
DateColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.TIME, new
TimeColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.STRING, new
StringColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.CLOB, new
ClobColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.BLOB, new
BlobColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.XML, new
XmlColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.NULL, new
NullColumnSerializer1());
- version1serializers.put(DataTypeManager.DefaultDataTypes.OBJECT, new
ObjectColumnSerializer1(DataTypeManager.DefaultTypeCodes.VARBINARY));
- version1serializers.put(DataTypeManager.DefaultDataTypes.VARBINARY, new
BinaryColumnSerializer1());
- }
+ private static ColumnSerializer arrayColumnSerializer = new ColumnSerializer() {
+
+ @Override
+ protected void writeObject(ObjectOutput out, Object obj)
+ throws IOException {
+ try {
+ super.writeObject(out, ((java.sql.Array)obj).getArray());
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ protected Object readObject(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ return new ArrayImpl((Object[]) in.readObject());
+ }
+
+ };
- static class BinaryColumnSerializer1 extends ColumnSerializer {
+ private static final ColumnSerializer arrayColumnSerialier2 = new
ArrayColumnSerializer2(new
ObjectColumnSerializer(DataTypeManager.DefaultTypeCodes.VARBINARY, (byte)2));
+
+ private static final class ArrayColumnSerializer2 extends ColumnSerializer {
+
+ ObjectColumnSerializer ser;
+
+ public ArrayColumnSerializer2(ObjectColumnSerializer ser) {
+ this.ser = ser;
+ }
+
@Override
+ protected void writeObject(ObjectOutput out, Object obj)
+ throws IOException {
+ Object[] values = null;
+ try {
+ values = (Object[]) ((Array)obj).getArray();
+ } catch (SQLException e) {
+ out.writeInt(-1);
+ return;
+ }
+ out.writeInt(values.length);
+ int code = DataTypeManager.getTypeCode(values.getClass().getComponentType());
+ out.writeByte((byte)code);
+ for (int i = 0; i < values.length;) {
+ writeIsNullData(out, i, values);
+ int end = Math.min(values.length, i+8);
+ for (; i < end; i++) {
+ if (values[i] != null) {
+ ser.writeObject(out, values[i], code);
+ }
+ }
+ }
+ out.writeBoolean((obj instanceof ArrayImpl &&
((ArrayImpl)obj).isZeroBased()));
+ }
+
+ @Override
+ protected Object readObject(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ int length = in.readInt();
+ if (length == -1) {
+ return new ArrayImpl(null);
+ }
+ int code = in.readByte();
+ Object[] vals =
(Object[])java.lang.reflect.Array.newInstance(DataTypeManager.getClass(code), length);
+ for (int i = 0; i < length;) {
+ byte b = in.readByte();
+ int end = Math.min(length, i+8);
+ for (; i < end; i++) {
+ if (!isNullObject(i, b)) {
+ vals[i] = ser.readObject(in, code);
+ }
+ }
+ }
+ ArrayImpl result = new ArrayImpl(vals);
+ result.setZeroBased(in.readBoolean());
+ return result;
+ }
+ }
+
+ static class BinaryColumnSerializer1 extends ColumnSerializer {
+ @Override
protected void writeObject(ObjectOutput out, Object obj)
throws IOException {
byte[] bytes = ((BinaryType)obj).getBytes();
@@ -125,12 +202,14 @@
}
}
- public static final class ObjectColumnSerializer1 extends ColumnSerializer {
+ public static final class ObjectColumnSerializer extends ColumnSerializer {
int highestKnownCode;
+ byte version;
- public ObjectColumnSerializer1(int highestKnownCode) {
+ public ObjectColumnSerializer(int highestKnownCode, byte version) {
this.highestKnownCode = highestKnownCode;
+ this.version = version;
}
@Override
@@ -138,14 +217,19 @@
throws IOException {
int code = DataTypeManager.getTypeCode(obj.getClass());
out.writeByte((byte)code);
- if (code == DataTypeManager.DefaultTypeCodes.BOOLEAN) {
+ writeObject(out, obj, code);
+ }
+
+ protected void writeObject(ObjectOutput out, Object obj, int code)
+ throws IOException {
+ if (code == DataTypeManager.DefaultTypeCodes.BOOLEAN) {
if (Boolean.TRUE.equals(obj)) {
out.write((byte)1);
} else {
out.write((byte)0);
}
} else if (code <= highestKnownCode && code !=
DataTypeManager.DefaultTypeCodes.OBJECT) {
- ColumnSerializer s =
getSerializer(DataTypeManager.getDataTypeName(obj.getClass()), (byte)1);
+ ColumnSerializer s =
getSerializer(DataTypeManager.getDataTypeName(obj.getClass()), version);
s.writeObject(out, obj);
} else {
super.writeObject(out, obj);
@@ -156,14 +240,19 @@
protected Object readObject(ObjectInput in) throws IOException,
ClassNotFoundException {
int code = in.readByte();
- if (code == DataTypeManager.DefaultTypeCodes.BOOLEAN) {
+ return readObject(in, code);
+ }
+
+ private Object readObject(ObjectInput in, int code) throws IOException,
+ ClassNotFoundException {
+ if (code == DataTypeManager.DefaultTypeCodes.BOOLEAN) {
if (in.readByte() == (byte)0) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
if (code != DataTypeManager.DefaultTypeCodes.OBJECT) {
- ColumnSerializer s =
getSerializer(DataTypeManager.getDataTypeName(DataTypeManager.getClass(code)), (byte)1);
+ ColumnSerializer s =
getSerializer(DataTypeManager.getDataTypeName(DataTypeManager.getClass(code)), version);
return s.readObject(in);
}
return super.readObject(in);
@@ -234,11 +323,11 @@
private static class XmlColumnSerializer1 extends ColumnSerializer {
protected void writeObject(ObjectOutput out, Object obj) throws IOException {
- ((XMLType)obj).writeExternal(out, (byte)1);
+ ((XMLType)obj).writeExternal(out, CURRENT_VERSION);
}
protected Object readObject(ObjectInput in) throws IOException,
ClassNotFoundException {
XMLType xt = new XMLType();
- xt.readExternal(in, (byte)1);
+ xt.readExternal(in, CURRENT_VERSION);
return xt;
}
}
@@ -273,6 +362,15 @@
out.write(currentByte);
}
}
+
+ static void writeIsNullData(ObjectOutput out, int offset, Object[] batch) throws
IOException {
+ int currentByte = 0;
+ for (int mask = 0x80; offset < batch.length; offset++, mask >>= 1) {
+ if (batch[offset] == null) currentByte |= mask;
+ }
+ out.write(currentByte);
+ }
+
/**
* Reads the isNull data into a byte array
* @param in
@@ -293,10 +391,14 @@
* @return
* @since 4.2
*/
- static boolean isNullObject(byte[] isNull, int row) {
+ static final boolean isNullObject(byte[] isNull, int row) {
// byte number mask bits to shift mask
return (isNull [ row / 8 ] & (0x01 << (7 - (row % 8)))) !=
0;
}
+
+ private static final boolean isNullObject(int row, byte b) {
+ return (b & (0x01 << (7 - (row % 8)))) != 0;
+ }
/**
* An abstract serializer for native types
@@ -556,21 +658,22 @@
}
private static ColumnSerializer getSerializer(String type, byte version) {
- ColumnSerializer cs = null;
- if (version == 1) {
- cs = version1serializers.get((type == null) ?
DataTypeManager.DefaultDataTypes.OBJECT : type);
+ ColumnSerializer[] sers = serializers.get(type);
+ if (sers == null) {
+ if (DataTypeManager.isArrayType(type)) {
+ if (version < 2) {
+ return arrayColumnSerializer;
+ }
+ //TODO: make this scalable with version
+ return arrayColumnSerialier2;
+ }
+ return defaultSerializer;
}
- if (cs == null) {
- cs = serializers.get((type == null) ? DataTypeManager.DefaultDataTypes.OBJECT :
type);
- }
- if (cs == null) {
- return defaultSerializer;
- }
- return cs;
+ return sers[Math.min(version, sers.length - 1)];
}
public static void writeBatch(ObjectOutput out, String[] types, List<? extends
List<?>> batch) throws IOException {
- writeBatch(out, types, batch, (byte)1);
+ writeBatch(out, types, batch, CURRENT_VERSION);
}
public static void writeBatch(ObjectOutput out, String[] types, List<? extends
List<?>> batch, byte version) throws IOException {
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java 2012-09-01 11:34:08
UTC (rev 4393)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestSQLException.java 2012-09-03 11:25:19
UTC (rev 4394)
@@ -154,11 +154,9 @@
@Test public void testCreateThrowable3() {
TeiidSQLException e = testCreateThrowable(
new TeiidException(
- new TeiidRuntimeException(
new SocketTimeoutException(
"A test MM Invalid Session
Exception"), //$NON-NLS-1$
"Test MetaMatrixRuntimeException with a
InvalidSessionException in it"), //$NON-NLS-1$
- "Test MM Core Exception with an MM Runtime
Exception in it and an InvalidSessionException nested within"), //$NON-NLS-1$
SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION);
//test to ensure that wrapping mmsqlexceptions works
Modified: trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java 2012-09-01
11:34:08 UTC (rev 4393)
+++ trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -65,7 +65,7 @@
super(message);
}
- public TeiidRuntimeException(final String code, final String message) {
+ TeiidRuntimeException(final String code, final String message) {
super(message);
// The following setCode call should be executed after setting the message
setCode(code);
@@ -83,37 +83,15 @@
setCode(code.toString());
}
- public TeiidRuntimeException(BundleUtil.Event code) {
- super();
- setCode(code.toString());
- }
-
- public TeiidRuntimeException(final String[] message) {
- super(message[1]);
- // The following setCode call should be executed after setting the message
- setCode(message[0]);
- }
-
/**
* Construct an instance with a linked exception specified. If the exception is a
{@link TeiidException} or a
- * MetaMatrixRuntimeException, then the code will be set to the exception's
code.
+ * TeoodRuntimeException, then the code will be set to the exception's code.
* @param e An exception to chain to this exception
*/
public TeiidRuntimeException(final Throwable e) {
- this(e, ( e instanceof java.lang.reflect.InvocationTargetException )
- ?
((java.lang.reflect.InvocationTargetException)e).getTargetException().getMessage()
- : (e == null ? null : e.getMessage()));
- }
-
- /**
- * Construct an instance with the linked exception and error message specified. If
the message is actually a key, the error
- * message will be retrieved from a resource bundle the key, and code will be set to
that key. Otherwise, if the specified
- * exception is a {@link TeiidException} or a MetaMatrixRuntimeException, the code
will be set to the exception's code.
- * @param e The exception to chain to this exception
- * @param message The error message or a resource bundle key
- */
- public TeiidRuntimeException(final Throwable e, final String message) {
- super(message, e);
+ super(( e instanceof java.lang.reflect.InvocationTargetException )
+ ?
((java.lang.reflect.InvocationTargetException)e).getTargetException().getMessage()
+ : (e == null ? null : e.getMessage()), e);
setCode(TeiidException.getCode(e));
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/ArrayImpl.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/ArrayImpl.java 2012-09-01
11:34:08 UTC (rev 4393)
+++ trunk/common-core/src/main/java/org/teiid/core/types/ArrayImpl.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -22,7 +22,10 @@
package org.teiid.core.types;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -32,12 +35,14 @@
import java.util.Map;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.ExternalizeUtil;
import org.teiid.core.util.HashCodeUtil;
/**
* Provides a serializable {@link Array} implementation with minimal JDBC functionality.
*/
-public final class ArrayImpl implements Comparable<ArrayImpl>, Serializable, Array
{
+public final class ArrayImpl implements Comparable<ArrayImpl>, Externalizable,
Array {
+ private static final String INVALID = ""; //$NON-NLS-1$
private static final long serialVersionUID = 517794153664734815L;
/**
* a regrettable hack for pg compatibility since we want to avoid adding a vector type
@@ -53,6 +58,16 @@
this.values = values;
}
+ public ArrayImpl() {
+
+ }
+
+ private void checkValues() throws SQLException {
+ if (values == null) {
+ throw new SQLException("Already freed or invalid"); //$NON-NLS-1$
+ }
+ }
+
@Override
public int compareTo(ArrayImpl o) {
return compareTo(o, false, null);
@@ -62,6 +77,12 @@
if (zeroBased != o.zeroBased) {
throw new TeiidRuntimeException("Incompatible types"); //$NON-NLS-1$
}
+ try {
+ checkValues();
+ o.checkValues();
+ } catch (SQLException e) {
+ throw new TeiidRuntimeException(e);
+ }
int len1 = values.length;
int len2 = o.values.length;
int lim = Math.min(len1, len2);
@@ -113,6 +134,9 @@
}
public Object[] getValues() {
+ if (values == null) {
+ throw new TeiidRuntimeException("Already freed or invalid"); //$NON-NLS-1$
+ }
return values;
}
@@ -131,11 +155,12 @@
@Override
public void free() throws SQLException {
-
+ this.values = null;
}
@Override
public Object getArray() throws SQLException {
+ checkValues();
return values;
}
@@ -154,6 +179,7 @@
if (iIndex >= values.length || iIndex < 0) {
throw new ArrayIndexOutOfBoundsException(iIndex);
}
+ checkValues();
return Arrays.copyOfRange(values, iIndex, Math.min(iIndex + count, values.length));
}
@@ -165,11 +191,13 @@
@Override
public int getBaseType() throws SQLException {
+ checkValues();
return
JDBCSQLTypeInfo.getSQLType(DataTypeManager.getDataTypeName(values.getClass().getComponentType()));
}
@Override
public String getBaseTypeName() throws SQLException {
+ checkValues();
return DataTypeManager.getDataTypeName(values.getClass().getComponentType());
}
@@ -195,4 +223,26 @@
throw new SQLFeatureNotSupportedException();
}
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ String componentType = in.readUTF();
+ if (INVALID.equalsIgnoreCase(componentType)) {
+ return;
+ }
+ ExternalizeUtil.readArray(in, DataTypeManager.getDataTypeClass(componentType));
+ zeroBased = in.readBoolean();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ if (values == null) {
+ out.writeUTF(INVALID);
+ return;
+ }
+ out.writeUTF(DataTypeManager.getDataTypeName(this.values.getClass().getComponentType()));
+ ExternalizeUtil.writeArray(out, values);
+ out.writeBoolean(zeroBased);
+ }
+
}
Modified:
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java 2012-09-01
11:34:08 UTC (rev 4393)
+++
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -84,15 +84,6 @@
}
- public void testMetaMatrixRuntimeExceptionWithExceptionAndMessage() {
- final String code = "1234"; //$NON-NLS-1$
- final TeiidRuntimeException child = new TeiidRuntimeException(code,
"Child"); //$NON-NLS-1$
- final TeiidRuntimeException err = new TeiidRuntimeException(child,
"Test"); //$NON-NLS-1$
- assertSame(child, err.getCause());
- assertEquals(code, err.getCode());
- assertEquals("1234 Test", err.getMessage()); //$NON-NLS-1$
-
- }
public static enum Event implements BundleUtil.Event {
Code,
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2012-09-01
11:34:08 UTC (rev 4393)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -57,7 +57,8 @@
SEVEN_4("7.4", (byte)0), //$NON-NLS-1$
SEVEN_5("7.5", (byte)0), //$NON-NLS-1$
SEVEN_6("7.6", (byte)0), //$NON-NLS-1$
- EIGHT_0("8.0", (byte)1); //$NON-NLS-1$
+ EIGHT_0("8.0", (byte)1), //$NON-NLS-1$
+ EIGHT_2("8.2", (byte)2); //$NON-NLS-1$
private String string;
private byte clientSerializationVersion;
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-01 11:34:08 UTC
(rev 4393)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-09-03 11:25:19 UTC
(rev 4394)
@@ -245,7 +245,6 @@
TEIID30234,
TEIID30235,
TEIID30236,
- TEIID30237,
TEIID30238,
TEIID30239,
TEIID30240,
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2012-09-01 11:34:08
UTC (rev 4393)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2012-09-03 11:25:19
UTC (rev 4394)
@@ -366,7 +366,7 @@
clone.activeReaders = new AtomicInteger();
return clone;
} catch (CloneNotSupportedException e) {
- throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30237);
+ throw new TeiidRuntimeException(e);
} finally {
lock.readLock().unlock();
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestArray.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestArray.java 2012-09-01
11:34:08 UTC (rev 4393)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestArray.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -28,8 +28,8 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.sql.SQLException;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -69,17 +69,25 @@
assertNotSame(a1.getExpressions().get(0), array.getExpressions().get(0));
}
+ @SuppressWarnings("unchecked")
@Test public void testArrayValueSerialization() throws Exception {
- ArrayImpl a1 = new ArrayImpl(new Integer[] {1, 2, 3});
+ ArrayImpl a1 = new ArrayImpl(new Integer[] {1, null, 3});
+ ArrayImpl a2 = new ArrayImpl(null);
String[] types = TupleBuffer.getTypeNames(Arrays.asList(new Array(Integer.class,
null)));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
- BatchSerializer.writeBatch(oos, types,
Collections.singletonList(Arrays.asList((a1))));
+ BatchSerializer.writeBatch(oos, types, Arrays.asList(Arrays.asList(a1),
Arrays.asList(a2)));
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
List<List<Object>> batch = BatchSerializer.readBatch(ois, types);
assertEquals(a1, batch.get(0).get(0));
+ try {
+ ((java.sql.Array)batch.get(1).get(0)).getArray();
+ fail();
+ } catch (SQLException e) {
+
+ }
}
@Test public void testZeroBasedArray() throws Exception {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2012-09-01 11:34:08
UTC (rev 4393)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2012-09-03 11:25:19
UTC (rev 4394)
@@ -31,7 +31,6 @@
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
-import org.teiid.core.TeiidRuntimeException;
import org.teiid.net.socket.SocketUtil;
import org.teiid.transport.SSLConfiguration;
@@ -206,7 +205,7 @@
node.get(type, name, DEFAULT).set(this.defaultValue);
}
else {
- throw new TeiidRuntimeException(IntegrationPlugin.Event.TEIID50045);
+ throw new AssertionError(this.modelType);
}
}
}
@@ -230,7 +229,7 @@
model.get(getModelName()).set(operation.get(getModelName()).asBoolean());
}
else {
- throw new TeiidRuntimeException(IntegrationPlugin.Event.TEIID50046);
+ throw new AssertionError(this.modelType);
}
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-09-01
11:34:08 UTC (rev 4393)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -75,8 +75,6 @@
TEIID50042, // error state
TEIID50043,
TEIID50044, // vdb save failed
- TEIID50045,
- TEIID50046,
TEIID50047,
TEIID50048,
TEIID50049,
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2012-09-01
11:34:08 UTC (rev 4393)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2012-09-03
11:25:19 UTC (rev 4394)
@@ -73,7 +73,7 @@
@Override
public boolean sameSubject(String securityDomain, Object context, Subject subject) {
if (context == null) {
- throw new
TeiidRuntimeException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50090));
+ throw new TeiidRuntimeException(IntegrationPlugin.Event.TEIID50090,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50090));
}
SecurityContext previousContext = (SecurityContext)context;
Subject previousUser = previousContext.getSubjectInfo().getAuthenticatedSubject();