Java: final field treemap changes size
<p>I have a java code that contains a class TRADE_HISTORY that holds a history of trades.</p>

<p>Class TRADE_HISTORY has a final field named fMapDateOutputPriceRatios that is set in the constructor .  fMapDateOutputPriceRatios is a map between dates and a double array (TreeMap).  In the constructor, the field is assinged to the argurment using </p>

<pre><code>fMapDateOutputPriceRatios = new TreeMap&lt;Date, double[]&gt;(aOutputPriceRatioData); 
</code></pre>

<p>The number of dates is obtained using </p>

<pre><code>Set&lt;Date&gt; dates = fMapDateOutputPriceRatios.keySet();
</code></pre>

<p>The size of dates is printed out in the constructor.  The class has only one constructor.</p>

<p>A problem is occurring when a new trade is added.  When a new date is added, the double vector is used, and obtained from </p>

<pre><code> double[] outputPriceRatios = fMapDateOutputPriceRatios.get( aDate );
</code></pre>

<p>The error occurs because the date is not available.</p>

<p>While trying to debug the error, the size of dates is being printed.</p>

<p>During construction, the size is 1973 elements.</p>

<p>When the error occurs, the size is 1964 elements.  </p>

<p>In particular, the date Apr 11, 2011 is not available at the time of the error.</p>

<p>I'm using eclipse and have set a break on the variable fMapDateOutputPriceRatios to break when the field is modified.  It only breaks during the constructor.</p>

<p>Any suggestion on how to determine why the size of fMapDateOutputPriceRatios changes?  </p>

<p>The only lines that access fMapDateOutputPriceRatios are</p>

<pre><code>TRADE_HISTORY::TRADE_HISTORY(Map&lt;Date, double[]&gt; aOutputPriceRatioData )
        fMapDateOutputPriceRatios = new TreeMap&lt;Date, double[]&gt;(aOutputPriceRatioData); 
        Set&lt;Date&gt; dates = fMapDateOutputPriceRatios.keySet();  // Used to debug error

TRADE_HISTORY::public void addTradeDistribution_0_to_100(Date aDate, ...)
        outputPriceRatios = fMapDateOutputPriceRatios.get( aDate )  // Causes error
        Set&lt;Date&gt; dates = fMapDateOutputPriceRatios.keySet();   // Used to debug error
</code></pre>
