[
https://issues.jboss.org/browse/ISPN-872?page=com.atlassian.jira.plugin.s...
]
Galder Zamarreño edited comment on ISPN-872 at 1/12/11 11:54 AM:
-----------------------------------------------------------------
I get the feeling that the issue here is that at read time, we don't differentiate
between a pure byte[] which we shouldn't serialize as opposed one that we should:
obj match {
case ba: Array[Byte] =>
Response.ok.`type`("application/x-java-serialized-object").entity(streamIt(_.write(ba))).build
case ser: Serializable =>
Response.ok.`type`("application/x-java-serialized-object").entity(streamIt(new
ObjectOutputStream(_).writeObject(ser))).build
If we send the byte[] as is, then this is not a java serialized object but it could be as
shown by this example.
So, if someone sends a byte[] as is, which does not come from having serialized an object,
a different type is needed here, maybe "application/octet-stream" or some other
pure binary MIME type?
I must say that I thought that your test is a bit odd and I've wondered if it actually
makes sense. If you have String, why convert it to byte array via getBytes() and then
serialize it? You can just take the String and serialize it directly and the resulting
object is a String on the server side. I guess what the getBytes() gives you is the
confidence that it is being transformed into a particular encoding of your preference
which in this case is plattform independent, i.e. UTF-8. Odd but I think deep down is a
valid use case.
was (Author: galder.zamarreno(a)jboss.com):
I get the feeling that the issue here is that at read time, we don't differentiate
between a pure byte[] which we shouldn't serialize as opposed one that we should:
obj match {
case ba: Array[Byte] =>
Response.ok.`type`("application/x-java-serialized-object").entity(streamIt(_.write(ba))).build
case ser: Serializable =>
Response.ok.`type`("application/x-java-serialized-object").entity(streamIt(new
ObjectOutputStream(_).writeObject(ser))).build
If we send the byte[] as is, then this is not a java serialized object but it could be as
shown by this example.
So, if someone sends a byte[] as is, which does not come from having serialized an object,
a different type is needed here, maybe "application/octet-stream" or some other
pure binary MIME type?
I must say thought that your test is a bit odd and I've wondered if it actually makes
sense. If you have String, why convert it to byte array via getBytes() and then serialize
it? You can just take the String and serialize it directly and the resulting object is a
String on the server side. I guess what the getBytes() gives you is the confidence that it
is transforming into a particular encoding of your type that is plattform independent,
i.e. UTF-8.
In REST, serialized byte array is returned as raw but not serialized
--------------------------------------------------------------------
Key: ISPN-872
URL:
https://issues.jboss.org/browse/ISPN-872
Project: Infinispan
Issue Type: Enhancement
Components: Cache Server
Affects Versions: 4.2.0.Final, 5.0.0.ALPHA1
Reporter: Galder Zamarreño
Assignee: Galder Zamarreño
Labels: REST
Fix For: 4.2.1.Final, 5.0.0.ALPHA2
From Michal:
"When I want to store byte array in the serialized form (mimetype:
application/x-java-serialized-object) I can't get it back, because rest server returns
it in raw form instead of serialized form.
see
https://github.com/infinispan/infinispan/blob/4.2.0.FINAL/server/rest/src...,
line 44-50.
the process is like this:
1. PUT bytearray in serialized form
2. rest server deserializes the bytearray and stores it in deserialized (raw) form
3. GET byte array (expecting serialized form)
4. rest server retrieves the byte array in raw form but doesn't serialize it, instead
streams it in raw form - because of the above mentioned code.
testcase
testByteArrayStorage()
in
https://anonsvn.jboss.org/repos/jbossas/branches/JBPAPP_5_1_datagrid/test...
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira