Fix resource leak on exception

When an exception is hit in the try statement, the readers will never get closed and leak resources
This commit is contained in:
Felix Bergmann 2020-04-07 10:02:22 +02:00 committed by GitHub
parent 877ef15374
commit 69a4ec80cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,15 +54,15 @@ public class WorldBlacklist {
if(!blacklist.contains(currentLine))
blacklist.add(currentLine);
}
//Close readers
bufferedReader.close();
fileReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
} finally {
//Close readers
if(bufferedReader != null) bufferedReader.close();
if(fileReader != null) fileReader.close();
}
plugin.getLogger().info(blacklist.size()+" entries in mcMMO World Blacklist");