繁体   English   中英

重现java.io.IOException:数据错误(CRC)

[英]Reproduce java.io.IOException: Data error (CRC)

我们有一个使用 update4j 的应用程序,并从 Windows 用户那里得到了一个错误报告,其中包含以下堆栈跟踪:

INFO [main]   (OurMain.java:70) - Fatal error details: A problem occurred during the update
com.example.updater.RuntimeFatalError: A problem occured during the update
    at com.example.updater.Updater.update(Updater.java:72)
    ...
Caused by: com.example.updater.RuntimeFatalError: A problem occurred during the update
    at com.example.updater.UpdateHandler.failed(UpdateHandler.java:78)
    at org.update4j.Configuration.updateImpl(Configuration.java:1048)
    at org.update4j.Configuration.update(Configuration.java:861)
    at org.update4j.Configuration.update(Configuration.java:845)
    at com.example.updater.Updater.update(Updater.java:70)
    ... 1 common frames omitted
Caused by: java.io.IOException: Adathiba (CRC)
    at java.base/sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at java.base/sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:54)
    at java.base/sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
    at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:245)
    at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:223)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
    at org.update4j.util.FileUtils.getChecksum(FileUtils.java:57)
    at org.update4j.FileMetadata.requiresUpdate(FileMetadata.java:371)
    at org.update4j.Configuration.updateImpl(Configuration.java:934)
    ... 4 common frames omitted

(我猜“Adathiba (CRC)”消息将是“数据错误 (CRC)”,使用英语语言环境。)

如果我是对的,update4j 正在尝试从此处的磁盘读取 jar 文件。

用户删除了我们的应用程序并完全重新安装了它(这解决了问题),但是重现错误并实际修复它会很棒,因为我们收到了其他一些类似的错误报告(不幸的是,细节更少)。

我试图创建一个损坏的输入 zip/jar 文件,但 update4j 检测到它的校验和与其 XML 文件中的校验和不同,并下载并替换了该文件(如预期的那样)。

欢迎参考相关的 OpenJDK (13, 14) 源代码。 我检查了FileDispatcherImpl.javaFileDispatcherImpl.c但我没有发现任何与 CRC 检查或错误相关的内容。

所以,这是我的问题:

  • 在哪种情况下 JVM 会抛出这种IOException
  • 它是否表示 ZIP/JAR 文件已损坏? 如果是,如何创建导致类似异常的文件(用于测试)?
  • 它是否表示硬盘出现故障(并且错误来自操作系统)?

正如@vbezhenar 在他的评论中提到的那样,这似乎是一条原生操作系统错误消息。 我不熟悉 JDK 代码,因此请谨慎回答我的(部分)答案。

FileDispatcherImpl.read0(Native Method) (来自堆栈跟踪)是一个本地方法:

static native int read0(FileDescriptor fd, long address, int len)
    throws IOException;

它在FileDispatcherImpl.c源文件中实现,如果我是对的

return convertReturnVal(env, (jint)read, JNI_TRUE);

语句抛出上面的异常。

convertReturnVal()IOUtil.c文件中实现 它调用另一种方法:

JNU_ThrowIOExceptionWithLastError(env, "Read/write failed");

它在jni_util.c文件中实现,第二个参数命名为defaultDetail 它调用JNU_ThrowByNameWithLastError()仅解析ReadFile()的结果(从read0()调用)。 由于defaultDetail的值( Read/write failed )未显示在问题的堆栈跟踪中,我想该消息来自操作系统。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM