fix NullPointerException when the element is null in the cache