mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-13 17:04:25 +00:00
fix: preserve scheduler save IOException propagation
This commit is contained in:
1 parent
0372a7f701
commit
cb611cee1a
2 files changed
+31
-1
No files matched your search
@@ -183,7 +183,7 @@ public final class TickScheduler {
|
||||
CompressedStreamTools.writeCompressed(saveTag(), dout);
|
||||
dout.close();
|
||||
} catch (java.io.IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw TickScheduler.<RuntimeException>rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +316,11 @@ public final class TickScheduler {
|
||||
return new WorldTickScheduler(world);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Throwable> RuntimeException rethrow(Throwable throwable) throws T {
|
||||
throw (T) throwable;
|
||||
}
|
||||
|
||||
public static ChunkExtension createChunkExtension(Chunk chunk, WorldExtension world) {
|
||||
return new ChunkTickScheduler(chunk, (WorldTickScheduler) world);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package codechicken.multipart;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
class TickSchedulerSaveFailureRegressionTest {
|
||||
|
||||
@Test
|
||||
void savePropagatesTheOriginalIoException(@TempDir Path directory) {
|
||||
TickScheduler.WorldTickScheduler scheduler = new TickScheduler.WorldTickScheduler(null) {
|
||||
|
||||
@Override
|
||||
File saveFile() {
|
||||
return directory.toFile();
|
||||
}
|
||||
};
|
||||
assertThrows(IOException.class, scheduler::save);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user