Amadeu Cabanilles Amadeu Cabanilles - 1 month ago 5
Java Question

java ConcurrentMap get in null

I have this ConcurrentMap

ConcurrentMap<String, Byte[]> companyLogo = new MapMaker()
.concurrencyLevel(Runtime.getRuntime().availableProcessors())
.weakKeys()
.initialCapacity(1000)
.expiration(24, TimeUnit.HOURS)
.makeMap();


and this piece of code

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


But
companyLogo.get("cpr48124");
is null. How can it be possible ?

Answer

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.

Comments