title: Why does NumberFormat.format throw an NullPointerException?
body: <p>I've just found a very strange <code>NullPointerException</code>. First, I create a <code>NumberFormat</code> like this (note that the default <code>Locale</code> would be Germany, I don't know if that helps):</p>
  
  <pre class="lang-java prettyprint-override"><code>NumberFormat angleFormat = NumberFormat.getNumberInstance(Locale.UK);
  angleFormat.setMaximumFractionDigits(5);
  angleFormat.setMinimumFractionDigits(0);
  </code></pre>
  
  <p>Then, I tried to format a double with it. This is done with a new Thread created by a Lambda, while <code>angleFormat</code> is declared at the method containing the Lambda. The code where the Exception is thrown looks like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>con.println("D" + moveId + (state.isEnemyInSightOf(e) ? "+" : "-")
          + angleFormat.format(e.getAngle()) // line 123 - error is here
          + (state.isMissileInSightOf(e) ? "+" : "-")
          + angleFormat.format(e.getSight())
          + (e.getLastShot() &gt;= 10 || e.getLastShot() &lt;= -1 ? "+" : "-")
          + angleFormat.format(e.getLives()));
  </code></pre>
  
  <p><code>e.getAngle()</code> returns a <code>double</code>, so it can't return null. However, I get this Exception:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "Thread-1" java.lang.NullPointerException
      at java.text.DecimalFormat.fastDoubleFormat(Unknown Source)
      at java.text.DecimalFormat.fastFormat(Unknown Source)
      at java.text.NumberFormat.format(Unknown Source)
      at server.game.Simulator.lambda$0(Simulator.java:123)
      at server.game.Simulator$$Lambda$3/23162747.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p><strong>I'm sure that <code>e</code> isn't null because of the Exception's stacktrace, it would a) be thrown one line earlier and b) not at <code>java.text.DecimalFormat.fastDoubleFormat</code></strong></p>
  
  <p>Why is there a <code>NullPointerException</code> beeing thrown <strong>sometimes</strong>, and sometimes it works without problems? And what does that mean? The error seems to be reproducable, but not very often.</p>