Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11319)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 11320)
@@ -1366,8 +1366,11 @@
      *
      * @param stream input stream
-     * @return byte array of data in input stream
+     * @return byte array of data in input stream or null if stream is null
      * @throws IOException if any I/O error occurs
      */
     public static byte[] readBytesFromStream(InputStream stream) throws IOException {
+        if (stream == null) {
+            return null;
+        }
         try {
             ByteArrayOutputStream bout = new ByteArrayOutputStream(stream.available());
Index: trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java	(revision 11319)
+++ trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java	(revision 11320)
@@ -3,5 +3,7 @@
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
@@ -162,3 +164,14 @@
         assertEquals("<ul></ul>", Utils.joinAsHtmlUnorderedList(Collections.emptyList()));
     }
+
+    /**
+     * Tests if readBytesFromStream handles null streams (might happen when there is no data on error stream)
+     * @throws IOException
+     *
+     */
+    @Test
+    public void testNullStreamForReadBytesFromStream() throws IOException {
+        assertNull("Null on null stream", Utils.readBytesFromStream(null));
+    }
+
 }
