mirror of https://github.com/apache/cloudstack.git
CS-15778: Fetching thumbnail modified with review comments
This commit is contained in:
parent
86f2508186
commit
6d356b4b49
|
|
@ -25,7 +25,7 @@ public class AjaxFIFOImageCache {
|
|||
private List<Integer> fifoQueue;
|
||||
private Map<Integer, byte[]> cache;
|
||||
private int cacheSize;
|
||||
private int nextKey = 1;
|
||||
private int nextKey = 0;
|
||||
|
||||
public AjaxFIFOImageCache(int cacheSize) {
|
||||
this.cacheSize = cacheSize;
|
||||
|
|
@ -57,6 +57,9 @@ public class AjaxFIFOImageCache {
|
|||
}
|
||||
|
||||
public synchronized byte[] getImage(int key) {
|
||||
if (key == 0) {
|
||||
key = nextKey;
|
||||
}
|
||||
|
||||
if(cache.containsKey(key)) {
|
||||
if(s_logger.isTraceEnabled())
|
||||
|
|
@ -70,7 +73,7 @@ public class AjaxFIFOImageCache {
|
|||
}
|
||||
|
||||
public synchronized int getNextKey() {
|
||||
return nextKey++;
|
||||
return ++nextKey;
|
||||
}
|
||||
|
||||
public synchronized int getKey() {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class ConsoleProxyAjaxImageHandler implements HttpHandler {
|
|||
ConsoleProxyClient viewer = ConsoleProxy.getVncViewer(param);
|
||||
AjaxFIFOImageCache imageCache =viewer.getAjaxImageCache();
|
||||
|
||||
byte[] img = imageCache.getImage(imageCache.getKey() - 1);
|
||||
byte[] img = imageCache.getImage(0);
|
||||
|
||||
if(img != null) {
|
||||
Headers hds = t.getResponseHeaders();
|
||||
|
|
|
|||
Loading…
Reference in New Issue