Huge output causes UTFDataFormatException
ShinyaYoshida
bitterfoxc at gmail.com
Thu Apr 23 08:35:49 UTC 2015
Sorry,
I couldn't find the reply in kulla-dev...
Thank you for your re-sending.
>So, another approach is simply to truncate the string, with maybe a "..."
at the end.
Definitely, it is preferred rather than printing everything.
Retry is here:
http://cr.openjdk.java.net/~shinyafox/kulla/201504201/webrev.03/
In my patch, the output is omitted if it is over 800 length, like Scala
does.
Best regards,
shinyafox(Shinya Yoshida)
2015-04-23 12:55 GMT+09:00 Robert Field <robert.field at oracle.com>:
> Hi Shinya,
>
> I'm resend this since it doesn't look like you saw it.
>
> -Robert
>
> On 04/20/15 14:01, Robert Field wrote:
>
> Hi shinyafox,
>
> When I ran tests on my system with the patch installed, I get a new
> failure of the ExceptionsTest.outOfMemory test on my platform. I can also
> replicate this in the REPL tool:
>
> -> List<byte[]> list = new ArrayList<>();
> | Added variable list of type List<byte[]> with initial value []
>
> -> while (true) { list.add(new byte[10000]); }
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2747)
> at java.lang.Class.getDeclaredMethod(Class.java:2174)
> at
> java.io.ObjectStreamClass.getPrivateMethod(ObjectStreamClass.java:1431)
> at java.io.ObjectStreamClass.access$1700(ObjectStreamClass.java:72)
> at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:494)
> at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:468)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:468)
> at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:365)
> at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1134)
> at java.io.ObjectOutputStream.*writeObject*
> (ObjectOutputStream.java:348)
> at remote.RemoteAgent.commandLoop(RemoteAgent.java:116)
> at remote.RemoteAgent.main(RemoteAgent.java:54)
>
> | State engine terminated. See /history
> | Resetting...
>
> It appears, unsurprisingly, that writeObject uses much more in the way of
> resources than writeUTF. In low memory error reporting situations, that is
> fatal.
>
> One solution might then be to use writeObject for the two valueString
> results leaving the failure cases still using writeUTF.
>
> But let us step back, what is being sent back to the user is a string
> representation of the value of the resulting object. It, in general, is
> not the actual value, for that we would be sending writeObject of the
> result rather than the valueSting of the result. The actual Object value
> would have been our preference, but given that it can't be deserialized
> accurately in the client VM with different classes loaded, the punt was a
> string representation. And a string representation is exactly what a tool
> like the REPL tool wants. In that usage case, a string representation of
> anywhere near 65535 is way too long. So, another approach is simply to
> truncate the string, with maybe a "..." at the end.
>
> Thoughts?
>
> -Robert
>
>
>
>
> On 04/19/15 21:40, ShinyaYoshida wrote:
>
> I've moved my test case into SimpleRegressionTest.
> New patch is here:http://cr.openjdk.java.net/~shinyafox/kulla/201504201/webrev.01/
>
> Regards,
> shinyafox(Shinya Yoshida)
>
> 2015-04-20 1:18 GMT+09:00 ShinyaYoshida <bitterfoxc at gmail.com> <bitterfoxc at gmail.com>:
>
>
> Hi,
> I met UTFDataFormatException with a huge output:
>
> -> java.util.stream.Stream.generate(() -> "
> ").limit(65534).collect(java.util.stream.Collectors.joining())
> Exception in thread "main" java.io.UTFDataFormatException
> at
> java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2169)
> at
> java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2012)
> at java.io.ObjectOutputStream.writeUTF(ObjectOutputStream.java:869)
> at remote.RemoteAgent.commandLoop(RemoteAgent.java:106)
> at remote.RemoteAgent.main(RemoteAgent.java:54)
> | State engine terminated. See /history
> | Resetting...
>
> The cause is rejecting the String which is over 65536 UTF-length in
> OOW#writeUTF.
> I think we should use OOW#writeObject.
>
> Here is my patch & test, please review my patch:http://cr.openjdk.java.net/~shinyafox/kulla/201504201/webrev.00/
>
> Regards,
> shinyafox(Shinya Yoshida)
>
>
>
>
>
>
More information about the kulla-dev
mailing list