1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-28 08:50:02 +02:00

Throw exception after 5 attempts

This commit is contained in:
snowleo
2012-08-05 19:50:37 +02:00
parent 71b3f7d631
commit c238ad213a

View File

@@ -118,7 +118,7 @@ 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());
boolean retry; int retry = 0;
do do
{ {
try try
@@ -133,15 +133,19 @@ public class EssentialsConf extends YamlConfiguration
{ {
channel.read(buffer, left); channel.read(buffer, left);
} }
retry = false; retry = 0;
} }
catch (ClosedByInterruptException ex) catch (ClosedByInterruptException ex)
{ {
buffer.rewind(); buffer.rewind();
retry = true; retry++;
if (retry >= 5)
{
throw ex;
}
} }
} }
while (retry); while (retry > 0);
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();