[close #671] remove shadowing of netty && grpc (#781) #472
SpotBugs Source Code Analyzer report
71 violation(s) found
Annotations
Check warning on line 75 in src/main/java/org/tikv/common/MetricsServer.java
github-actions / checks-spotbugs
ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
Write to static field org.tikv.common.MetricsServer.METRICS_SERVER_INSTANCE from instance method org.tikv.common.MetricsServer.close()
Raw output
This instance method writes to a static field. This is tricky to get correct if multiple instances are being manipulated, and generally bad practice.
Check warning on line 79 in src/main/java/org/tikv/common/MetricsServer.java
github-actions / checks-spotbugs
ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD
Write to static field org.tikv.common.MetricsServer.metricsServerRefCount from instance method org.tikv.common.MetricsServer.close()
Raw output
This instance method writes to a static field. This is tricky to get correct if multiple instances are being manipulated, and generally bad practice.
Check warning on line 235 in src/main/java/org/tikv/common/PDClient.java
github-actions / checks-spotbugs
NP_BOOLEAN_RETURN_NULL
org.tikv.common.PDClient.isCheckerPaused(PDChecker) has Boolean return type and returns explicit null
Raw output
A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. This method can be invoked as though it returned a value of type boolean, and the compiler will insert automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.
Check warning on line 400 in src/main/java/org/tikv/common/TiConfiguration.java
github-actions / checks-spotbugs
UPM_UNCALLED_PRIVATE_METHOD
Private method org.tikv.common.TiConfiguration.getBoolean(String, boolean) is never called
Raw output
This private method is never called. Although it is possible that the method will be invoked through reflection, it is more likely that the method is never used, and should be removed.
Check warning on line 381 in src/main/java/org/tikv/common/TiConfiguration.java
github-actions / checks-spotbugs
UPM_UNCALLED_PRIVATE_METHOD
Private method org.tikv.common.TiConfiguration.getDouble(String) is never called
Raw output
This private method is never called. Although it is possible that the method will be invoked through reflection, it is more likely that the method is never used, and should be removed.
Check warning on line 364 in src/main/java/org/tikv/common/TiConfiguration.java
github-actions / checks-spotbugs
UPM_UNCALLED_PRIVATE_METHOD
Private method org.tikv.common.TiConfiguration.getInt(String, int) is never called
Raw output
This private method is never called. Although it is possible that the method will be invoked through reflection, it is more likely that the method is never used, and should be removed.
Check warning on line 750 in src/main/java/org/tikv/common/TiSession.java
github-actions / checks-spotbugs
SWL_SLEEP_WITH_LOCK_HELD
org.tikv.common.TiSession.closeAwaitTermination(long) calls Thread.sleep() with a lock held
Raw output
This method calls Thread.sleep() with a lock held. This may result in very poor performance and scalability, or a deadlock, since other threads may be waiting to acquire the lock. It is a much better idea to call wait() on the lock, which releases the lock and allows other threads to run.
Check warning on line 59 in src/main/java/org/tikv/common/catalog/CatalogTransaction.java
github-actions / checks-spotbugs
VA_FORMAT_STRING_USES_NEWLINE
Format string should use %n rather than \n in org.tikv.common.catalog.CatalogTransaction.parseFromJson(ByteString, Class)
Raw output
This format string includes a newline character (\n). In format strings, it is generally preferable to use %n, which will produce the platform-specific line separator.
Check warning on line 123 in src/main/java/org/tikv/common/codec/CodecDataInput.java
github-actions / checks-spotbugs
RR_NOT_CHECKED
org.tikv.common.codec.CodecDataInput.readPartialUnsignedShort() ignores result of java.io.DataInputStream.read(byte[], int, int)
Raw output
This method ignores the return value of one of the variants of java.io.InputStream.read() which can return multiple bytes. If the return value is not checked, the caller will not be able to correctly handle the case where fewer bytes were read than the caller requested. This is a particularly insidious kind of bug, because in many programs, reads from input streams usually do read the full amount of data requested, causing the program to fail only sporadically.
Check warning on line 86 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.codec.MetaCodec.autoTableIDKey(long): String.getBytes()
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
Check warning on line 72 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.codec.MetaCodec.decodeHashDataKey(ByteString): new String(byte[])
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
Check warning on line 94 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.codec.MetaCodec.encodeDatabaseID(long): String.getBytes()
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
Check warning on line 90 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.codec.MetaCodec.tableKey(long): String.getBytes()
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
Check warning on line 40 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
MS_SHOULD_BE_FINAL
org.tikv.common.codec.MetaCodec.KEY_DBs isn't final but should be
Raw output
This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.
Check warning on line 42 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
MS_SHOULD_BE_FINAL
org.tikv.common.codec.MetaCodec.KEY_SCHEMA_VERSION isn't final but should be
Raw output
This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.
Check warning on line 41 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
MS_SHOULD_BE_FINAL
org.tikv.common.codec.MetaCodec.KEY_TABLE isn't final but should be
Raw output
This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.
Check warning on line 75 in src/main/java/org/tikv/common/codec/MetaCodec.java
github-actions / checks-spotbugs
SR_NOT_CHECKED
org.tikv.common.codec.MetaCodec.decodeHashDataKey(ByteString) ignores result of org.tikv.common.codec.CodecDataInput.skipBytes(int)
Raw output
This method ignores the return value of java.io.InputStream.skip() which can skip multiple bytes. If the return value is not checked, the caller will not be able to correctly handle the case where fewer bytes were skipped than the caller requested. This is a particularly insidious kind of bug, because in many programs, skips from input streams usually do skip the full amount of data requested, causing the program to fail only sporadically. With Buffered streams, however, skip() will only skip data in the buffer, and will routinely fail to skip the requested number of bytes.
Check warning on line 130 in src/main/java/org/tikv/common/codec/MyDecimal.java
github-actions / checks-spotbugs
SF_SWITCH_NO_DEFAULT
Switch statement found in org.tikv.common.codec.MyDecimal.readWord(int[], int, int) where default case is missing
Raw output
This method contains a switch statement where default case is missing. Usually you need to provide a default case.
Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if the default case is at the end of the switch statement and the switch statement doesn't contain break statements for other cases.
Check warning on line 762 in src/main/java/org/tikv/common/codec/MyDecimal.java
github-actions / checks-spotbugs
SF_SWITCH_NO_DEFAULT
Switch statement found in org.tikv.common.codec.MyDecimal.writeWord(int[], int, int, int) where default case is missing
Raw output
This method contains a switch statement where default case is missing. Usually you need to provide a default case.
Because the analysis only looks at the generated bytecode, this warning can be incorrect triggered if the default case is at the end of the switch statement and the switch statement doesn't contain break statements for other cases.
Check warning on line 118 in src/main/java/org/tikv/common/codec/RowDecoderV2.java
github-actions / checks-spotbugs
BIT_SIGNED_CHECK_HIGH_BIT
Check for sign of bitwise operation involving 0x8000000000000000 (-9223372036854775808) in org.tikv.common.codec.RowDecoderV2.decodeDouble(byte[])
Raw output
This method compares a bitwise expression such as((val & CONSTANT) > 0) where CONSTANT is the negative number. Using bit arithmetic and then comparing with the greater than operator can lead to unexpected results. This comparison is unlikely to work as expected. The good practice is to use '!= 0' instead of '> 0'.
Check warning on line 298 in src/main/java/org/tikv/common/codec/RowEncoderV2.java
github-actions / checks-spotbugs
BIT_IOR_OF_SIGNED_BYTE
Bitwise OR of signed byte value computed in org.tikv.common.codec.RowEncoderV2.encodeBit(CodecDataOutput, Object)
Raw output
Loads a byte value (e.g., a value loaded from a byte array or returned by a method with return type byte) and performs a bitwise OR with that value. Byte values are sign extended to 32 bits before any bitwise operations are performed on the value. Thus, if b[0] contains the value 0xff, andx is initially 0, then the code((x << 8) | b[0]) will sign extend 0xffto get 0xffffffff, and thus give the value0xffffffff as the result.
In particular, the following code for packing a byte array into an int is badly wrong:
int result = 0;
for(int i = 0; i < 4; i++) {
result = ((result << 8) | b[i]);
}
The following idiom will work instead:
int result = 0;
for(int i = 0; i < 4; i++) {
result = ((result << 8) | (b[i] & 0xff));
}
Check warning on line 25 in src/main/java/org/tikv/common/codec/RowV2.java
github-actions / checks-spotbugs
MS_SHOULD_BE_FINAL
org.tikv.common.codec.RowV2.CODEC_VER isn't final but should be
Raw output
This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.
Check warning on line 266 in src/main/java/org/tikv/common/columnar/TiBlockColumnVector.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.columnar.TiBlockColumnVector.getUTF8String(int): new String(byte[])
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.
Check warning on line 213 in src/main/java/org/tikv/common/columnar/TiChunkColumnVector.java
github-actions / checks-spotbugs
DLS_DEAD_LOCAL_STORE
Dead store to resultFrac in org.tikv.common.columnar.TiChunkColumnVector.getMyDecimal(int)
Raw output
This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.
Note that Sun's javac compiler often generates dead stores for final local variables. Because SpotBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.
Check warning on line 240 in src/main/java/org/tikv/common/columnar/TiChunkColumnVector.java
github-actions / checks-spotbugs
DM_DEFAULT_ENCODING
Found reliance on default encoding in org.tikv.common.columnar.TiChunkColumnVector.getEnumString(int): new String(byte[])
Raw output
Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly.