mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-05 12:02:53 +00:00
Try to fix interrupt problem.
This commit is contained in:
parent
7beab59c1a
commit
c7b90f61f7
1 changed files with 25 additions and 1 deletions
|
@ -5,6 +5,7 @@ import com.google.common.io.Files;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
|
import java.nio.channels.ClosedByInterruptException;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
|
@ -117,7 +118,30 @@ public class EssentialsConf extends YamlConfiguration
|
||||||
{
|
{
|
||||||
final FileChannel channel = inputStream.getChannel();
|
final FileChannel channel = inputStream.getChannel();
|
||||||
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
|
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();
|
buffer.rewind();
|
||||||
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
|
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
|
||||||
CharsetDecoder decoder = UTF8.newDecoder();
|
CharsetDecoder decoder = UTF8.newDecoder();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue