Throw exception after 5 attempts

This commit is contained in:
snowleo 2012-08-05 19:50:37 +02:00
parent c7b90f61f7
commit c6617324af

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();