-
-
Notifications
You must be signed in to change notification settings - Fork 72
DefaultUpdateHandler heap space exception when file to download is 0b #106
Comments
Thanks, I'll look into this. Does this happen on JDK 11+ too? |
Sorry forgot to mention env, |
The env usually doesn't matter but in the case of I'll look into it when I have a chance. |
I have a hunch is an int overflow bug. |
The problem is here:
Which is a divide by zero. While for integers is fails with an Then in this line: update4j/src/main/java/org/update4j/service/DefaultUpdateHandler.java Lines 188 to 189 in 2c4c04c
we multiple an int by Infinity which results in Attempting to repeat a string by max value will cause an |
I think this a very special case that should probably not be handled by update4j. It will fail regardless in the file validation phase. |
Totally agree that it should fail (input is wrong anyway) but would be nice to have a better suited exception thrown early to avoid filling the heap space . Or maybe ignore files with size 0 and checksum 1 ? |
The safest and least intrusive would be to simply clamp the progress between 0 and 1 and never allow leaking out of those bounds. |
Due to a bug in my app, the update4j xml generated ended up with a 0b file size instead of correct size(65mo), leading to this exception in the client using that xml:
Part of the XML file:
file uri="http://files.yildiz-games.be/play50hz/player/retro-player.jar" path="${user.dir}/lib/retro-player.jar" size="0" checksum="1"
Exception:
Downloading 0 B 0% [> ] Exception in thread "Progress Printer" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Unknown Source)
at java.base/java.util.StringJoiner.add(Unknown Source)
at java.base/java.lang.String.join(Unknown Source)
at org.update4j.util.StringUtils.repeat(StringUtils.java:123)
at org.update4j.service.DefaultUpdateHandler.renderProgress(DefaultUpdateHandler.java:189)
at org.update4j.service.DefaultUpdateHandler$1.run(DefaultUpdateHandler.java:127)
at java.base/java.util.TimerThread.mainLoop(Unknown Source)
at java.base/java.util.TimerThread.run(Unknown Source)
Same file with expected size(65mo) is handled correctly.
The text was updated successfully, but these errors were encountered: