NullPointerException - how this could happen?
got code looking like this:
// This is com.n.common.Networking.downloadBmp( ) function
// ...
byte[] data = inputStreamToByteArray(new PatchedInputStream(connectJava(url)));
// if the data is null in this moment - return;
if (data == null) // <--- line 185
return null;
// ...
And got exception like this:
ERROR/AndroidRuntime(4526): Uncaught handler: thread pool-1-thread-2 exiting due to uncaught exception
ERROR/AndroidRuntime(4526): java.lang.NullPointerException
ERROR/AndroidRuntime(4526): at com.n.common.Networking.downloadBmp(Networking.java:185)
ERROR/AndroidRuntime(4526): at com.n.common.AsyncNetworking$3.run(AsyncNetworking.java:203)
ERROR/AndroidRuntime(4526): at java.lang.Thread.run(Thread.java:1060)
ERROR/AndroidRuntime(4526): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
ERROR/AndroidRuntime(4526): at java开发者_JS百科.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
ERROR/AndroidRuntime(4526): at java.lang.Thread.run(Thread.java:1060)
How is that possible?
EDIT: It is probable due to using Eclipse "Organize imports" function, which altered line numbers - and comparing newer code version to the old deployed one. Thx everyone for help.
Should be a deployment problem or something related to saving files and having multiple versions. The code that throws the Exception has to have a different line 185 than what you have posted.
Try clean / recompile / (redeploy) and see if the line number changes
Something else is going on, that line can not produce a NPE. Most likely you have a stale build that is reporting the wrong line number in the logs.
A quick suggestion would be, that the problem is somewhere in "inputStreamToByteArray(new PatchedInputStream(connectJava(url)));".
I am also wondering what "connectJava" is? Is it a method that you have created? If it is, please provide it too, as i suspect that it's causing the problem.
精彩评论