(Probably) Fix bug where unclosed WatchServices cause inotify limit to fill upp. Also cache the values for a minor speedup.

This commit is contained in:
Olof Larsson 2016-01-21 12:53:48 +01:00
parent b3e117277e
commit 0c2e624f10

View File

@ -3,6 +3,7 @@ package com.massivecraft.massivecore.store;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.WatchService;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
@ -218,12 +219,15 @@ public class DriverFlatfile extends DriverAbstract
file.delete();
}
@Override
public boolean supportsPusher()
private boolean supportsPusher = this.supportsPusherCalc();
private boolean supportsPusherCalc()
{
try
{
return ! ( FileSystems.getDefault().newWatchService().getClass().getName().equals("sun.nio.fs.PollingWatchService"));
WatchService watchService = FileSystems.getDefault().newWatchService();
boolean ret = ! watchService.getClass().getName().equals("sun.nio.fs.PollingWatchService");
watchService.close();
return ret;
}
catch (IOException e)
{
@ -231,6 +235,12 @@ public class DriverFlatfile extends DriverAbstract
}
}
@Override
public boolean supportsPusher()
{
return this.supportsPusher;
}
@Override
public PusherColl getPusher(Coll<?> coll)
{