You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
method "TransitionBuffer get( EntityId id, int size )"
doesnt provide the WeakReference with the ReferenceQueue, hence the while loop condition will never be true. When using the ReferenceQueue, the WeakReference to the buffer might get GCed though before that buffer is returned, meaning the method could potentially return null (could return null currently too, just really unlikely). this might be a fix:
protected synchronized TransitionBuffer get( EntityId id, int size ) {
// See if we've already got one
WeakReference<TransitionBuffer> result = map.get(id);
TransitionBuffer buffer;
// If result is null, we definitely need to create a new one
// if its not null, we assign result.get() before doing the condition check
// since even when result.get() is not null, we might get null from a following result.get() call
if( result == null || (buffer = result.get()) == null ) {
// Need to create a new one
buffer = PositionTransition.createBuffer(size);
map.put(id, new WeakReference<>(buffer, refs));
}
// Clean out any dead references to keep our map from growing and growing
Reference toRemove;
while( (toRemove = refs.poll()) != null ) {
map.values().remove(toRemove);
}
return buffer;
}
The text was updated successfully, but these errors were encountered:
method "TransitionBuffer get( EntityId id, int size )"
doesnt provide the WeakReference with the ReferenceQueue, hence the while loop condition will never be true. When using the ReferenceQueue, the WeakReference to the buffer might get GCed though before that buffer is returned, meaning the method could potentially return null (could return null currently too, just really unlikely). this might be a fix:
protected synchronized TransitionBuffer get( EntityId id, int size ) {
// See if we've already got one
WeakReference<TransitionBuffer> result = map.get(id);
TransitionBuffer buffer;
// If result is null, we definitely need to create a new one
// if its not null, we assign result.get() before doing the condition check
// since even when result.get() is not null, we might get null from a following result.get() call
if( result == null || (buffer = result.get()) == null ) {
// Need to create a new one
buffer = PositionTransition.createBuffer(size);
map.put(id, new WeakReference<>(buffer, refs));
}
// Clean out any dead references to keep our map from growing and growing
Reference toRemove;
while( (toRemove = refs.poll()) != null ) {
map.values().remove(toRemove);
}
return buffer;
}
The text was updated successfully, but these errors were encountered: