Use a defensive copy for shorter lock time
This commit is contained in:
parent
499337c98e
commit
58ca63e2b1
@ -82,17 +82,23 @@ public class YamlReconnectHandler extends AbstractReconnectManager
|
|||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
|
Map<String, String> copy = new HashMap<>();
|
||||||
lock.readLock().lock();
|
lock.readLock().lock();
|
||||||
try ( FileWriter wr = new FileWriter( file ) )
|
try
|
||||||
{
|
{
|
||||||
yaml.dump( data, wr );
|
copy.putAll( data );
|
||||||
} catch ( IOException ex )
|
|
||||||
{
|
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not save reconnect locations", ex );
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
lock.readLock().unlock();
|
lock.readLock().unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try ( FileWriter wr = new FileWriter( file ) )
|
||||||
|
{
|
||||||
|
yaml.dump( copy, wr );
|
||||||
|
} catch ( IOException ex )
|
||||||
|
{
|
||||||
|
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not save reconnect locations", ex );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user