diff --git a/LaunchServer/source/LaunchServer.java b/LaunchServer/source/LaunchServer.java index c8cb5bd..dab9f64 100644 --- a/LaunchServer/source/LaunchServer.java +++ b/LaunchServer/source/LaunchServer.java @@ -324,19 +324,19 @@ private void shutdownHook() { serverSocketHandler.close(); - // Flush handlers & providers + // Close handlers & providers try { - config.authHandler.flush(); + config.authHandler.close(); } catch (IOException e) { LogHelper.error(e); } try { - config.authProvider.flush(); + config.authProvider.close(); } catch (IOException e) { LogHelper.error(e); } try { - config.textureProvider.flush(); + config.textureProvider.close(); } catch (IOException e) { LogHelper.error(e); } diff --git a/LaunchServer/source/auth/MySQLSourceConfig.java b/LaunchServer/source/auth/MySQLSourceConfig.java index 87cc736..69edcd0 100644 --- a/LaunchServer/source/auth/MySQLSourceConfig.java +++ b/LaunchServer/source/auth/MySQLSourceConfig.java @@ -1,7 +1,6 @@ package launchserver.auth; import javax.sql.DataSource; -import java.io.Flushable; import java.sql.Connection; import java.sql.SQLException; @@ -16,7 +15,7 @@ import launcher.serialize.config.entry.IntegerConfigEntry; import launcher.serialize.config.entry.StringConfigEntry; -public final class MySQLSourceConfig extends ConfigObject implements Flushable { +public final class MySQLSourceConfig extends ConfigObject implements AutoCloseable { @LauncherAPI public static final int TIMEOUT = VerifyHelper.verifyInt( Integer.parseUnsignedInt(System.getProperty("launcher.mysql.timeout", Integer.toString(5))), VerifyHelper.POSITIVE, "launcher.mysql.timeout can't be <= 0"); @@ -59,7 +58,7 @@ } @Override - public synchronized void flush() { + public synchronized void close() { if (hikari) { // Shutdown hikari pool ((HikariDataSource) source).close(); } diff --git a/LaunchServer/source/auth/handler/AuthHandler.java b/LaunchServer/source/auth/handler/AuthHandler.java index 0ad6b6e..d04462d 100644 --- a/LaunchServer/source/auth/handler/AuthHandler.java +++ b/LaunchServer/source/auth/handler/AuthHandler.java @@ -1,6 +1,5 @@ package launchserver.auth.handler; -import java.io.Flushable; import java.io.IOException; import java.util.Map; import java.util.Objects; @@ -13,7 +12,7 @@ import launcher.serialize.config.entry.BlockConfigEntry; import launchserver.auth.AuthException; -public abstract class AuthHandler extends ConfigObject implements Flushable { +public abstract class AuthHandler extends ConfigObject implements AutoCloseable { private static final Map> AUTH_HANDLERS = new ConcurrentHashMap<>(4); @LauncherAPI @@ -21,6 +20,9 @@ super(block); } + @Override + public abstract void close() throws IOException; + @LauncherAPI public abstract UUID auth(String username, String accessToken) throws IOException; diff --git a/LaunchServer/source/auth/handler/FileAuthHandler.java b/LaunchServer/source/auth/handler/FileAuthHandler.java index 1913cd6..bf160fc 100644 --- a/LaunchServer/source/auth/handler/FileAuthHandler.java +++ b/LaunchServer/source/auth/handler/FileAuthHandler.java @@ -94,7 +94,7 @@ } @Override - public final void flush() throws IOException { + public final void close() throws IOException { lock.readLock().lock(); try { LogHelper.info("Writing auth handler file (%d entries)", entryMap.size()); diff --git a/LaunchServer/source/auth/handler/MemoryAuthHandler.java b/LaunchServer/source/auth/handler/MemoryAuthHandler.java index 3d24841..7d9e8ed 100644 --- a/LaunchServer/source/auth/handler/MemoryAuthHandler.java +++ b/LaunchServer/source/auth/handler/MemoryAuthHandler.java @@ -17,7 +17,7 @@ } @Override - public void flush() throws IOException { + public void close() { // Do nothing } diff --git a/LaunchServer/source/auth/handler/MySQLAuthHandler.java b/LaunchServer/source/auth/handler/MySQLAuthHandler.java index 56723af..4e37686 100644 --- a/LaunchServer/source/auth/handler/MySQLAuthHandler.java +++ b/LaunchServer/source/auth/handler/MySQLAuthHandler.java @@ -72,8 +72,8 @@ } @Override - public void flush() { - mySQLHolder.flush(); + public void close() { + mySQLHolder.close(); } @Override diff --git a/LaunchServer/source/auth/handler/NullAuthHandler.java b/LaunchServer/source/auth/handler/NullAuthHandler.java index 23e7185..e748171 100644 --- a/LaunchServer/source/auth/handler/NullAuthHandler.java +++ b/LaunchServer/source/auth/handler/NullAuthHandler.java @@ -25,10 +25,10 @@ } @Override - public void flush() throws IOException { + public void close() throws IOException { AuthHandler handler = this.handler; if (handler != null) { - handler.flush(); + handler.close(); } } diff --git a/LaunchServer/source/auth/provider/AcceptAuthProvider.java b/LaunchServer/source/auth/provider/AcceptAuthProvider.java index 2156849..660bb8c 100644 --- a/LaunchServer/source/auth/provider/AcceptAuthProvider.java +++ b/LaunchServer/source/auth/provider/AcceptAuthProvider.java @@ -13,7 +13,7 @@ } @Override - public void flush() { + public void close() { // Do nothing } } diff --git a/LaunchServer/source/auth/provider/AuthProvider.java b/LaunchServer/source/auth/provider/AuthProvider.java index 9a1fb73..714a9b2 100644 --- a/LaunchServer/source/auth/provider/AuthProvider.java +++ b/LaunchServer/source/auth/provider/AuthProvider.java @@ -1,6 +1,6 @@ package launchserver.auth.provider; -import java.io.Flushable; +import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; @@ -11,7 +11,7 @@ import launcher.serialize.config.entry.BlockConfigEntry; import launchserver.auth.AuthException; -public abstract class AuthProvider extends ConfigObject implements Flushable { +public abstract class AuthProvider extends ConfigObject implements AutoCloseable { private static final Map> AUTH_PROVIDERS = new ConcurrentHashMap<>(8); @LauncherAPI @@ -19,6 +19,9 @@ super(block); } + @Override + public abstract void close() throws IOException; + @LauncherAPI public abstract String auth(String login, String password) throws Exception; diff --git a/LaunchServer/source/auth/provider/FileAuthProvider.java b/LaunchServer/source/auth/provider/FileAuthProvider.java index e9e3121..3b005db 100644 --- a/LaunchServer/source/auth/provider/FileAuthProvider.java +++ b/LaunchServer/source/auth/provider/FileAuthProvider.java @@ -52,7 +52,7 @@ } @Override - public void flush() { + public void close() { // Do nothing } diff --git a/LaunchServer/source/auth/provider/MySQLAuthProvider.java b/LaunchServer/source/auth/provider/MySQLAuthProvider.java index f1cba03..a3cf2b3 100644 --- a/LaunchServer/source/auth/provider/MySQLAuthProvider.java +++ b/LaunchServer/source/auth/provider/MySQLAuthProvider.java @@ -46,7 +46,7 @@ } @Override - public void flush() { + public void close() { // Do nothing } } diff --git a/LaunchServer/source/auth/provider/NullAuthProvider.java b/LaunchServer/source/auth/provider/NullAuthProvider.java index d63f909..0e24277 100644 --- a/LaunchServer/source/auth/provider/NullAuthProvider.java +++ b/LaunchServer/source/auth/provider/NullAuthProvider.java @@ -19,10 +19,10 @@ } @Override - public void flush() throws IOException { + public void close() throws IOException { AuthProvider provider = this.provider; if (provider != null) { - provider.flush(); + provider.close(); } } diff --git a/LaunchServer/source/auth/provider/RejectAuthProvider.java b/LaunchServer/source/auth/provider/RejectAuthProvider.java index 054d047..30fbe34 100644 --- a/LaunchServer/source/auth/provider/RejectAuthProvider.java +++ b/LaunchServer/source/auth/provider/RejectAuthProvider.java @@ -20,7 +20,7 @@ } @Override - public void flush() { + public void close() { // Do nothing } } diff --git a/LaunchServer/source/auth/provider/RequestAuthProvider.java b/LaunchServer/source/auth/provider/RequestAuthProvider.java index 66726e5..c56bd8c 100644 --- a/LaunchServer/source/auth/provider/RequestAuthProvider.java +++ b/LaunchServer/source/auth/provider/RequestAuthProvider.java @@ -34,7 +34,7 @@ } @Override - public void flush() { + public void close() { // Do nothing } diff --git a/LaunchServer/source/texture/NullTextureProvider.java b/LaunchServer/source/texture/NullTextureProvider.java index fed0be0..98937af 100644 --- a/LaunchServer/source/texture/NullTextureProvider.java +++ b/LaunchServer/source/texture/NullTextureProvider.java @@ -16,10 +16,10 @@ } @Override - public void flush() throws IOException { + public void close() throws IOException { TextureProvider provider = this.provider; if (provider != null) { - provider.flush(); + provider.close(); } } diff --git a/LaunchServer/source/texture/RequestTextureProvider.java b/LaunchServer/source/texture/RequestTextureProvider.java index 4adae04..a97a254 100644 --- a/LaunchServer/source/texture/RequestTextureProvider.java +++ b/LaunchServer/source/texture/RequestTextureProvider.java @@ -30,7 +30,7 @@ } @Override - public void flush() throws IOException { + public void close() { // Do nothing } diff --git a/LaunchServer/source/texture/TextureProvider.java b/LaunchServer/source/texture/TextureProvider.java index 0c88fd8..e172127 100644 --- a/LaunchServer/source/texture/TextureProvider.java +++ b/LaunchServer/source/texture/TextureProvider.java @@ -1,6 +1,5 @@ package launchserver.texture; -import java.io.Flushable; import java.io.IOException; import java.util.Map; import java.util.Objects; @@ -13,7 +12,7 @@ import launcher.serialize.config.ConfigObject; import launcher.serialize.config.entry.BlockConfigEntry; -public abstract class TextureProvider extends ConfigObject implements Flushable { +public abstract class TextureProvider extends ConfigObject implements AutoCloseable { private static final Map> TEXTURE_PROVIDERS = new ConcurrentHashMap<>(2); @LauncherAPI @@ -35,6 +34,9 @@ return authHandlerAdapter.convert(block); } + @Override + public abstract void close() throws IOException; + @LauncherAPI public static void registerProvider(String name, Adapter adapter) { VerifyHelper.putIfAbsent(TEXTURE_PROVIDERS, name, Objects.requireNonNull(adapter, "adapter"), diff --git a/LaunchServer/source/texture/VoidTextureProvider.java b/LaunchServer/source/texture/VoidTextureProvider.java index b681fdb..6e31f32 100644 --- a/LaunchServer/source/texture/VoidTextureProvider.java +++ b/LaunchServer/source/texture/VoidTextureProvider.java @@ -1,6 +1,5 @@ package launchserver.texture; -import java.io.IOException; import java.util.UUID; import launcher.client.PlayerProfile; @@ -12,7 +11,7 @@ } @Override - public void flush() throws IOException { + public void close() { // Do nothing }