<?xml version="1.0" encoding="UTF-8"?>
<!-- name="generator" content="blojsom v3.2" -->
<rdf:RDF xmlns:wfw="http://wellformedweb.org/CommentAPI/"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns="http://purl.org/rss/1.0/">

	<channel rdf:about="http://www.madplanet.com/weblog/blog/sid">
		<title>Sid&#39;s Blog</title>
		<link>http://www.madplanet.com/weblog/blog/sid/</link>
		<description></description>
		<dc:publisher>Siddharth Chhabra</dc:publisher>
		<dc:creator>sid@madplanet.com</dc:creator>
		<dc:date>2008-06-24T12:27:57-07:00</dc:date>
		<dc:language>en</dc:language>

        <items>
        <rdf:Seq>
                                <rdf:li rdf:resource="http://www.madplanet.com/weblog/blog/sid/2008/06/24/Throw-null" />
                                <rdf:li rdf:resource="http://www.madplanet.com/weblog/blog/sid/2008/06/12/Dont-put-a-lot-in-IN" />
                                <rdf:li rdf:resource="http://www.madplanet.com/weblog/blog/sid/2008/05/27/Log4j-SMTPAppender-for-email-alerts" />
                                <rdf:li rdf:resource="http://www.madplanet.com/weblog/blog/sid/2008/05/14/Hello-World" />
                </rdf:Seq>
        </items>
    </channel>

            <item rdf:about="http://www.madplanet.com/weblog/blog/sid/2008/06/24/Throw-null">
	    <title>Throw null.</title>
	    <link>http://www.madplanet.com/weblog/blog/sid/2008/06/24/Throw-null</link>
        <description>&lt;a href=&quot;http://www.jroller.com/eu/entry/something_new_about_null_values&quot;&gt; Eugene &lt;/a&gt;posed an interesting question about &lt;a href=&quot;http://tech.puredanger.com/2008/06/23/throw-null/&quot;&gt;Alex&#39; blog entry&lt;/a&gt;
on why the following code does not require main method to throw throwable -
&lt;pre&gt;
  public class Weird {  
    public static void main(String[] args) {  
      throw null;  
    }  
  }
&lt;/pre&gt;
The fact that it throws a NPE has been discussed on Alex&#39; blog.&lt;br/&gt;
But the reason(or my hypothesis) why the compile dos not require you to add a Throwable to throws clause is as follows - 
&lt;ol&gt;	
&lt;li&gt;The null reference can always be cast to any reference type.&lt;/li&gt;
&lt;li&gt;Checked Exceptions should be declared in the throws clause.&lt;/li&gt;
&lt;li&gt;RuntimeExceptions and Descendants are exempt from the above requirement(2)&lt;/li&gt;
&lt;li&gt;Rephrasing 2 and 3 as &quot;if the type is not an instance of RuntimeException&quot;, which translates to the following code - 
&lt;pre&gt;
if(!(type instanceof RuntimeException)) {
 //check throws clause for validity
}else {
 //dont check.
}
&lt;/pre&gt;
and we can see that &#39;null&#39; case would go to the else block. 
&lt;/ol&gt;

Q.E.D. ? (you decide)
</description>
	    <dc:date>2008-06-24T12:27:57-07:00</dc:date>
	                                <wfw:comment>http://www.madplanet.com/weblog/commentapi/sid/Java/J2EE/2008/06/24/Throw-null</wfw:comment>
            <wfw:commentRss>http://www.madplanet.com/weblog/blog/sid/2008/06/24/Throw-null?page=comments&amp;flavor=rss2</wfw:commentRss>
            </item>
            <item rdf:about="http://www.madplanet.com/weblog/blog/sid/2008/06/12/Dont-put-a-lot-in-IN">
	    <title>Dont put a lot in IN.</title>
	    <link>http://www.madplanet.com/weblog/blog/sid/2008/06/12/Dont-put-a-lot-in-IN</link>
        <description>So in case people were wondering if application alerts are a good idea;
heres a sybase database oddity/limitation/defect which we noticed via our alerting mechanism.
&lt;p&gt;
This defect was not discovered during development, slipped through QA and did not show itself in production for quite a few months.
And then suddenly one day it showed up in the alerts (see below) -
&lt;/p&gt;
&lt;em&gt;
&lt;p&gt;
[com.company.servlets.GenericServlet] request string---&gt;http://service.company.com:8080/category/get_ante/attrs?null
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorizedSQLException for SQL [select this_.atom as atom4_0_, this_.dte_orig as dte2_4_0_, this_.dte_update as dte3_4_0_, this_.country_code as country4_4_0_, this_.ante as ante4_0_, this_.updated_by as updated6_4_0_ from category_ante_intl_atom this_ where this_.atom in (?, ?, ?, ?, ?, ?, ?, &lt;strong&gt;...1024 of them !!&lt;/strong&gt;)]; &lt;/p&gt;


&lt;p&gt;
SQL state [ZZZZZ]; error code [404]; Too many ANDs or ORs in expression (limit 1024 per expression level). Try splitting query or limiting ANDs and ORs.
&lt;/p&gt;
&lt;/em&gt;
So anyone who has used hibernate (&quot;Restrictions.in&quot;) or even plain sql with an IN clause should be careful if the method takes an unbounded list and puts them inside the IN clause. Infact anyone writing one of those innocent looking DAO method which takes in a list of ids and returns a bunch of Objects could be guilty of causing this if they are not careful.
&lt;br/&gt;This is one of those unobvious scaling bugs which people run into (a similar famous scaling bug is documented here - &lt;a href=&quot;http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html&quot;&gt;BinarySearch
&lt;/a&gt;)&lt;br/&gt;
And one of the criticisms of hashCode is the return type int instead of a long (again related to scaling). 
&lt;br/&gt;
&lt;p&gt;
This defect (or &#39;limitation&#39; if you want to be polite) exists in sybase 12.5 and has been corrected in more recent versions of sybase ase.
Also in Oracle this limit is even less, around a 1000 ! see here --&gt; 
&lt;a href=&quot;http://forums.oracle.com/forums/thread.jspa?threadID=428758&quot;&gt;Oracle forum link&lt;/a&gt;.
&lt;br/&gt;So for portability we might have to keep that in mind.&lt;/p&gt;

</description>
	    <dc:date>2008-06-12T10:30:49-07:00</dc:date>
	                                <wfw:comment>http://www.madplanet.com/weblog/commentapi/sid/Java/J2EE/2008/06/12/Dont-put-a-lot-in-IN</wfw:comment>
            <wfw:commentRss>http://www.madplanet.com/weblog/blog/sid/2008/06/12/Dont-put-a-lot-in-IN?page=comments&amp;flavor=rss2</wfw:commentRss>
            </item>
            <item rdf:about="http://www.madplanet.com/weblog/blog/sid/2008/05/27/Log4j-SMTPAppender-for-email-alerts">
	    <title> Log4j SMTPAppender for email alerts </title>
	    <link>http://www.madplanet.com/weblog/blog/sid/2008/05/27/Log4j-SMTPAppender-for-email-alerts</link>
        <description>&lt;p&gt;
We recently put a new application in production under a tight schedule.
One of things we wanted to track was the number of errors which were happening at runtime,so we could get some feedback on the frequency with which they happened.
&lt;/p&gt;
&lt;p&gt;
A couple of other members in the team had used log4j&#39;s smtpappender for this before. So we hooked it up to send us email alerts for each log.error statement in our code (Application errors).
It was very interesting to see how our dependencies failed us and what bugs had gotten past QA.
&lt;/p&gt;

&lt;pre&gt;
Sample log4j configuration for the SMTP appender - 
  &amp;lt;appender name=&quot;SMTP&quot; class=&quot;org.apache.log4j.net.SMTPAppender&quot;&amp;gt;
    &amp;lt;errorHandler class=&quot;org.jboss.logging.util.OnlyOnceErrorHandler&quot;/&amp;gt;
    &amp;lt;param name=&quot;Threshold&quot; value=&quot;${log4j.email.threshold}&quot;/&amp;gt
    &amp;lt;param name=&quot;To&quot; value=&quot;${log4j.email.to}&quot;/&amp;gt;
    &amp;lt;param name=&quot;From&quot; value=&quot;${log4j.email.from}&quot;/&amp;gt;
    &amp;lt;param name=&quot;Subject&quot; value=&quot;Service Error - ${machineid}&quot;/&amp;gt;
    &amp;lt;param name=&quot;SMTPHost&quot; value=&quot;hqintmail.org.com&quot;/&amp;gt;
    &amp;lt;param name=&quot;BufferSize&quot; value=&quot;10&quot;/&amp;gt;
    &amp;lt;layout class=&quot;org.apache.log4j.PatternLayout&quot;&amp;gt;
      &amp;lt;param name=&quot;ConversionPattern&quot; value=&quot;%d{ABSOLUTE} %-5p [%c] %m%n&quot;/&amp;gt;
    &amp;lt;/layout&amp;gt;
  &amp;lt;/appender&amp;gt;
&lt;/pre&gt;
For example one of things we noticed was a couple of the webservices we depended on was not very reliable and crashed (returned no data) for atleast 10-15 times in the day &lt;strong&gt;!&lt;/strong&gt;&lt;p&gt; 
Since this was a customer facing webapp the errors were appropriately handled on the UI but having this alerting turned on, enabled us to proactively track issues before customers actually reported them.
There were a couple of situations in which it didn&#39;t exactly do what we wanted.
For example, when one of our enterprise databases went down for  a couple of minutes, our inbox got 
flooded with alerts within minutes.
&lt;/p&gt;
&lt;p&gt;
But on the whole, things were going well until our mail server changed.
Log4j configuration still had the old mail server name.
And since the appender could not send out the email alert, it relentlessly kept trying to do so making the box totally unresponsive and even dropping existing client connections

Googling further on the problem I was able to find this (just thought I would pass it on) – 
&lt;a href=&quot;http://forum.java.sun.com/thread.jspa?threadID=659705&amp;tstart=75&quot;&gt;java forum thread discussing log4j&lt;/a&gt;
&lt;/p&gt;

So if you worry about high availability then this is one of the things which could expose a chink in your 
design and eventually we are moving away from using this as our alerting mechanism( though using asyncappender could mitigate some of the risk) as we wanted more features from our alerting.
&lt;br/&gt;
A couple of features which would be nice to have -	
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cumulative alerting&lt;/strong&gt; - 
Tell me when a problem(database down) starts and when it subsides instead of each failed attempt.
&lt;/li&gt;

&lt;li&gt;&lt;strong&gt;Selective alerting &lt;/strong&gt; - 
Ability to ignore some alerts without requiring a code change
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt; Routing &lt;/strong&gt; - 
Ability to route different kinds of alerts to different emails (out of the box).
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance and Availability&lt;/strong&gt; - 
It should not affect the performance or the availability of the application.
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Statisitcal Analysis of Alerts &lt;/strong&gt; - 
Basically fancy charts and historical analysis.
&lt;/li&gt;
&lt;/ol&gt;

</description>
	    <dc:date>2008-05-27T13:57:42-07:00</dc:date>
	                                <wfw:comment>http://www.madplanet.com/weblog/commentapi/sid/Java/J2EE/2008/05/27/Log4j-SMTPAppender-for-email-alerts</wfw:comment>
            <wfw:commentRss>http://www.madplanet.com/weblog/blog/sid/2008/05/27/Log4j-SMTPAppender-for-email-alerts?page=comments&amp;flavor=rss2</wfw:commentRss>
            </item>
            <item rdf:about="http://www.madplanet.com/weblog/blog/sid/2008/05/14/Hello-World">
	    <title>Hello World</title>
	    <link>http://www.madplanet.com/weblog/blog/sid/2008/05/14/Hello-World</link>
        <description>I say Hello - You say Good-bye
</description>
	    <dc:date>2008-05-14T16:12:00-07:00</dc:date>
	        </item>
    
</rdf:RDF>
