summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-08-05 19:41:06 +0200
committersnowleo <schneeleo@gmail.com>2012-08-05 19:41:28 +0200
commitc7b90f61f7653c7cf99a51c342604d04490aff8e (patch)
tree502060add7b1cc3cd1bc039d810f7e05ef50fc13
parent7beab59c1ab49c2d11aee745b1a60e34dbd6f5b4 (diff)
downloadEssentials-c7b90f61f7653c7cf99a51c342604d04490aff8e.tar
Essentials-c7b90f61f7653c7cf99a51c342604d04490aff8e.tar.gz
Essentials-c7b90f61f7653c7cf99a51c342604d04490aff8e.tar.lz
Essentials-c7b90f61f7653c7cf99a51c342604d04490aff8e.tar.xz
Essentials-c7b90f61f7653c7cf99a51c342604d04490aff8e.zip
Try to fix interrupt problem.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsConf.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
index b2cb1fd12..97f4182cb 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java
@@ -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();