Make Disposable interface implement Closeable
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
package com.velocitypowered.natives;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
* This marker interface indicates that this object should be explicitly disposed before the object
|
||||
* can no longer be used. Not disposing these objects will likely leak native resources and
|
||||
* eventually lead to resource exhaustion.
|
||||
*/
|
||||
public interface Disposable {
|
||||
public interface Disposable extends Closeable {
|
||||
|
||||
/**
|
||||
* Disposes this object. After this call returns, any use of this object becomes invalid. Multiple
|
||||
* calls to this function should be safe: there should be no side-effects once an object is
|
||||
* disposed.
|
||||
*/
|
||||
void dispose();
|
||||
@Override
|
||||
void close();
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ public class Java11VelocityCompressor implements VelocityCompressor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
disposed = true;
|
||||
deflater.end();
|
||||
inflater.end();
|
||||
|
@@ -118,7 +118,7 @@ public class JavaVelocityCompressor implements VelocityCompressor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
disposed = true;
|
||||
deflater.end();
|
||||
inflater.end();
|
||||
|
@@ -70,7 +70,7 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
if (!disposed) {
|
||||
inflate.free(inflateCtx);
|
||||
deflate.free(deflateCtx);
|
||||
|
@@ -55,7 +55,7 @@ public class JavaVelocityCipher implements VelocityCipher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public class NativeVelocityCipher implements VelocityCipher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void close() {
|
||||
if (!disposed) {
|
||||
impl.free(ctx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user