Mix of Checkstyle and SonarLint.

This commit is contained in:
Andrew Steinborn
2018-10-28 03:18:15 -04:00
parent 9806d57a13
commit 1310cd2c53
15 changed files with 98 additions and 53 deletions

View File

@@ -0,0 +1,24 @@
package com.velocitypowered.natives;
public class NativeSetupException extends RuntimeException {
public NativeSetupException() {
}
public NativeSetupException(String message) {
super(message);
}
public NativeSetupException(String message, Throwable cause) {
super(message, cause);
}
public NativeSetupException(Throwable cause) {
super(cause);
}
public NativeSetupException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@@ -1,5 +1,7 @@
package com.velocitypowered.natives.compression;
import static com.velocitypowered.natives.util.NativeConstants.ZLIB_BUFFER_SIZE;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.zip.DataFormatException;

View File

@@ -1,5 +1,7 @@
package com.velocitypowered.natives.compression;
import static com.velocitypowered.natives.util.NativeConstants.ZLIB_BUFFER_SIZE;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.zip.DataFormatException;

View File

@@ -8,12 +8,6 @@ import java.util.zip.DataFormatException;
* Provides an interface to inflate and deflate {@link ByteBuf}s using zlib.
*/
public interface VelocityCompressor extends Disposable {
/**
* The default preferred output buffer size for zlib.
*/
int ZLIB_BUFFER_SIZE = 8192;
void inflate(ByteBuf source, ByteBuf destination) throws DataFormatException;
void deflate(ByteBuf source, ByteBuf destination) throws DataFormatException;

View File

@@ -0,0 +1,12 @@
package com.velocitypowered.natives.util;
public class NativeConstants {
/**
* The default preferred output buffer size for zlib.
*/
public static final int ZLIB_BUFFER_SIZE = 8192;
private NativeConstants() {
throw new AssertionError();
}
}

View File

@@ -1,6 +1,7 @@
package com.velocitypowered.natives.util;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.natives.NativeSetupException;
import com.velocitypowered.natives.compression.JavaVelocityCompressor;
import com.velocitypowered.natives.compression.NativeVelocityCompressor;
import com.velocitypowered.natives.compression.VelocityCompressorFactory;
@@ -37,7 +38,7 @@ public class Natives {
}));
System.load(tempFile.toAbsolutePath().toString());
} catch (IOException e) {
throw new RuntimeException(e);
throw new NativeSetupException("Unable to copy natives", e);
}
};
}
@@ -57,12 +58,12 @@ public class Natives {
public static final NativeCodeLoader<VelocityCipherFactory> cipher = new NativeCodeLoader<>(
ImmutableList.of(
/*new NativeCodeLoader.Variant<>(NativeCodeLoader.MACOS,
copyAndLoadNative("/macosx/velocity-cipher.dylib"), "mbed TLS (macOS)",
NativeVelocityCipher.FACTORY),
new NativeCodeLoader.Variant<>(NativeCodeLoader.LINUX,
copyAndLoadNative("/linux_x64/velocity-cipher.so"), "mbed TLS (Linux amd64)",
NativeVelocityCipher.FACTORY),*/
/*new NativeCodeLoader.Variant<>(NativeCodeLoader.MACOS,
copyAndLoadNative("/macosx/velocity-cipher.dylib"), "mbed TLS (macOS)",
NativeVelocityCipher.FACTORY),
new NativeCodeLoader.Variant<>(NativeCodeLoader.LINUX,
copyAndLoadNative("/linux_x64/velocity-cipher.so"), "mbed TLS (Linux amd64)",
NativeVelocityCipher.FACTORY),*/
new NativeCodeLoader.Variant<>(NativeCodeLoader.ALWAYS, () -> {
}, "Java", JavaVelocityCipher.FACTORY)
)