mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-14 11:21:21 +01:00
Try to fix interrupt problem.
This commit is contained in:
parent
7beab59c1a
commit
c7b90f61f7
@ -5,6 +5,7 @@ import com.google.common.io.Files;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
@ -117,7 +118,30 @@ public class EssentialsConf extends YamlConfiguration
|
||||
{
|
||||
final FileChannel channel = inputStream.getChannel();
|
||||
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
|
||||
channel.read(buffer);
|
||||
boolean retry;
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
int BUFFERSIZE = 1024;
|
||||
long left = configFile.length() % BUFFERSIZE;
|
||||
for (long i = 0; i < configFile.length() - left; i += BUFFERSIZE)
|
||||
{
|
||||
channel.read(buffer, BUFFERSIZE);
|
||||
}
|
||||
if (left > 0)
|
||||
{
|
||||
channel.read(buffer, left);
|
||||
}
|
||||
retry = false;
|
||||
}
|
||||
catch (ClosedByInterruptException ex)
|
||||
{
|
||||
buffer.rewind();
|
||||
retry = true;
|
||||
}
|
||||
}
|
||||
while (retry);
|
||||
buffer.rewind();
|
||||
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
|
||||
CharsetDecoder decoder = UTF8.newDecoder();
|
||||
|
Loading…
Reference in New Issue
Block a user