You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Georg Reichelt (Jira)" <ji...@apache.org> on 2022/04/04 12:38:00 UTC

[jira] [Commented] (IO-764) IOUtils.write() throws OutOfMemoryError/NegativeArraySizeException while writing big strings

    [ https://issues.apache.org/jira/browse/IO-764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516785#comment-17516785 ] 

David Georg Reichelt commented on IO-764:
-----------------------------------------

Yes, it works if you start it with -Xmx8g (and I testet with OpenJDK 11 and 8).

The question is whether this would be suitable for regular testing in CI (than, surefire needs -Xmx8g), or whether I should disable the test by default.

> IOUtils.write() throws OutOfMemoryError/NegativeArraySizeException while writing big strings
> --------------------------------------------------------------------------------------------
>
>                 Key: IO-764
>                 URL: https://issues.apache.org/jira/browse/IO-764
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.11.0
>            Reporter: David Georg Reichelt
>            Assignee: Gary D. Gregory
>            Priority: Critical
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Currently, if I try to write a sufficiently big to a stream, IOUtils.write fails:
> {code:java}
> java.lang.NegativeArraySizeException: -1283060862
> at java.base/java.lang.StringCoding.encodeUTF8(StringCoding.java:904)
> at java.base/java.lang.StringCoding.encode(StringCoding.java:449)
> at java.base/java.lang.String.getBytes(String.java:964)
> at org.apache.commons.io.IOUtils.write(IOUtils.java:3251)
> at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:3541)
> at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:3524){code}
> The reason for this is that getBytes does not support Strings with this size. This should be fixed.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)