mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
Fix CodeQL warnings (#4348)
Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
parent
76597838c4
commit
0e1883bdae
@ -139,7 +139,7 @@ public class Audio {
|
||||
if (newVolume - volume < .01) {
|
||||
// the getMasterVolume() may only returns integers, so we have to make sure that we
|
||||
// increase the volume level at least by 1%.
|
||||
newVolume += .01;
|
||||
newVolume += .01f;
|
||||
}
|
||||
if (newVolume > 1) {
|
||||
newVolume = 1;
|
||||
|
@ -145,7 +145,7 @@ public class JavaTest {
|
||||
* @return true on success, false on timeout
|
||||
*/
|
||||
protected boolean waitFor(BooleanSupplier condition, long timeout, long sleepTime) {
|
||||
int waitingTime = 0;
|
||||
long waitingTime = 0;
|
||||
boolean rv;
|
||||
while (!(rv = condition.getAsBoolean()) && waitingTime < timeout) {
|
||||
waitingTime += sleepTime;
|
||||
|
@ -89,7 +89,10 @@ public class InputStreamCacheWrapper extends InputStream {
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
offset += n;
|
||||
if (n > Integer.MAX_VALUE || n < Integer.MIN_VALUE) {
|
||||
throw new IOException("Invalid offset, exceeds Integer range");
|
||||
}
|
||||
offset += (int) n;
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -103,7 +106,7 @@ public class InputStreamCacheWrapper extends InputStream {
|
||||
}
|
||||
|
||||
public long length() {
|
||||
Long totalSize = cacheEntry.getTotalSize();
|
||||
long totalSize = cacheEntry.getTotalSize();
|
||||
if (totalSize > 0L) {
|
||||
return totalSize;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class LRUMediaCacheEntry<V> {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected Long getTotalSize() {
|
||||
protected long getTotalSize() {
|
||||
if (completed) { // we already know the total size of the sound
|
||||
return currentSize;
|
||||
} else {
|
||||
@ -323,7 +323,9 @@ public class LRUMediaCacheEntry<V> {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return Math.max(0, Long.valueOf(fileChannelLocal.size() - offset).intValue());
|
||||
long nBytes = Math.min(Integer.MAX_VALUE, Math.max(0, fileChannelLocal.size() - offset));
|
||||
// nBytes is for sure in integer range, safe to cast
|
||||
return (int) nBytes;
|
||||
} catch (IOException e) {
|
||||
logger.debug("Cannot get file length for cache file {}", key);
|
||||
return 0;
|
||||
|
@ -52,7 +52,7 @@ public class JavaTest {
|
||||
* @return true on success, false on timeout
|
||||
*/
|
||||
protected boolean waitFor(BooleanSupplier condition, long timeout, long sleepTime) {
|
||||
int waitingTime = 0;
|
||||
long waitingTime = 0;
|
||||
boolean rv;
|
||||
while (!(rv = condition.getAsBoolean()) && waitingTime < timeout) {
|
||||
waitingTime += sleepTime;
|
||||
|
Loading…
Reference in New Issue
Block a user