Amadeu Cabanilles Amadeu Cabanilles - 1 year ago 55
Java Question

java ConcurrentMap get in null

I have this ConcurrentMap

ConcurrentMap<String, Byte[]> companyLogo = new MapMaker()
.expiration(24, TimeUnit.HOURS)

and this piece of code

companyLogo.put("cpr48124", ArrayUtils.toObject(resize (request, ((Byte[])request.getSession().getAttribute(COMPANY_LOGO_KEY+ imageId)))));

is null. How can it be possible ?

Answer Source

I'm not familiar with MapMaker is, but I'd guess that weakKeys might be your problem.

It is likely that the 'weakness' of your new entry is making it unavailable since there are no other references to it.