I have the following code:
public class MyEvent implements org.apache.camel.Processor
{
static private final Map<Long, String> obj = new ConcurrentHashMap<Long, String>();
@PostConstruct
public void postConstruct()
{
for (Object object : cacheList)
{
obj.put(object.getId(), object.getName());
}
}
@Override
public void process(Exchange exchange) throws Exception
{
synchronized (obj)
{
String value = obj.get(number);
}
}
}
Sometimes when starting, I have a NullPointerException
in this line:
String value = obj.get(number);
My question is: Why do I get this error and how can I fix it?
Java version 1.6.0_32