<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Exception is reported even though its caught within the context of business transaction in Splunk AppDynamics</title>
    <link>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722081#M2991</link>
    <description>&lt;P&gt;For some reason, my answer was caught as spam.&lt;/P&gt;

&lt;P&gt;So you can read it at&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/50355471/appydynamic-reports-error-for-filenotfoundexception" target="_blank" rel="noopener nofollow noreferrer"&gt;https://stackoverflow.com/questions/50355471/appydynamic-reports-error-for-filenotfoundexception&lt;/A&gt;&amp;nbsp;instead.&lt;/P&gt;

&lt;P&gt;^ Post edited by&amp;nbsp;&lt;A href="https://community.appdynamics.com/t5/user/viewprofilepage/user-id/142051"&gt;@Ryan.Paredez&lt;/A&gt;, Christopher's original reply that was flagged as spam has been unflagged and is live in this thread. It is the post that is right above this one.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2020 08:17:38 GMT</pubDate>
    <dc:creator>Christopher_Sua</dc:creator>
    <dc:date>2020-02-27T08:17:38Z</dc:date>
    <item>
      <title>Exception is reported even though its caught within the context of business transaction</title>
      <link>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722079#M2989</link>
      <description>&lt;P&gt;Have a simple method for connection,&lt;/P&gt;
&lt;PRE&gt;import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class Connection {

    public boolean connect(URL url, String requestType) {
        HttpURLConnection connection = null;
        try {
            URLConnection urlConnection = url.openConnection();
            if (urlConnection instanceof HttpURLConnection) {
                connection = (HttpURLConnection) urlConnection;
                connection.setRequestMethod(requestType);
                connection.setRequestProperty("Authorization", getAuth()); //$NON-NLS-1$
            }

            if (connection == null) {
                return false;
            }
            connection.connect();
	    &lt;STRONG&gt;connection.getInputStream();&lt;/STRONG&gt;

            return connection.getResponseCode() == HttpURLConnection.HTTP_OK;
        } catch (IOException e) {
            &lt;STRONG&gt;return false;&lt;/STRONG&gt;
        }
    }
}
&lt;/PRE&gt;

&lt;P&gt;As the line &lt;SPAN&gt;connection.getInputStream(); is encountered there is a FileNotFoundException thrown for invalida URL, caught as IOException and false is returned, however AppDynamics reports it as a business transaction error.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN&gt;Read this on the Appdynamics documentation “&lt;/SPAN&gt;An exception that is thrown and caught within the context of the business transaction is not considered a transaction error and the exception is not captured in AppDynamics.&amp;nbsp;“&lt;/P&gt;

&lt;P&gt;Can someone explain on why is 'FileNotFoundException' being reported in AppDynamics as business transaction error even though its being caught. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 15:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722079#M2989</guid>
      <dc:creator>CommunityUser</dc:creator>
      <dc:date>2018-05-18T15:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Exception is reported even though its caught within the context of business transaction</title>
      <link>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722080#M2990</link>
      <description>&lt;P&gt;Are you sure you're not getting the FileNotFound when trying to do getInputStream on the connection later (or in your real code in case this is a simplified example)? Since HttpUrlConnection implements http protocol and 4xx codes are error codes trying to call getInputStream generates FNF. Instead you should call getErrorStream.&lt;/P&gt;&lt;P&gt;I ran your code (without the auth part) and I don't get any FilenotFoundException testing on url's that return 404.&lt;/P&gt;&lt;P&gt;So in this case HttpUrlConnection correctly implements the http protocol and appdynamics correctly catches the error.&lt;BR /&gt;I'm facing the same issue with jersey wrapping the FnF in a UniformResourceException but after some analyzing it's actually either jersey that should provide ways of checking the status code before returning output or correctly use httpurlconnection, and in our case - the webservice should not return 404 for requests that yields no found results but rather an empty collection.&lt;/P&gt;&lt;PRE class="lia-code-sample language-java"&gt;&lt;CODE&gt;import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class Connection {

public boolean connect(URL url, String requestType) {
HttpURLConnection connection = null;
try {
URLConnection urlConnection = url.openConnection();
if (urlConnection instanceof HttpURLConnection) {
connection = (HttpURLConnection) urlConnection;
connection.setRequestMethod(requestType);
}
if (connection == null) {
return false;
}
connection.connect();
System.out.println(connection.getResponseCode());
return connection.getResponseCode() == HttpURLConnection.HTTP_OK;
} catch (IOException e) {
System.out.println("E" + e.getMessage());
return false;
}
}

public static void main(String args[])
{
Connection con = new Connection();
try{
con.connect(new URL("http://www.google.com/asdfasdfsd"), "GET");
} catch(MalformedURLException mfe)
{

}
}
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 08:12:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722080#M2990</guid>
      <dc:creator>Christopher_Sua</dc:creator>
      <dc:date>2020-02-27T08:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Exception is reported even though its caught within the context of business transaction</title>
      <link>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722081#M2991</link>
      <description>&lt;P&gt;For some reason, my answer was caught as spam.&lt;/P&gt;

&lt;P&gt;So you can read it at&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/50355471/appydynamic-reports-error-for-filenotfoundexception" target="_blank" rel="noopener nofollow noreferrer"&gt;https://stackoverflow.com/questions/50355471/appydynamic-reports-error-for-filenotfoundexception&lt;/A&gt;&amp;nbsp;instead.&lt;/P&gt;

&lt;P&gt;^ Post edited by&amp;nbsp;&lt;A href="https://community.appdynamics.com/t5/user/viewprofilepage/user-id/142051"&gt;@Ryan.Paredez&lt;/A&gt;, Christopher's original reply that was flagged as spam has been unflagged and is live in this thread. It is the post that is right above this one.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 08:17:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-AppDynamics/Exception-is-reported-even-though-its-caught-within-the-context/m-p/722081#M2991</guid>
      <dc:creator>Christopher_Sua</dc:creator>
      <dc:date>2020-02-27T08:17:38Z</dc:date>
    </item>
  </channel>
</rss>

