Weird EOFException on Galaxy Nexus

谁说胖子不能爱 提交于 2019-12-10 15:59:31

问题


My Android application uses URLConnection to connect to a webservice. It's in the market over a year now and works quite well. However, problems with Galaxy Nexus users came up recently:

When getting the input stream (not even reading yet!) from the URLConnection like:

final BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()), 8192);

A EOFException is thrown at getInputStream().

First I thought this may be an ICS problem, so I installed an early build on my Nexus S, but there I couldn't reproduce the problem. Then I got access to a Galaxy Nexus, which crashes in the same way as the bug reports I've received, which makes me believe that it's probably not a case of a single phone acting weird.

The stack trace of the crash can be seen here and the whole code on GitHub. It's really weird, the app has some 100k+ installations on Android Market and the problem only seem to occur on the Galaxy Nexus.

Any hints or suggestions would be greatly appreciated!


回答1:


I've seen the same issue on my Xperia Arc S (Note! Non-ICS) during development of my app. I'm almost certain that we see the same symptom of two different problems, though.

In my case I was reading the entire stream as a UTF8 String but the server side implementation was expecting me to read the first byte as a numeric byte and the rest of it as UTF8 String.

I'm not sure on the details for why I really got an EOFException, but reading the stream, paying attention to the types in the custom protocol in it, solved my problem.




回答2:


I'm seeing this same error on ICS, I "fixed" it by disabling keepAlive:

    System.setProperty("http.keepAlive", "false");


来源:https://stackoverflow.com/questions/8487780/weird-eofexception-on-galaxy-nexus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!