Yeah, we discussed this on IRC and Tim also made some additional changes, so I think we're good on this.
Regards -- Dejan Bosanac ---------------------- Red Hat, Inc. FuseSource is now part of Red Hat [email protected] Twitter: @dejanb Blog: http://sensatic.net ActiveMQ in Action: http://www.manning.com/snyder/ On Wed, Dec 26, 2012 at 2:50 PM, Hiram Chirino <[email protected]> wrote: > If I had to guess it's so that Maps and Lists in the body/headers of > Message objects get decoded as Strings and not UTF8Buffers. > > > On Thu, Dec 20, 2012 at 12:33 PM, Timothy Bish <[email protected]> wrote: > >> >> Dejan, what is the problem that you are fixing here? It looks like with >> this change there no reason to even have the UTF8Buffer as every string >> is now going to be unpacked from raw UTF8 >> >> On Thu, 2012-12-20 at 16:53 +0000, [email protected] wrote: >> > Author: dejanb >> > Date: Thu Dec 20 16:53:33 2012 >> > New Revision: 1424587 >> > >> > URL: http://svn.apache.org/viewvc?rev=1424587&view=rev >> > Log: >> > https://issues.apache.org/jira/browse/AMQ-4180 - force unmarshaling for >> maps and lists >> >> > Modified: >> > >> activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java >> > >> > Modified: >> activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java >> > URL: >> http://svn.apache.org/viewvc/activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java?rev=1424587&r1=1424586&r2=1424587&view=diff >> > >> ============================================================================== >> > --- >> activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java >> (original) >> > +++ >> activemq/trunk/activemq-client/src/main/java/org/apache/activemq/util/MarshallingSupport.java >> Thu Dec 20 16:53:33 2012 >> > @@ -92,7 +92,7 @@ public final class MarshallingSupport { >> > Map<String, Object> rc = new HashMap<String, Object>(size); >> > for (int i = 0; i < size; i++) { >> > String name = in.readUTF(); >> > - rc.put(name, unmarshalPrimitive(in)); >> > + rc.put(name, unmarshalPrimitive(in, true)); >> > } >> > return rc; >> > } >> > @@ -110,7 +110,7 @@ public final class MarshallingSupport { >> > int size = in.readInt(); >> > List<Object> answer = new ArrayList<Object>(size); >> > while (size-- > 0) { >> > - answer.add(unmarshalPrimitive(in)); >> > + answer.add(unmarshalPrimitive(in, true)); >> > } >> > return answer; >> > } >> > @@ -152,6 +152,10 @@ public final class MarshallingSupport { >> > } >> > >> > public static Object unmarshalPrimitive(DataInputStream in) throws >> IOException { >> > + return unmarshalPrimitive(in, false); >> > + } >> > + >> > + public static Object unmarshalPrimitive(DataInputStream in, boolean >> force) throws IOException { >> > Object value = null; >> > byte type = in.readByte(); >> > switch (type) { >> > @@ -183,18 +187,19 @@ public final class MarshallingSupport { >> > value = new byte[in.readInt()]; >> > in.readFully((byte[])value); >> > break; >> > - case STRING_TYPE: { >> > - int length = in.readUnsignedShort(); >> > - byte data[] = new byte[length]; >> > - in.readFully(data); >> > - value = new UTF8Buffer(data); >> > + case STRING_TYPE: >> > + if (force) { >> > + value = in.readUTF(); >> > + } else { >> > + value = readUTF(in, in.readUnsignedShort()); >> > + } >> > break; >> > - } >> > case BIG_STRING_TYPE: { >> > - int length = in.readInt(); >> > - byte data[] = new byte[length]; >> > - in.readFully(data); >> > - value = new UTF8Buffer(data); >> > + if (force) { >> > + value = readUTF8(in); >> > + } else { >> > + value = readUTF(in, in.readInt()); >> > + } >> > break; >> > } >> > case MAP_TYPE: >> > @@ -212,6 +217,12 @@ public final class MarshallingSupport { >> > return value; >> > } >> > >> > + public static UTF8Buffer readUTF(DataInputStream in, int length) >> throws IOException { >> > + byte data[] = new byte[length]; >> > + in.readFully(data); >> > + return new UTF8Buffer(data); >> > + } >> > + >> > public static void marshalNull(DataOutputStream out) throws >> IOException { >> > out.writeByte(NULL); >> > } >> > >> > >> >> -- >> Tim Bish >> Sr Software Engineer | RedHat Inc. >> [email protected] | www.fusesource.com | www.redhat.com >> skype: tabish121 | twitter: @tabish121 >> blog: http://timbish.blogspot.com/ >> >> > > > -- > > ** > > *Hiram Chirino* > > *Engineering | Red Hat, Inc.* > > *[email protected] <[email protected]> | fusesource.com | redhat.com* > > *skype: hiramchirino | twitter: @hiramchirino<http://twitter.com/hiramchirino> > * > > *blog: Hiram Chirino's Bit Mojo <http://hiramchirino.com/blog/>*
