2
0

Warning fixes and spotbug configuration tweaks.

This commit is contained in:
Maarten Billemont
2019-09-24 13:06:40 -04:00
parent 36692ac10d
commit fd1014926c
13 changed files with 134 additions and 100 deletions

View File

@@ -24,6 +24,7 @@ import com.google.common.base.Charsets;
import com.google.common.primitives.UnsignedBytes;
import com.lyndir.lhunath.opal.system.MessageAuthenticationDigests;
import com.lyndir.lhunath.opal.system.logging.Logger;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.nio.*;
import java.nio.charset.Charset;
import java.util.Arrays;
@@ -57,6 +58,7 @@ public class MPIdenticon {
this( fullName, masterPassword.toCharArray() );
}
@SuppressFBWarnings("CLI_CONSTANT_LIST_INDEX")
@SuppressWarnings("MethodCanBeVariableArityMethod")
public MPIdenticon(final String fullName, final char[] masterPassword) {
this.fullName = fullName;

View File

@@ -60,17 +60,14 @@ public class MPAlgorithmV0 extends MPAlgorithm {
ByteBuffer masterPasswordBuffer = ByteBuffer.wrap( masterPasswordBytes );
CoderResult result = encoder.encode( CharBuffer.wrap( masterPassword ), masterPasswordBuffer, true );
if (!result.isUnderflow())
result.throwException();
if (result.isError())
throw new IllegalStateException( result.toString() );
result = encoder.flush( masterPasswordBuffer );
if (!result.isUnderflow())
result.throwException();
if (result.isError())
throw new IllegalStateException( result.toString() );
return _masterKey( fullName, masterPasswordBytes, version().toInt() );
}
catch (final CharacterCodingException e) {
throw new IllegalStateException( e );
}
finally {
Arrays.fill( masterPasswordBytes, (byte) 0 );
}

View File

@@ -43,7 +43,7 @@ public final class Native {
private static final char EXTENSION_SEPARATOR = '.';
private static final String NATIVES_PATH = "lib";
@SuppressFBWarnings("PATH_TRAVERSAL_IN")
@SuppressFBWarnings({"PATH_TRAVERSAL_IN", "IOI_USE_OF_FILE_STREAM_CONSTRUCTORS", "EXS_EXCEPTION_SOFTENING_RETURN_FALSE"})
@SuppressWarnings({ "HardcodedFileSeparator", "LoadLibraryWithNonConstantString" })
public static boolean load(final Class<?> context, final String name) {
@@ -89,7 +89,7 @@ public final class Native {
return true;
}
catch (@SuppressWarnings("ErrorNotRethrown") final IOException | UnsatisfiedLinkError e) {
logger.dbg( e, "Couldn't load library: %s", libraryResource );
logger.wrn( e, "Couldn't load library: %s", libraryResource );
if (libraryFile != null)
if (libraryFile.exists() && !libraryFile.delete())