CLOUDSTACK-8656: console logging on asserted exceptions

This commit is contained in:
Daan Hoogland 2015-08-04 13:28:58 +02:00
parent e8a00ed989
commit 27960b4a7a
4 changed files with 31 additions and 21 deletions

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.consoleproxy;
import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@ -201,10 +203,7 @@ public class ConsoleProxyAjaxHandler implements HttpHandler {
s_logger.warn("Exception while reading request body: ", e);
} finally {
if (closeStreamAfterRead) {
try {
is.close();
} catch (IOException e) {
}
closeAutoCloseable(is, "error closing stream after read");
}
}
return sb.toString();

View File

@ -25,6 +25,7 @@ import java.util.List;
import com.cloud.consoleproxy.ConsoleProxyRdpClient;
import com.cloud.consoleproxy.util.ImageHelper;
import com.cloud.consoleproxy.util.Logger;
import com.cloud.consoleproxy.util.TileInfo;
import com.cloud.consoleproxy.vnc.FrameBufferCanvas;
@ -35,6 +36,7 @@ public class RdpBufferedImageCanvas extends BufferedImageCanvas implements Frame
*
*/
private static final long serialVersionUID = 1L;
private static final Logger s_logger = Logger.getLogger(RdpBufferedImageCanvas.class);
private final ConsoleProxyRdpClient _rdpClient;
@ -66,6 +68,7 @@ public class RdpBufferedImageCanvas extends BufferedImageCanvas implements Frame
try {
imgBits = ImageHelper.jpegFromImage(bufferedImage);
} catch (IOException e) {
s_logger.info("[ignored] read error on image", e);
}
return imgBits;
@ -91,6 +94,7 @@ public class RdpBufferedImageCanvas extends BufferedImageCanvas implements Frame
try {
imgBits = ImageHelper.jpegFromImage(bufferedImage);
} catch (IOException e) {
s_logger.info("[ignored] read error on image tiles", e);
}
return imgBits;
}

View File

@ -27,6 +27,7 @@ import java.io.IOException;
import java.util.List;
import com.cloud.consoleproxy.util.ImageHelper;
import com.cloud.consoleproxy.util.Logger;
import com.cloud.consoleproxy.util.TileInfo;
/**
@ -35,6 +36,7 @@ import com.cloud.consoleproxy.util.TileInfo;
*/
public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
private static final long serialVersionUID = 1L;
private static final Logger s_logger = Logger.getLogger(BufferedImageCanvas.class);
// Offline screen buffer
private BufferedImage offlineImage;
@ -42,7 +44,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
// Cached Graphics2D object for offline screen buffer
private Graphics2D graphics;
private PaintNotificationListener listener;
private final PaintNotificationListener listener;
public BufferedImageCanvas(PaintNotificationListener listener, int width, int height) {
super();
@ -59,7 +61,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
}
public void setCanvasSize(int width, int height) {
this.offlineImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
offlineImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
graphics = offlineImage.createGraphics();
setSize(offlineImage.getWidth(), offlineImage.getHeight());
@ -121,6 +123,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
try {
imgBits = ImageHelper.jpegFromImage(bufferedImage);
} catch (IOException e) {
s_logger.info("[ignored] read error on image", e);
}
return imgBits;
}
@ -144,6 +147,7 @@ public class BufferedImageCanvas extends Canvas implements FrameBufferCanvas {
try {
imgBits = ImageHelper.jpegFromImage(bufferedImage);
} catch (IOException e) {
s_logger.info("[ignored] read error on image tiles", e);
}
return imgBits;
}

View File

@ -23,9 +23,11 @@ import java.awt.image.DataBufferInt;
import java.io.DataInputStream;
import java.io.IOException;
import com.cloud.consoleproxy.util.Logger;
import com.cloud.consoleproxy.vnc.VncScreenDescription;
public class RawRect extends AbstractRect {
private static final Logger s_logger = Logger.getLogger(RawRect.class);
private final int[] buf;
public RawRect(VncScreenDescription screen, int x, int y, int width, int height, DataInputStream is) throws IOException {
@ -50,26 +52,27 @@ public class RawRect extends AbstractRect {
switch (dataBuf.getDataType()) {
case DataBuffer.TYPE_INT: {
// We chose RGB888 model, so Raster will use DataBufferInt type
DataBufferInt dataBuffer = (DataBufferInt)dataBuf;
case DataBuffer.TYPE_INT: {
// We chose RGB888 model, so Raster will use DataBufferInt type
DataBufferInt dataBuffer = (DataBufferInt)dataBuf;
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
// Paint rectangle directly on buffer, line by line
int[] imageBuffer = dataBuffer.getData();
for (int srcLine = 0, dstLine = y; srcLine < height && dstLine < imageHeight; srcLine++, dstLine++) {
try {
System.arraycopy(buf, srcLine * width, imageBuffer, x + dstLine * imageWidth, width);
} catch (IndexOutOfBoundsException e) {
}
// Paint rectangle directly on buffer, line by line
int[] imageBuffer = dataBuffer.getData();
for (int srcLine = 0, dstLine = y; srcLine < height && dstLine < imageHeight; srcLine++, dstLine++) {
try {
System.arraycopy(buf, srcLine * width, imageBuffer, x + dstLine * imageWidth, width);
} catch (IndexOutOfBoundsException e) {
s_logger.info("[ignored] buffer overflow!?!", e);
}
break;
}
break;
}
default:
throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: " +
default:
throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: " +
dataBuf.getClass().getSimpleName());
}
}