NewRelic

时间:2015-08-17 10:02:26

标签: android nullpointerexception newrelic

我一直在使用NewRelic sdk来跟踪我的应用程序上的网络请求,现在我收到了一些NullPointerException,例如下面的那个;

java.lang.NullPointerException
   at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:479)
   at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:419)
   at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:217)
   at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:177)
   at com.newrelic.agent.android.instrumentation.HttpsURLConnectionExtension.connect(HttpsURLConnectionExtension.java:102)
   at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:512)
   at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:493)
   at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:205)
   at org.jsoup.helper.HttpConnection.get(HttpConnection.java:194)
   at com.radioafrica.mpasho.service.ArticleFetcherService.checkForApiChanges(ArticleFetcherService.java:480)
   at com.radioafrica.mpasho.service.ArticleFetcherService.onHandleIntent(ArticleFetcherService.java:261)
   at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:132)
   at android.os.HandlerThread.run(HandlerThread.java:60)

每当我尝试向一个特定网址发出http请求时。我怎么能抓住这个例外?

以下是发出http请求的代码

 private void checkForApiChanges() {
    String version = null;

    try {
        Document doc = Jsoup.connect(CHECK_URL).get();
        Elements v = doc.select("p.version");

        for (Element el : v) {
            version = el.text();
        }

    } catch (IOException | OutOfMemoryError | ExceptionInInitializerError e) {
        e.printStackTrace();
    }
}

0 个答案:

没有答案