Skip to content

Commit

Permalink
Fix rare region future NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
itsMatoosh committed May 17, 2022
1 parent 2f94b51 commit da53d7a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'me.matoosh'
version '1.6.0'
version '1.6.1'

sourceCompatibility = JavaVersion.VERSION_1_8

Expand All @@ -29,7 +29,7 @@ dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'

// lombok
compileOnly 'org.projectlombok:lombok:1.18.22'
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.22'

testCompileOnly 'org.projectlombok:lombok:1.18.22'
Expand All @@ -42,11 +42,11 @@ dependencies {
implementation 'com.github.seeseemelk:MockBukkit:v1.16-SNAPSHOT'

// mockito
testImplementation 'org.mockito:mockito-core:4.1.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.1.0'
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'org.mockito:mockito-junit-jupiter:4.5.1'

// assertj
testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation 'org.assertj:assertj-core:3.22.0'
}

test {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,16 @@ public CompletableFuture<Region> getRegion(@NonNull ChunkInfo chunkInfo) {
String regionKey = getRegionKey(chunkInfo);
Region region = regions.get(regionKey);
if (region == null) {
// buffer region
// create region object
Path regionPath = getRegionFile(chunkInfo);
Region newRegion = new Region(regionKey, chunkInfo.getWorld(), regionPath);
regions.put(newRegion.getKey(), newRegion);

// load region
ExecutorService regionExeService = Executors.newSingleThreadExecutor();
CompletableFuture<Void> loadFuture = loadRegion(newRegion.getFilePath(), regionExeService)
.thenAccept(newRegion::setBuffer);
newRegion.setLoadFuture(loadFuture);
regions.put(newRegion.getKey(), newRegion);

// wait until region loads
return newRegion.getLoadFuture().thenApply((d) -> newRegion);
Expand Down

0 comments on commit da53d7a

Please sign in to comment.