StorageService.move() throws RuntimeException when interrupted

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/service/StorageService.java

Line: 4168

try
{
relocator.stream().get();
}
catch (ExecutionException | InterruptedException e)
{
throw new RuntimeException("Interrupted while waiting for
stream/fetch ranges to finish: " + e.getMessage());
}



RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that an interrupt has occurred. This mismatch could be a
problem. For example, the callers may miss the possibility that
StorageService.move() can be interrupted because it does not throw any
InterruptedException. Or, the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the interrupt.


Do you think this is a bug?


Thanks!


StorageService.rebuild() throws RuntimeException when interrupted

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/service/StorageService.java

Line: 1313

try
{
...
}
catch (InterruptedException e)
{
throw new RuntimeException("Interrupted while waiting on rebuild
streaming");
}



RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that an interrupt has occurred. This mismatch could be a
problem. For example, the callers may miss the possibility that
StorageService.rebuild() can be interrupted because it does not throw any
InterruptedException. Or, the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the interrupt.


Do you think this is a bug?


Thanks!


StorageService.decommission() throws RuntimeException when interrupted

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/service/StorageService.java

Line: 4008

try
{
...
}
catch (InterruptedException e)
{
throw new RuntimeException("Node interrupted while decommissioning");
}



RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that an interrupt has occurred. This mismatch be a
problem. For example, the callers may miss the possibility that
StorageService.decommission() can be interrupted because it does not throw
any InterruptedException. Or,  the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the interrupt.


Do you think this is a bug?


Thanks!


CompactionAwareWriter.getWriteDirectory() throws RuntimeException when running out of disk space

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following two
throw statements whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/db/compaction/writers/CompactionAwareWriter.java

Line: 222 & 231

if (availableSpace < estimatedWriteSize)
throw new RuntimeException(String.format("Not enough space to
write %s to %s (%s available)",

FBUtilities.prettyPrintMemory(estimatedWriteSize),
 d.location,

FBUtilities.prettyPrintMemory(availableSpace)));

d = getDirectories().getWriteableLocation(estimatedWriteSize);if (d == null)
throw new RuntimeException(String.format("Not enough disk space to
store %s",

FBUtilities.prettyPrintMemory(estimatedWriteSize)));



RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
messages indicate that the Cassandra node is running out of disk space.
This mismatch could be a problem. For example, the callers may miss the
possibility that getWriteDirectory() can run out of disk space because it
does not throw an accurate exception class (e.g., CASSANDRA-11448
). Or, the callers
trying to handle other RuntimeException may accidentally (and incorrectly)
handle the out of disk space scenario.


Do you think this is a bug?


Thanks!


WindowsFailedSnapshotTracker.deleteOldSnapshots() throws RuntimeException when it failed to create a file

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/db/WindowsFailedSnapshotTracker.java

Line: 98

try
{
_failedSnapshotFile = new PrintWriter(new FileWriter(TODELETEFILE, true));
}
catch (IOException e)
{
throw new RuntimeException(String.format("Failed to create failed
snapshot tracking file [%s]. Aborting", TODELETEFILE));
}


RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that deleteOldSnapshots() failed to create a file. This
mismatch could be a problem. For example, the callers may miss the
possibility that deleteOldSnapshots() can fail to create a file because it
does not throw any IOException. Or, the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the file
creation failure.


Do you think this is a bug?


Thanks!


CommitLogArchiver.construct() throws a RuntimeException when it failed to create a directory

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java

Line: 110

if (!directory.mkdir())
{
throw new RuntimeException("Unable to create directory: " + dir);
}


RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that construct() failed to create a directory. This
mismatch could be a problem. For example, the callers may miss the
possibility that construct() can fail to create a directory because it does
not throw any IOException. Or, the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the directory
creation failure.


Do you think this is a bug?


Thanks!


CommitLogArchiver.maybeRestoreArchive() throws a RuntimeException when it failed to list a directory

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java

Line: 225

File[] files = new File(dir).listFiles();
if (files == null)
{
throw new RuntimeException("Unable to list directory " + dir);
}


RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that maybeRestoreArchive() failed to list a directory.
This mismatch could be a problem. For example, the callers may miss the
possibility that maybeRestoreArchive() can fail to list a directory because
it does not throw any IOException. Or, the callers trying to handle other
RuntimeException may accidentally (and incorrectly) handle the
directory listing failure.


Do you think this is a bug?


Thanks!


OffHeapBitSet() throws a RuntimeException when it runs out of memory

2019-05-06 Thread eBugs Study
Dear Cassandra developers, we are developing a tool to detect
exception-related bugs in Java. Our prototype has spotted the following
throw statement whose exception class and error message indicate different
error conditions.



Version: Cassandra-3.11 (commit: 123113f7b887370a248669ee0db6fdf13df0146e)

File:
CASSANDRA-ROOT/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java

Line: 49

try
{
long byteCount = wordCount * 8L;
bytes = Memory.allocate(byteCount);
}
catch (OutOfMemoryError e)
{
throw new RuntimeException("Out of native memory occured, You can
avoid it by increasing the system ram space or by increasing
bloom_filter_fp_chance.");
}


RuntimeException is usually used to represent errors in the program logic
(think of one of its subclasses, NullPointerException), while the error
message indicates that OffHeapBitSet() ran out of memory. This mismatch
could be a problem. For example, the callers may miss the possibility that
OffHeapBitSet() can run out of memory. Or, the callers trying to handle
other RuntimeException may accidentally (and incorrectly) handle the out of
memory scenario.


Do you think this is a bug?


Thanks!