Open LadyCailinBot opened 7 years ago
The code here has moved around some, but looking through the history, I now see that this corresponds to here (PersistenceNetworkImpl.java#L99), on the ds.get(key)
line, so this must be ThreadsafeDataSource.GetDataSource returning null.
Looking at that code, I see that SOURCES is a WeakHashMap, and the thing about WeakHashMaps is that they use the WeakReference class, so the values in the Map could just.. go away from time to time, if nothing is concretely using them.
That said, there is still a check there:
ThreadsafeDataSource source = SOURCES.get(pair);
if(source != null) {
return source;
} else {
ThreadsafeDataSource ds = new ThreadsafeDataSource(DataSourceFactory.GetDataSource(uri, options));
SOURCES.put(pair, ds);
return ds;
}
So if the source is null, we build a new one. The WeakHashMap only uses WeakReferences on the keys though, so.. I feel sure that this is related, but I can't see how. If we're about to return null, we don't, and in the else case, we return ds (guaranteed not null) so.. there must be something else going on here, but I don't understand it.
CMDHELPER-3153 - Reported by PseudoKnight
Not sure what's going on here, but I thought I'd add this to keep track of it. This code has run countless times with no issue.