2016-10-27 17 views
2

我有這樣的ConcurrentMapjava的ConcurrentMap得到空

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

這一段代碼

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

companyLogo.get("cpr48124");爲空。怎麼可能?

+0

嘗試打印出來: ArrayUtils.toObject(resize(request,((Byte [])request.getSession()。getAttribute(COMPANY_LOGO_KEY + imageId)))) – Arctigor

+1

我不熟悉'MapMaker',但我猜想'weakKeys'可能是你的問題。 – bradimus

+0

你有沒有嘗試過另一個字節[],我的意思是「ssssss」.getBytes()...或類似的東西,只是爲了測試它?這可能是你會話屬性的問題 –

回答

1

我不熟悉MapMaker是的,但我猜weakKeys可能是你的問題。

您的新條目的「弱點」可能會導致它無法使用,因爲沒有其他參考。