<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rally Engineering Blog</title>
	
	<link>http://www.rallydev.com/engblog</link>
	<description>Stay current with Rally's engineering team.</description>
	<lastBuildDate>Mon, 21 May 2012 16:57:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RallyEngineeringBlog" /><feedburner:info uri="rallyengineeringblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>RallyEngineeringBlog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Your Harshest Critic is Your Automated Tests</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/dLI9Po0p8QE/</link>
		<comments>http://www.rallydev.com/engblog/2012/05/21/your-harshest-critic-is-your-automated-tests/#comments</comments>
		<pubDate>Mon, 21 May 2012 16:57:47 +0000</pubDate>
		<dc:creator>Garston Tremblay</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2952</guid>
		<description><![CDATA[
			
				
			
		
You&#8217;ve probably read a lot on this blog about why automated tests are so awesome.  But there&#8217;s another reason why they are really awesome: they are quite possibly the strictest critic of the code you write.  More strict than your QA person, your pairing partner and the browser itself (yes, even IE  [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F21%2Fyour-harshest-critic-is-your-automated-tests%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F21%2Fyour-harshest-critic-is-your-automated-tests%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>You&#8217;ve probably read a lot on this blog about why automated tests are so awesome.  But there&#8217;s another reason why they are really awesome: they are quite possibly the strictest critic of the code you write.  More strict than your QA person, your pairing partner and the browser itself (yes, even IE <img src='http://www.rallydev.com/engblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ).</p>
<p>Automated browser tests can catch some of the smallest &#8220;bugs&#8221;.  And I put the word bugs in quotes for a reason; browser tests can catch coding mistakes that are technically bugs, but aren&#8217;t actually visible to the user.</p>
<p>One category of these types of bugs is memory leaks.  There have been several instances where our browser tests have become flaky or flat-out failed because some of our UI components and/or pages weren&#8217;t destroying themselves properly when they are no longer visible to the user.  If the page/component is still in the DOM, the test will be able to interact with it which can cause the test to be flaky or fail.  This issue has more potential to show itself if you re-use the same components in different parts of your app.</p>
<p>Memory leaks are a good example of something that wouldn&#8217;t typically have been found by QA or a regular user but a browser test will have no problem showing you that you messed up.  Like I said, harshest critic you can find but they make you a better developer for sure <img src='http://www.rallydev.com/engblog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Another quick Javascript example:<br />
We had a boolean method on a Javascript object that looked something like this:</p>
<pre class="brush: jscript;">
isParent: function() {
  return this.getChildren().length &gt; 0;
}
</pre>
<p>We needed to make a change because this.getChildren() could now return undefined so we changed our method to this:</p>
<pre class="brush: jscript;">
isParent: function() {
  var children = this.getChildren();
  return children &amp;&amp; children.length &gt; 0;
}
</pre>
<p>Luckily, we had also written a test to verify that isParent() would return false when children is undefined.  It was failing and we couldn&#8217;t figure out why!  Our change had even fixed the JavaScript error we were getting in the browser when getChildren() was returning undefined and everything looked great in the browser.</p>
<p>After some more inspection (our actual case was a bit more complicated so give us a break <img src='http://www.rallydev.com/engblog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) we realized that if children was undefined, isParent() would actually return undefined instead of a boolean value like the API says it should.  Undefined is false-y in Javascript so the caller of isParent() didn&#8217;t happen to care that undefined was being returned instead of false in this case so everything looked great in the browser but the test showed us isParent() wasn&#8217;t adhering to its API.</p>
<p>I was really excited how writing a test made us realize that we had made a mistake!!  A pretty small mistake all-in-all but nevertheless a mistake.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2952&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/dLI9Po0p8QE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/05/21/your-harshest-critic-is-your-automated-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/05/21/your-harshest-critic-is-your-automated-tests/</feedburner:origLink></item>
		<item>
		<title>Bite Size Pro Tip: Key Code Gotchas in Javascript</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/rRjXdD1d2wc/</link>
		<comments>http://www.rallydev.com/engblog/2012/05/15/bite-size-pro-tip-key-code-gotchas-in-javascript/#comments</comments>
		<pubDate>Tue, 15 May 2012 21:01:54 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[Bite Size Pro Tips]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2950</guid>
		<description><![CDATA[
			
				
			
		
We recently wrapped up another hackathon. Like I did last summer, I spent my time in javascript. This time, I learned a few things about the key codes browsers send to javascript event handlers when non-alphanumeric keys are pressed.
First, in the modern browsers I tested (FF, Chrome, and (ick) IE9) the forward-slash key is registered [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F15%2Fbite-size-pro-tip-key-code-gotchas-in-javascript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F15%2Fbite-size-pro-tip-key-code-gotchas-in-javascript%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We recently wrapped up another hackathon. <a href="http://www.rallydev.com/engblog/2011/08/11/using-hackathons-to-keep-your-tools-sharp/">Like I did last summer</a>, I spent my time in javascript. This time, I learned a few things about the key codes browsers send to javascript event handlers when non-alphanumeric keys are pressed.</p>
<p>First, in the modern browsers I tested (FF, Chrome, and (ick) IE9) the forward-slash key is registered as a key code of 191. This surprised me because the ASCII code is 47.</p>
<p>Along the same lines, the question mark key is registered as 191 with a shiftKey value of true. Again, I&#8217;d have expected the ASCII code of 63.</p>
<p>Here&#8217;s the curve ball in the whole thing. The one really random non-conforming browser is Firefox, which registers the question mark key as a key code of 0 (zero) with a shiftKey value of true. Shame on me for thinking IE would be the oddball.</p>
<p>Unlike the last time I spent time hackathoning in javascript, this project was handled all along with the intent of putting it into production. Keep an eye out for something cool involving the keyboard soon in Rally.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2950&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/rRjXdD1d2wc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/05/15/bite-size-pro-tip-key-code-gotchas-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/05/15/bite-size-pro-tip-key-code-gotchas-in-javascript/</feedburner:origLink></item>
		<item>
		<title>RallyON</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/ZenuvSfvyi8/</link>
		<comments>http://www.rallydev.com/engblog/2012/05/01/rallyon/#comments</comments>
		<pubDate>Tue, 01 May 2012 19:52:49 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Engineering Practices]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2943</guid>
		<description><![CDATA[
			
				
			
		
This week, Rally is holding the second annual RallyON conference.  Today, Steve and I are presenting a brief history of (mostly automated) testing at Rally. There shouldn&#8217;t be a ton that&#8217;s new for regular readers of this blog, but I&#8217;m happy to share the slides with anyone who&#8217;s interested.
Track what&#8217;s happening at RallyON using [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F01%2Frallyon%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F05%2F01%2Frallyon%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This week, Rally is holding the second annual <a href="http://www.rallydev.com/community/">RallyON</a> conference. <img src="http://www.rallydev.com/engblog/wp-content/uploads/2012/05/ryan-rallyon.jpg" alt="RallyON" /> Today, <a href="http://www.rallydev.com/engblog/author/sneely/">Steve</a> and I are presenting a brief history of (mostly automated) testing at Rally. There shouldn&#8217;t be a ton that&#8217;s new for regular readers of this blog, but I&#8217;m happy to share the slides with anyone who&#8217;s interested.</p>
<p>Track what&#8217;s happening at RallyON using the hashtag <a href="http://twitter.com/#!/search/%23RallyON2012">#RallyOn2012</a>.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2943&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/ZenuvSfvyi8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/05/01/rallyon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/05/01/rallyon/</feedburner:origLink></item>
		<item>
		<title>Bulk Attachment of Event Listeners with ExtJs</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/HX2NalHEFu8/</link>
		<comments>http://www.rallydev.com/engblog/2012/04/05/bulk-attachment-of-event-listeners-with-extjs/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 14:29:05 +0000</pubDate>
		<dc:creator>dthompson</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2917</guid>
		<description><![CDATA[
			
				
			
		
Sometimes I run across a task where I need to attach event listeners to many different dom elements of the same type. I am usually tempted to do something similar to the code below.

Ext.each(Ext.query('a', parentNode), function(el) {
    el.on('click', doSomethingAwesome);
});

This is ExtJs&#8217;s way to loop through each dom element matching the passed css [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F04%2F05%2Fbulk-attachment-of-event-listeners-with-extjs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F04%2F05%2Fbulk-attachment-of-event-listeners-with-extjs%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes I run across a task where I need to attach event listeners to many different dom elements of the same type. I am usually tempted to do something similar to the code below.</p>
<pre class="brush: jscript;">
Ext.each(Ext.query('a', parentNode), function(el) {
    el.on('click', doSomethingAwesome);
});
</pre>
<p>This is ExtJs&#8217;s way to loop through each dom element matching the passed css selector and attach an event listener to it. I&#8217;m lazy and it&#8217;s less code than the correct implementation, which would be to add a listener to the parent element and filter for the correct target element inside the handler function. The disadvantages to the lazy method are that multiple listeners are created, all of which have some amount of overhead attached, and that listeners need to be removed and/or reattached whenever the innerHTML of the parent element changes.</p>
<p>An ExtJs specific example of when the &#8216;lazy&#8217; method doesn&#8217;t work is when event listeners need to be attached to elements created by a renderer inside of a <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.Panel">GridPanel</a> cell. The GridPanel does not expose any row or cell render events, so there is no reliable way to add event listeners to dom elements located inside cells.</p>
<p>Fortunately ExtJs&#8217;s <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Element-method-on">Element.on</a> method has a helpful &#8216;delegate&#8217; option that does all of this for you automatically. Use ExtJs&#8217;s <a href="http://http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Element-method-on">Element.on</a> method to attach a listener to the parent dom element and specify a css selector for the &#8216;delegate&#8217; option to filter out events whose target node does not match the passed css selector.</p>
<pre class="brush: jscript;">
var parentEl = Ext.fly(parentNode);
parentEl.on('click', function(event, target, options) {
    console.log('the &quot;target&quot; argument is the anchor element that is a child of parentNode');
}, this, {
    delegate: 'a'
});
</pre>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2917&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/HX2NalHEFu8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/04/05/bulk-attachment-of-event-listeners-with-extjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/04/05/bulk-attachment-of-event-listeners-with-extjs/</feedburner:origLink></item>
		<item>
		<title>Chaos Raccoon</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/4h_T1En7EVQ/</link>
		<comments>http://www.rallydev.com/engblog/2012/04/01/chaos-raccoon/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 12:00:14 +0000</pubDate>
		<dc:creator>Steve Neely</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[April 1st]]></category>
		<category><![CDATA[disaster]]></category>
		<category><![CDATA[raccoon]]></category>
		<category><![CDATA[recovery]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2856</guid>
		<description><![CDATA[
			
				
			
		
On the Rally Engineering blog we’ve written many articles on systems’ performance, monitoring, resilience, and recovery. An interesting event just happened at our Denver production facility that pushed our systems to their limits. It helped us answer the question:
How well does production survive in the face of all-out failures?
Maybe inspired by Netflix’s Chaos Monkey, some [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F04%2F01%2Fchaos-raccoon%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F04%2F01%2Fchaos-raccoon%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>On the Rally Engineering blog we’ve written many articles on systems’ performance, monitoring, resilience, and recovery. An interesting event just happened at our Denver production facility that pushed our systems to their limits. It helped us answer the question:</p>
<p style="text-align: center;"><em><strong>How well does production survive in the face of all-out failures?</strong></em></p>
<p>Maybe inspired by Netflix’s <a title="Chaos Monkey *eep* *eep*" href="http://techblog.netflix.com/2010/12/5-lessons-weve-learned-using-aws.html" target="_blank">Chaos Monkey</a>, some local wildlife found its was into our server room and litterally <strong>tore apart our hardware</strong>.</p>
<p style="text-align: center;"><strong>Enter the <em><span style="color: #ff0000;">&#8220;Rally Chaos Raccoon&#8221;</span></em></strong></p>
<p>Last weekend the Chaos Raccoon, we now call “Cyril”*, chewed his way into our production server room. From security video footage we saw that at first he was cautious and quiet. Just hiding behind the Dell 4210s &#8212; where it’s warm.</p>
<p>But after a full day of no food Cyril got angry.</p>
<p><em>Pissed</em> angry.</p>
<p>He gnawed on the mounting brackets of our UPS and ripped open a SAN unit in use by <code>app-server-01</code>.</p>
<p>The instant <code>app-01</code> failed our backup app-server spun into action and took over the production traffic from <code>app-01</code>. The process all had to happen automatically &#8212; when <a href="http://www.rallydev.com/engblog/author/anichols/">Aaron</a> tried to enter the cage for a manual failover Cyril attacked and <strong>bit his cheek</strong> (yes, <em>that</em> cheek).</p>
<p><img class="alignright size-medium wp-image-2858" title="angry-raccoon" src="http://www.rallydev.com/engblog/wp-content/uploads/2012/03/angry-raccoon-300x288.jpg" alt="angry-raccoon" width="300" height="288" /></p>
<p>As Aaron left the server room, seeking medical attention and rabies shots, the Chaos Raccoon ripped into another Dell 4210 and chewed its innards into shreds. Our system smoothly recovered, load-balancing network traffic whilst simultaneously paging the operations team another warning. When Cyril finally chewed through the UPS he electrocuted himself to death.</p>
<p>It smelled bad.</p>
<p>In the future we&#8217;ll probably test our processes with a &#8220;Bad-ass Bear&#8221;, &#8220;Crazy Coy Carp&#8221;, or &#8220;Janky Jackalope&#8221;. Opening up your production systems to wildlife attack demonstrates confidence in monitoring, recovery, and backup processes. It stretches your failover strategies to their limits. You may think your systems are ready for anything but when a raccoon attacks <strong>there are no rules</strong>.</p>
<p>If you’re going to implement your own Chaos Raccoon we recommend you first deploy an array of recovery tools and test with non-endangered creatures. It’s organic and the ecologically sound option.</p>
<h6>* real names changed to protect the innocent</h6>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2856&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/4h_T1En7EVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/04/01/chaos-raccoon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/04/01/chaos-raccoon/</feedburner:origLink></item>
		<item>
		<title>Bite-size pro tips: the IntelliJ debugger and jconsole</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/6TSgwZPOm5M/</link>
		<comments>http://www.rallydev.com/engblog/2012/03/26/bite-size-pro-tips-the-intellij-debugger-and-jconsole/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 02:39:20 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2848</guid>
		<description><![CDATA[
			
				
			
		
IntelliJ is an awesome IDE from JetBrains. jconsole is a powerful tool for examining the state of an executing JVM. When you&#8217;re debugging JVM code in IntelliJ, you might find that jconsole can&#8217;t connect to your JVM while you&#8217;re sitting on a breakpoint. This is because the default breakpoint behavior in IntelliJ is to stop [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F26%2Fbite-size-pro-tips-the-intellij-debugger-and-jconsole%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F26%2Fbite-size-pro-tips-the-intellij-debugger-and-jconsole%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.jetbrains.com/idea/">IntelliJ</a> is an awesome IDE from JetBrains. <a href="http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html">jconsole</a> is a powerful tool for examining the state of an executing JVM. When you&#8217;re debugging JVM code in IntelliJ, you might find that jconsole can&#8217;t connect to your JVM while you&#8217;re sitting on a breakpoint. This is because the default breakpoint behavior in IntelliJ is to stop the whole VM, not just the thread that&#8217;s sitting on the breakpoint. If you try to connect jconsole to the JVM in this state, it will time out.</p>
<p>This is easy to fix:<br />
1. Right click on your breakpoint and choose &#8220;Properties&#8221;<br />
2. Change the suspend policy from &#8220;All&#8221; to &#8220;Thread&#8221;</p>
<p>&#8220;&#8230;and you&#8217;re done kid.&#8221; Imagine I said that in a Boston accent.</p>
<p>You can now connect to the JVM while sitting on that breakpoint. Problem solved.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2848&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/6TSgwZPOm5M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/03/26/bite-size-pro-tips-the-intellij-debugger-and-jconsole/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/03/26/bite-size-pro-tips-the-intellij-debugger-and-jconsole/</feedburner:origLink></item>
		<item>
		<title>Java Memory Problems: Why is my Heap Exhausted?</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/rlK7oi3KwJg/</link>
		<comments>http://www.rallydev.com/engblog/2012/03/16/java-memory-problems-why-is-my-heap-exhausted/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 19:06:09 +0000</pubDate>
		<dc:creator>Steve Neely</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[heap]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[memory leak]]></category>
		<category><![CDATA[out of memory error]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2837</guid>
		<description><![CDATA[
			
				
			
		
Help! My Java application keeps crashing! OutOfMemoryError?! My hair is on fire! Please don’t let the invisible fire burn my friend!!!
1. Increase max heap size
Some applications are complex and large enough that they simply need more memory.
Try increasing the max heap size when you start the JVM by adding the flag -Xmx. So your start-up [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F16%2Fjava-memory-problems-why-is-my-heap-exhausted%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F16%2Fjava-memory-problems-why-is-my-heap-exhausted%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><em>Help! My Java application keeps crashing! <code><span style="color: #339966;">OutOfMemoryError</span></code>?! My hair is on <span style="color: #ff0000;">fire</span>! Please don’t let the invisible <span style="color: #ff0000;">fire</span> burn my friend!!!</em></p>
<p><strong>1. Increase max heap size</strong></p>
<p>Some applications are complex and large enough that they simply need more memory.<br />
Try increasing the max heap size when you start the JVM by adding the flag <code>-Xmx</code>. So your start-up will look something like this: <code>java -Xmx1024m MyApp</code> (which is equivalent to <code>java -Xmx1g MyApp</code>)</p>
<p>The downside to this is that your application will suffer from longer garbage collection cycles, it may be better to fix the greedy code.</p>
<p>But what if your application still runs out of memory? Seems like you have a leak.</p>
<p><strong>2. Detect memory leak</strong></p>
<p>Learn to use a tools like jmap and Thread Dump Analyser (TDA). Run <code>jmap -histo</code><br />
(where <code>pid</code> is the process-id of your Java application) a few times and compare the output. Read my earlier blog posts on <a href="http://www.rallydev.com/engblog/2011/09/20/outofmemoryerror-fun-with-heap-dump-analysis/">fun with heap dump analysis</a>.</p>
<p><strong>3. Carefully read your code</strong></p>
<p>There are many ways to leak memory in Java code. Watch out for thread local variables &#8212; especially in a thread pool. Each thread stores its own state so anything you put on there will last the lifetime of the thread. If your threads are recycled through a thread pool that state may hang around for a long time.</p>
<p>Mutable static collections are bad. Static fields are retained by the class and therefore its classloader. That means your collection will hang around for the lifetime of that class. Come to think of it, it is better not to use mutable statics.</p>
<p>If you re-implement the <code>hashcode</code> and <code>equals</code> methods and get it wrong you’ll shoot yourself in the foot. Here is why: when you store an object in a <code>HashMap</code> the collection will call your (wrong) <code>hashcode</code> method to determine that object’s position. On look-up, the map uses the (wrong) <code>hashcode</code> method again and then calls (wrong) <code>equals</code> method to check it retrieved the correct object. If you break the implementations of these two methods you can add objects into the <code>HashMap</code> but can’t get them back. Worse, you can add the same thing repeatedly and it will not overwrite the old value because <code>hashcode</code> keeps returning different values for the same object.</p>
<p><strong>4. Circuit breakers</strong></p>
<p>If you do have to compute over potentially large collections of objects then use weak references as circuit breakers. I wrote a series of blog posts that will serve as a good primer for weak references. In particular: <a href="http://www.rallydev.com/engblog/2012/01/04/a-byte-sized-primer-on-jvm-memory-management/">JVM Memory Primer</a>, <a href="http://www.rallydev.com/engblog/2012/01/10/java-references-from-strong-to-soft-to-weak-to-phantom/">Java References</a> and <a href="http://www.rallydev.com/engblog/2012/01/11/defining-reachability/">Reachability Explained</a>.</p>
<p>Monitoring JVM memory usage and tweaking system options is something we do all the time. Once you’ve fixed your leaks you need to continue to monitor systems and run load tests to project usage into the future. Be proactive; don’t wait for an <code>OutOfMemoryError</code> to remind you.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2837&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/rlK7oi3KwJg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/03/16/java-memory-problems-why-is-my-heap-exhausted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/03/16/java-memory-problems-why-is-my-heap-exhausted/</feedburner:origLink></item>
		<item>
		<title>Integration Testing Patterns (2 of ?) – make your tests like production</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/xeO10vjPDTY/</link>
		<comments>http://www.rallydev.com/engblog/2012/03/09/integration-testing-patterns-2-of-make-your-tests-like-production/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 16:51:26 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Engineering Practices]]></category>
		<category><![CDATA[Test-Driven Design]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2834</guid>
		<description><![CDATA[
			
				
			
		
This one&#8217;s going to be short and sweet, with no sample code. Recently, I&#8217;ve been blogging about writing effective integration tests.
If you&#8217;re going to make the time investment (both development time and execution time) in writing integration tests, you need to make them work as much like your production environment as possible. Exercise as much [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F09%2Fintegration-testing-patterns-2-of-make-your-tests-like-production%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F03%2F09%2Fintegration-testing-patterns-2-of-make-your-tests-like-production%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This one&#8217;s going to be short and sweet, with no sample code. Recently, I&#8217;ve been blogging about <a href="http://www.rallydev.com/engblog/2012/02/29/integration-testing-patterns-part-2-of-limit-your-commits/">writing effective</a> <a href="http://www.rallydev.com/engblog/2012/02/23/integration-testing-patterns-part-1-of/">integration tests</a>.</p>
<p>If you&#8217;re going to make the time investment (both development time and execution time) in writing integration tests, you need to make them work as much like your production environment as possible. Exercise as much of the same stack as you can.</p>
<p>If you&#8217;re writing to a database, you should be using the same connection pooling and transaction management mechanism as production. If you&#8217;re using an inversion of control container, you should be using the same one as production and loading as many of the same components as possible.</p>
<p>Why? If you don&#8217;t, your integration tests are not really proving anything. If you&#8217;re committing to a database, but not the same way you will in production, that leaves room for data inconsistencies. If you&#8217;re only loading part of your IoC container, that leaves room for unexpected wiring of dependencies.</p>
<p>Make your integration tests like production. It&#8217;ll save you from bugs later.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2834&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/xeO10vjPDTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/03/09/integration-testing-patterns-2-of-make-your-tests-like-production/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/03/09/integration-testing-patterns-2-of-make-your-tests-like-production/</feedburner:origLink></item>
		<item>
		<title>Integration Testing Patterns (part 2 of ?) – limit your commits</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/UKd-li02CG8/</link>
		<comments>http://www.rallydev.com/engblog/2012/02/29/integration-testing-patterns-part-2-of-limit-your-commits/#comments</comments>
		<pubDate>Wed, 29 Feb 2012 20:29:52 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[Agile Processes]]></category>
		<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Engineering Practices]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Test-Driven Design]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2814</guid>
		<description><![CDATA[
			
				
			
		
In my last post I promised to share some tips that can help developers write effective integration tests.
Committing to a database is expensive. In many standard SQL databases, it&#8217;s pretty much the most expensive thing you can do. By comparison, querying is relatively inexpensive. If possible, you should structure your integration tests in such a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F02%2F29%2Fintegration-testing-patterns-part-2-of-limit-your-commits%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F02%2F29%2Fintegration-testing-patterns-part-2-of-limit-your-commits%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In <a href="http://www.rallydev.com/engblog/2012/02/23/integration-testing-patterns-part-1-of/">my last post</a> I promised to share some tips that can help developers write effective integration tests.</p>
<p>Committing to a database is expensive. In many standard SQL databases, it&#8217;s pretty much the most expensive thing you can do. By comparison, querying is relatively inexpensive. If possible, you should structure your integration tests in such a way that you assert as much as possible for each commit that&#8217;s made.</p>
<p>Consider this test. Rally supports the notion of a hierarchy of projects, structured into a tree. Individual users can have access to any node(s) within the tree and should only see data from those projects. This test creates users and projects and verifies our permission model.</p>
<pre class="brush: java;">
public void whenOnParentScopedDownOnlyIncludeChildProjectsWhereUserHasAccess(PersistenceContext context) {
  Project parent = createProject();
  Project editorAccessChild = createProject(parent);
  Project viewerAccessChild = createProject(editorAccessChild);
  Project noAccessChild = createProject(parent);

  User user = createUserAsProjectEditor(parent);
  makeProjectEditor(user, editorAccessChild);
  makeProjectViewer(user, viewerAccessChild);
  context.commitAndReset();

  ProjectOidsInScope scope = scopeTo(parent).as(user).includeChildren();

  assertThat(scope.get(), containsOidsOf(parent, editorAccessChild, viewerAccessChild));
}

public void whenOnChildScopedUpOnlyIncludeParentProjectsWhereUserHasAccess(PersistenceContext context) {
  Project noAccessGrandParent = createProject();
  Project viewerParent = createProject(noAccessGrandParent);
  Project editorProject = createProject(viewerParent);

  User user = createUserAsProjectEditor(editorProject);
  makeProjectViewer(user, viewerParent);
  context.commitAndReset();

  ProjectOidsInScope scope = scopeTo(editorProject).as(user).includeParents();

  assertThat(scope.get(), containsOidsOf(editorProject, viewerParent));
}
</pre>
<p>These are good tests. With a little understanding of the Rally domain, they&#8217;re highly readable and they test the right things.</p>
<p>So what&#8217;s the problem? We&#8217;re committing twice when once will do. While the impact on any individual test is fairly minimal, the impact of unnecessary commits is compounded when spread across thousands of tests. Even within this test class, these aren&#8217;t the only two tests. There are ten.</p>
<p>What if we wrote the test like this?</p>
<pre class="brush: java;">
private Project editorProject;
private Project editorAccessChild;
private Project viewerAccessChild;
private Project noAccessChild;
private User user;
private Project noAccessGrandParent;
private Project viewerParent;

@BeforeMethod
protected void setupData(PersistenceContext context) {
  if(dataCreated) return;
  dataCreated = true;
  noAccessGrandParent = createProject();
  viewerParent = createProject(noAccessGrandParent);
  editorProject = createProject(viewerParent);
  editorAccessChild = createProject(editorProject);
  viewerAccessChild = createProject(editorAccessChild);
  noAccessChild = createProject(editorProject);

  user = createUserAsProjectEditor(editorProject);

  makeProjectViewer(user, viewerParent);
  makeProjectEditor(user, editorAccessChild);
  makeProjectViewer(user, viewerAccessChild);

  context.commitAndReset();
}

public void whenOnParentScopedDownOnlyIncludeChildProjectsWhereUserHasAccess(PersistenceContext context) {
  ProjectOidsInScope scope = scopeTo(editorProject).as(user).includeChildren();

  assertThat(scope.get(), containsOidsOf(editorProject, editorAccessChild, viewerAccessChild));
}

public void whenOnChildScopedUpOnlyIncludeParentProjectsWhereUserHasAccess(PersistenceContext context) {
  ProjectOidsInScope scope = scopeTo(editorProject).as(user).includeParents();

  assertThat(scope.get(), containsOidsOf(editorProject, viewerParent));
}
</pre>
<p>We&#8217;ve moved the data creation into a setup method that runs (and commits) only once. We&#8217;ve sacrificed a small amount of readability within each test because the data setup isn&#8217;t directly adjacent to the actions and assertions. We have, however, gained some consistency across tests. Once we know the data structure we&#8217;re working with, we don&#8217;t need to mentally parse each test separately to figure out what shape the data is in before reading the rest of the test.</p>
<p>Integration tests are expensive, so achieving maximum bang for buck is important. If you can verify multiple behaviors while only doing the expensive part of the test once, DO IT!</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2814&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/UKd-li02CG8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/02/29/integration-testing-patterns-part-2-of-limit-your-commits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/02/29/integration-testing-patterns-part-2-of-limit-your-commits/</feedburner:origLink></item>
		<item>
		<title>Integration Testing Patterns (part 1 of ?)</title>
		<link>http://feedproxy.google.com/~r/RallyEngineeringBlog/~3/JskSP-4VbJg/</link>
		<comments>http://www.rallydev.com/engblog/2012/02/23/integration-testing-patterns-part-1-of/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 06:00:02 +0000</pubDate>
		<dc:creator>Ryan Scott</dc:creator>
				<category><![CDATA[Agile Processes]]></category>
		<category><![CDATA[Automated Testing]]></category>
		<category><![CDATA[Clean Code]]></category>
		<category><![CDATA[Engineering Practices]]></category>
		<category><![CDATA[Test-Driven Design]]></category>

		<guid isPermaLink="false">http://www.rallydev.com/engblog/?p=2809</guid>
		<description><![CDATA[
			
				
			
		
I love TDD and Unit Testing. That said, there are times and places where Integration Testing is more appropriate. In this series of posts, I&#8217;m going to explore patterns (and anti-patterns) of integration testing and try to identify when each is appropriate.
First off, what&#8217;s an integration test? The loosest definition I can come up with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F02%2F23%2Fintegration-testing-patterns-part-1-of%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rallydev.com%2Fengblog%2F2012%2F02%2F23%2Fintegration-testing-patterns-part-1-of%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I love <a href="http://c2.com/cgi/wiki?TestDrivenDevelopment">TDD</a> and <a href="http://c2.com/cgi/wiki?UnitTest">Unit Testing</a>. That said, there are times and places where Integration Testing is more appropriate. In this series of posts, I&#8217;m going to explore patterns (and anti-patterns) of integration testing and try to identify when each is appropriate.</p>
<p>First off, what&#8217;s an integration test? The loosest definition I can come up with is that an integration test involves either (1) access to out of process resources like databases or file systems or (2) exercises several parts of a larger system working together. For the most part, I&#8217;m going to focus on scenario 1.</p>
<p>In no particular order, here&#8217;s what I plan on blogging about in this series:</p>
<ul>
<li><a href="http://www.rallydev.com/engblog/2011/07/29/enforcing-conventions-through-tests-part-3-prevention-jsp-precompilation-bugs/">Enforce your conventions</a>!</li>
<li>Limit your commits</li>
<li>Multiple asserts are OK</li>
<li>Set up the data as infrequently as possible</li>
<li>Don&#8217;t test shite that should be tested in a faster test</li>
<li>This shite still needs to be fast</li>
<li>Make your tests like production</li>
<li>No, really, this shite needs to be fast!</li>
<li><a href="http://www.rallydev.com/engblog/2011/10/03/when-is-readability-the-most-important-ility/">Readability</a> is still damn important</li>
</ul>
<p>There&#8217;s certainly some overlap in that topic list, so I&#8217;m sure I&#8217;ll cover multiple topics in every post. I&#8217;ll be sure to get to all of the topics, though.</p>
<img src="http://www.rallydev.com/engblog/?ak_action=api_record_view&id=2809&type=feed" alt="" /><img src="http://feeds.feedburner.com/~r/RallyEngineeringBlog/~4/JskSP-4VbJg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rallydev.com/engblog/2012/02/23/integration-testing-patterns-part-1-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rallydev.com/engblog/2012/02/23/integration-testing-patterns-part-1-of/</feedburner:origLink></item>
	</channel>
</rss>

