Skip to main content

Posts

Showing posts from June, 2014

tomcat dbcp abandoned connections

We recently switched from commons dbcp to tomcat dbcp and after 2-3 weeks another architect ran into an issue where his backend job would run into a resultset close issue.  He was saying it started right about the time we made the switch and it happens only for long running jobs.  That reminds me of something I had read about abandoned connections so I asked him to check after how many minutes it does this and it was 20min 1 sec. It seems I had added a property in dbcp         dataSource.setLogAbandoned(true);         dataSource.setRemoveAbandoned(true);         dataSource.setRemoveAbandonedTimeout(1200); so first thing was to confirm if this was really the case because our transaction timeout for long running queries is also 20 min but that has been for ages so this abandoned was the only recent change. Finally I found logAbandoned would log into tomcat catalina.out and I indeed saw this Jun 18, 2014 3:54:07 PM org.apache.tomcat.jdbc.pool.ConnectionPool abandon WARNING: Conne

Band-Aid programming

I saw a code sample last Saturday for someone where there was a method with 9 TODOs and I saw some code that was doing                 xxxDao.setLastSectionNum(custId, lastSectionNum);                 xxxDao.setLastChangeNum(custId, lastChangeNum);                 xxxDao.setLastModified(custId, now, xxxContext);                 if (subject == null) {                         xxxDao.updateSubject(custId, subject);                 } My blood was boiling after seeing this. This is what is called as band aid programming. I found out that programmer has added first line 2 years ago and then one more requirement came in so he added one more dao method and in 2 years we get 4 methods. WTH couldnt he refactor the code to just do 1 update query or use some ORM with POJO.  But to me he is typical band-aid programmer because I saw 9 TODOs in one 100 lines method. What that tells me is that he is just fixing bare minimum things and is having a tunnel vision.

Copy as cURL -- a great idea

Sometimes small actions are very powerful. I was recently using firebug and ran into a menu item called as copy as cURL. for e.g. when invoked on a  DuckDuckGo search on "Fox4 weather" gives curl 'https://duckduckgo.com/?q=fox4+weather&t=canonical' -H 'Host: duckduckgo.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate' -H 'DNT: 1' -H 'Referer: https://duckduckgo.com/?q=fox4+wether&t=canonical' -H 'Connection: keep-alive' Great idea Firebug team and I am hoping this small action will save me a lot of time in future.

iphone5 charger cable worse quality I have seen

The lightning cable broke within a month. I was on trip to Houston and in the car it will start charging and then die. Then I went to hotel and put it on wall plug and it wont charge. I had a suspicion that putting it in car confused the phone but restart wont help. I remember 2-3 days back it would charge and 90% and then say accessory not supported. I thought its some bug in new update. So I went to walmart in Houston at 9:00 in night on a trip to NASA and then got a cable, while I was checking out I found one more customer came asking for iphone lightning charger cable, I was now sure its a cable issue.  So I bought the cable went to hotel and this also wont charge, I went again and got another cable and that one worked.  What a bummer I thought the phone went bad. Three days after I came back home I called AT&T to send me a replacement cable and they sent me their own proprietary cable which means even they know that the OEM cable by Apple sucks and they charge $30-$40 for