google / guava

Google core libraries for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why do I occasionally get NullPointerException when I access concurrently?

ChaimNJ opened this issue · comments

commented

image

guava version is 30.1.1-jre
use jdk17

use example: cache.get(id, () -> test.query(id))

i can't understand why it throw NullPointException

@ChaimNJ It's most likely because id is sometimes null.

What happens if you ensure that the IDs you pass in are never null?

commented

@ChaimNJ It's most likely because id is sometimes null.

What happens if you ensure that the IDs you pass in are never null?

Thanks, i will check why id is sometimes null