Fix rare null pointer race condition
This commit is contained in:
+4
-2
@@ -84,9 +84,11 @@ public class ColumnRenderBuffer implements AutoCloseable
|
||||
/** Should be run on a DH thread. */
|
||||
public synchronized CompletableFuture<ColumnRenderBuffer> makeAndUploadBuffersAsync(LodQuadBuilder builder, EDhApiGpuUploadMethod gpuUploadMethod)
|
||||
{
|
||||
if (this.uploadFuture != null)
|
||||
// separate variable to prevent race condition when checking null
|
||||
CompletableFuture<ColumnRenderBuffer> future = this.uploadFuture;
|
||||
if (future != null)
|
||||
{
|
||||
return this.uploadFuture;
|
||||
return future;
|
||||
}
|
||||
this.uploadFuture = new CompletableFuture<>();
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class ColumnRenderBufferBuilder
|
||||
uploadFuture.whenComplete((uploadedBuffer, exception) ->
|
||||
{
|
||||
// clean up if not uploaded
|
||||
if (!uploadedBuffer.buffersUploaded)
|
||||
if (uploadedBuffer != null && !uploadedBuffer.buffersUploaded)
|
||||
{
|
||||
uploadedBuffer.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user