From bd1ac8583a01f7db7b312dcb509c5bda5c1c492f Mon Sep 17 00:00:00 2001 From: trifonnt Date: Thu, 24 Sep 2009 13:50:28 +0000 Subject: [PATCH] Prevent NullPinterException. Thank's to Felix! --- .../org/compiere/cm/MediaBroadcast.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java b/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java index 018ecd51e8..634eae8ffc 100644 --- a/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java +++ b/webCM/src/main/servlet/org/compiere/cm/MediaBroadcast.java @@ -89,22 +89,24 @@ public class MediaBroadcast extends HttpServletCM } else { response.setContentType(thisMedia.getMediaType()); // Binary / Image content will get handled here - MImage thisImage = thisMedia.getImage(); - response.setContentLength(thisImage.getData().length); - - // Open the file and output streams - byte[] buffer = thisImage.getData(); - ByteArrayInputStream in = new ByteArrayInputStream(buffer); - OutputStream out = response.getOutputStream(); - - // Copy the contents of the file to the output stream - byte[] buf = new byte[1024]; - int count = 0; - while ((count = in.read(buf)) >= 0) { - out.write(buf, 0, count); - } - in.close(); - out.close(); + MImage thisImage = thisMedia.getImage(); + if (thisImage != null) { + response.setContentLength(thisImage.getData().length); + + // Open the file and output streams + byte[] buffer = thisImage.getData(); + ByteArrayInputStream in = new ByteArrayInputStream(buffer); + OutputStream out = response.getOutputStream(); + + // Copy the contents of the file to the output stream + byte[] buf = new byte[1024]; + int count = 0; + while ((count = in.read(buf)) >= 0) { + out.write(buf, 0, count); + } + in.close(); + out.close(); + } } } else { response.sendError(404);