From 2d472ce8a27063228b84292b28066dbe3453eef4 Mon Sep 17 00:00:00 2001 From: Eric Trautman Date: Thu, 10 Jan 2019 23:45:51 -0500 Subject: [PATCH] fix stupid bug that should have been caught in prior commit --- .../org/janelia/alignment/util/ImageProcessorCache.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/render-app/src/main/java/org/janelia/alignment/util/ImageProcessorCache.java b/render-app/src/main/java/org/janelia/alignment/util/ImageProcessorCache.java index 25d20342e..e576a04e2 100644 --- a/render-app/src/main/java/org/janelia/alignment/util/ImageProcessorCache.java +++ b/render-app/src/main/java/org/janelia/alignment/util/ImageProcessorCache.java @@ -79,15 +79,15 @@ public ImageProcessorCache(final long maximumNumberOfCachedPixels, final Weigher weigher = (key, value) -> { - final long bitCount = value.getPixelCount() * value.getBitDepth(); + final long bitCount = ((long) value.getPixelCount()) * value.getBitDepth(); final long kilobyteCount = bitCount / 8000L; final int weight; - if (kilobyteCount > Integer.MAX_VALUE) { + if (kilobyteCount < 0 || kilobyteCount > Integer.MAX_VALUE) { weight = Integer.MAX_VALUE; LOG.warn("{} is too large ({} kilobytes) for cache weight function, using max weight of {}", key, kilobyteCount, weight); } else { - weight = (int) kilobyteCount; + weight = Math.max(1, (int) kilobyteCount); } return weight; };