Attached is a patch that I would like to make to the Java client
(including some changes to the common module).
It does the following:
(i) uses LONG_STRING in place of WIDE_STRING for properties set through
FieldTable.setString() as these appear to all be equivalent (apart from
the type code)
(ii) uses setString instead of setAsciiString in creation of the
connection.start-ok frames client properties
(iii) uses 4 bytes for the size of the BINARY value type as per the spec
posted on the wiki
I have a patch for the c++ broker to add support for the BINARY value
type and with these changes, that allows the topic test at least to pass
using java client and c++ broker). (I would prefer to have that pass
without the use of BINARY at all, but will leave that for later).
If anyone has any objections to the attached patch, let me know. In
particular if it will have any impact on the JMS TCK. Otherwise I will
check this in.
Index: common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
===================================================================
--- common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java (revision 496956)
+++ common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java (working copy)
@@ -528,9 +528,8 @@
table.setString("string", "hello");
table.setString("null-string", null);
+ final ByteBuffer buffer = ByteBuffer.allocate((int) table.getEncodedSize() + 4); // FIXME XXX: Is cast a problem?
- final ByteBuffer buffer = ByteBuffer.allocate((int) table.getEncodedSize()); // FIXME XXX: Is cast a problem?
-
table.writeToBuffer(buffer);
buffer.flip();
@@ -579,7 +578,7 @@
byte[] _bytes = {99, 98, 97, 96, 95};
result.setBytes("bytes", _bytes);
- size += 1 + EncodingUtils.encodedShortStringLength("bytes") + 1 + EncodingUtils.encodedByteLength() * _bytes.length;
+ size += 1 + EncodingUtils.encodedShortStringLength("bytes") + 4 + _bytes.length;
Assert.assertEquals(size, result.getEncodedSize());
result.setChar("char", (char) 'c');
@@ -621,7 +620,7 @@
Assert.assertEquals(size, result.getEncodedSize());
result.setObject("object-bytes", _bytes);
- size += 1 + EncodingUtils.encodedShortStringLength("object-bytes") + 1 + EncodingUtils.encodedByteLength() * _bytes.length;
+ size += 1 + EncodingUtils.encodedShortStringLength("object-bytes") + 4 + _bytes.length;
Assert.assertEquals(size, result.getEncodedSize());
result.setObject("object-char", 'c');
Index: common/src/main/java/org/apache/qpid/framing/AMQType.java
===================================================================
--- common/src/main/java/org/apache/qpid/framing/AMQType.java (revision 496956)
+++ common/src/main/java/org/apache/qpid/framing/AMQType.java (working copy)
@@ -230,7 +230,7 @@
{
public int getEncodingSize(Object value)
{
- return 1 + (value == null ? 0 : ((byte[]) value).length);
+ return EncodingUtils.encodedLongstrLength((byte[]) value);
}
@@ -250,12 +250,12 @@
public void writeValueImpl(Object value, ByteBuffer buffer)
{
- EncodingUtils.writeBytes(buffer, (byte[]) value);
+ EncodingUtils.writeLongstr(buffer, (byte[]) value);
}
public Object readValueFromBuffer(ByteBuffer buffer)
{
- return EncodingUtils.readBytes(buffer);
+ return EncodingUtils.readLongstr(buffer);
}
},
Index: common/src/main/java/org/apache/qpid/framing/FieldTable.java
===================================================================
--- common/src/main/java/org/apache/qpid/framing/FieldTable.java (revision 496956)
+++ common/src/main/java/org/apache/qpid/framing/FieldTable.java (working copy)
@@ -448,7 +448,6 @@
{
return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value));
}
-
}
public Object setString(AMQShortString string, String value)
@@ -460,15 +459,7 @@
}
else
{
- //FIXME: determine string encoding and set either WIDE or ASCII string
-// if ()
- {
- return setProperty(string, AMQType.WIDE_STRING.asTypedValue(value));
- }
-// else
-// {
-// return setProperty(string, AMQType.ASCII_STRING.asTypedValue(value));
-// }
+ return setProperty(string, AMQType.LONG_STRING.asTypedValue(value));
}
}
Index: common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
===================================================================
--- common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (revision 496956)
+++ common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (working copy)
@@ -747,7 +747,7 @@
}
}
- public static byte[] readLongstr(ByteBuffer buffer) throws AMQFrameDecodingException
+ public static byte[] readLongstr(ByteBuffer buffer)
{
long length = buffer.getUnsignedInt();
if (length == 0)
Index: client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
===================================================================
--- client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java (revision 496956)
+++ client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java (working copy)
@@ -118,10 +118,10 @@
stateManager.changeState(AMQState.CONNECTION_NOT_TUNED);
FieldTable clientProperties = FieldTableFactory.newFieldTable();
- clientProperties.setAsciiString(new AMQShortString(ClientProperties.instance.toString()), protocolSession.getClientID());
- clientProperties.setAsciiString(new AMQShortString(ClientProperties.product.toString()), QpidProperties.getProductName());
- clientProperties.setAsciiString(new AMQShortString(ClientProperties.version.toString()), QpidProperties.getReleaseVersion());
- clientProperties.setAsciiString(new AMQShortString(ClientProperties.platform.toString()), getFullSystemInfo());
+ clientProperties.setString(new AMQShortString(ClientProperties.instance.toString()), protocolSession.getClientID());
+ clientProperties.setString(new AMQShortString(ClientProperties.product.toString()), QpidProperties.getProductName());
+ clientProperties.setString(new AMQShortString(ClientProperties.version.toString()), QpidProperties.getReleaseVersion());
+ clientProperties.setString(new AMQShortString(ClientProperties.platform.toString()), getFullSystemInfo());
// AMQP version change: Hardwire the version to 0-8 (major=8, minor=0)
// TODO: Connect this to the session version obtained from ProtocolInitiation for this session.
// Be aware of possible changes to parameter order as versions change.