我在狂野的服务器错误日志中发现了那个“有趣的”异常。我的应用程序将异常和“wtf”错误发布到我的中央服务器,所以我没有太多信息到底发生了什么。我只知道它发生了,我没有任何线索。
堆栈跟踪:
java.io.IOException: Math result not representable
at org.apache.harmony.luni.platform.OSFileSystem.writeImpl(Native Method)
at org.apache.harmony.luni.platform.OSFileSystem.write(OSFileSystem.java:129)
at java.io.FileOutputStream.write(FileOutputStream.java:297)
at net.jav.apps.romeolive.RomeoInterface.fetchBinaryToFile(RomeoInterface.java:299)
at net.jav.apps.romeolive.HeartBeatService$_fetchPic.run(HeartBeatService.java:327)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
代替 net.jav.apps.romeolive.RomeoInterface 的代码:
byte[] ret=fetchBinary(fullurl);
if (ret==null) return false;
try
{
FileOutputStream os=new FileOutputStream(getCacheFileName(type,fullurl));
os.write(ret, 0, ret.length);
“失败”行 #299 是 os.write()
fetchBinary(url) 从 Web 服务器获取一些二进制文件(缩略图 jpg)并将其作为 byte[] 返回,如果未找到/错误则返回 NULL。
getCacheFileName(type,fullurl) 返回 cacheDir() 加上类型加上净化的 fullurl(删除斜杠,只使用 url 的本地部分)。
所以究竟失败了,是......试图将现有的缩略图 jpg byte[] 写入 cacheDir() 中完美制作的文件名。
出现此异常的设备(直到现在只有一次)是:GT-I9000@samsung/GT-I9000/GT-I9000/GT-I9000:2.2.1/FROYO/XXJPY:user/release-keys
有没有人将这个“数学结果不可表示”作为 IOException?我真的很想确定那件事;)谷歌和 Stackoverflow 没有显示任何有用的甚至相关的东西。
非常感谢,奥利弗