qiniu / android-netdiag

Network Diagnosis for Android
MIT License
141 stars 36 forks source link

Crash : Trace Route Null pointer exception in case of wrong url #6

Open harshgaba opened 6 years ago

harshgaba commented 6 years ago

Hello, I am getting null pointer exception while performing Traceroute in case of wrong url. java.net.UnknownHostException: Unable to resolve host "apibroken.apc.com": No address associated with hostname at java.net.InetAddress.lookupHostByName(InetAddress.java:424) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getByName(InetAddress.java:289) at com.qiniu.android.netdiag.TraceRoute.getIp(TraceRoute.java:76) 08-07 14:31:50.568 16689-16704/com.example.harshgaba.netdialogsample W/System.err: at com.qiniu.android.netdiag.TraceRoute.run(TraceRoute.java:158) at com.qiniu.android.netdiag.TraceRoute.access$000(TraceRoute.java:16) at com.qiniu.android.netdiag.TraceRoute$1.run(TraceRoute.java:63) at java.lang.Thread.run(Thread.java:841) Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.getaddrinfo(Native Method) at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61) at java.net.InetAddress.lookupHostByName(InetAddress.java:405) 08-07 14:31:50.569 16689-16704/com.example.harshgaba.netdialogsample W/System.err: ... 7 more 08-07 14:31:50.569 16689-16704/com.example.harshgaba.netdialogsample W/dalvikvm: threadid=12: thread exiting with uncaught exception (group=0x2ccf2ba8) 08-07 14:31:50.570 16689-16704/com.example.harshgaba.netdialogsample E/AndroidRuntime: FATAL EXCEPTION: Thread-139 Process: com.example.harshgaba.netdialogsample, PID: 16689 java.lang.NullPointerException at com.qiniu.android.netdiag.TraceRoute$Result.access$100(TraceRoute.java:210) at com.qiniu.android.netdiag.TraceRoute.updateOut(TraceRoute.java:151) at com.qiniu.android.netdiag.TraceRoute.run(TraceRoute.java:161) at com.qiniu.android.netdiag.TraceRoute.access$000(TraceRoute.java:16) at com.qiniu.android.netdiag.TraceRoute$1.run(TraceRoute.java:63) at java.lang.Thread.run(Thread.java:841)

------------------->>>> Below implemented code <<<---------------------

TraceRoute.start("apibroken.apc.com", new Output() { @Override public void write(String line) { Log.e("TraceRoute:-- ", line + " "); } }, new TraceRoute.Callback() { @Override public void complete(TraceRoute.Result r) { try { Log.e("TraceRoute:-- ", " r.content() " + r.content() + " " + r.ip); } catch (Exception e) { e.printStackTrace(); }

        }

    });
vzhovnitsky commented 4 years ago

Same here, error comes up on result.append(str); because Result in null.