I have apparently missed it when this code was first committed, but even now, it does not guarantee that the entries will really have valueSize - the single read operation (which is here always followed by cacheWrapper.put(...)) may read less than valueSize.
Could you adapt the code so that the buffer is always filled (except for the last buffer)?