Skip to content

Commit

Permalink
fix stupid bug that should have been caught in prior commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed Jan 11, 2019
1 parent 25e408f commit 2d472ce
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ public ImageProcessorCache(final long maximumNumberOfCachedPixels,

final Weigher<CacheKey, ImageProcessor> 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;
};
Expand Down

0 comments on commit 2d472ce

Please sign in to comment.