Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,25 @@ protected ECChunk[] backupAndEraseChunks(ECChunk[] dataChunks,
int idx = 0;

for (int i = 0; i < erasedDataIndexes.length; i++) {
toEraseChunks[idx ++] = dataChunks[erasedDataIndexes[i]];
dataChunks[erasedDataIndexes[i]] = null;
if (erasedDataIndexes[i] < dataChunks.length) {
toEraseChunks[idx ++] = dataChunks[erasedDataIndexes[i]];
dataChunks[erasedDataIndexes[i]] = null;
} else {
throw new IllegalArgumentException(
"The erased index is out of bound: erasedDataIndex="
+ erasedDataIndexes[i]);
}
}

for (int i = 0; i < erasedParityIndexes.length; i++) {
toEraseChunks[idx ++] = parityChunks[erasedParityIndexes[i]];
parityChunks[erasedParityIndexes[i]] = null;
if (erasedParityIndexes[i] < parityChunks.length) {
toEraseChunks[idx ++] = parityChunks[erasedParityIndexes[i]];
parityChunks[erasedParityIndexes[i]] = null;
} else {
throw new IllegalArgumentException(
"The erased index is out of bound: erasedParityIndex="
+ erasedParityIndexes[i]);
}
}

return toEraseChunks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static Collection<Object[]> data() {
{RSRawErasureCoderFactory.class, 6, 3, new int[]{1}, new int[]{}},
{RSRawErasureCoderFactory.class, 6, 3, new int[]{3}, new int[]{0}},
{RSRawErasureCoderFactory.class, 6, 3, new int[]{2, 4}, new int[]{1}},
{RSRawErasureCoderFactory.class, 6, 1, new int[]{0}, new int[]{1}},
{NativeRSRawErasureCoderFactory.class, 6, 3, new int[]{0}, new int[]{}},
{XORRawErasureCoderFactory.class, 10, 1, new int[]{0}, new int[]{}},
{NativeXORRawErasureCoderFactory.class, 10, 1, new int[]{0},
Expand Down Expand Up @@ -123,7 +124,12 @@ protected void performTestValidate(int chunkSize) {
}

// decode
backupAndEraseChunks(clonedDataChunks, parityChunks);
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use LambdaTestUtils.intercept() for all bits of test code which validates expected exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backupAndEraseChunks method would only throw exception if the erased data index is out of bound. This is only true for the newly added value set.

Adding LambdaTestUtils.intercept() fails the tests for other parameterized values since LambdaTestUtils.intercept() @throws AssertionError if the evaluation call didn't raise an exception.

backupAndEraseChunks(clonedDataChunks, parityChunks);
} catch (IllegalArgumentException e) {
String expected = "The erased index is out of bound";
Assume.assumeTrue(expected, !e.toString().contains(expected));
}
ECChunk[] inputChunks =
prepareInputChunksForDecoding(clonedDataChunks, parityChunks);
markChunks(inputChunks);
Expand Down Expand Up @@ -210,7 +216,12 @@ public void testValidateWithBadDecoding() throws IOException {
}

// decode
backupAndEraseChunks(clonedDataChunks, parityChunks);
try {
backupAndEraseChunks(clonedDataChunks, parityChunks);
} catch (IllegalArgumentException e) {
String expected = "The erased index is out of bound";
Assume.assumeTrue(expected, !e.toString().contains(expected));
}
ECChunk[] inputChunks =
prepareInputChunksForDecoding(clonedDataChunks, parityChunks);
markChunks(inputChunks);
Expand Down