From 3c249dcb6baaaa7446b69a1bda01f7630b6f07d4 Mon Sep 17 00:00:00 2001 From: FuzzingTeam Date: Tue, 11 Oct 2022 18:14:07 +0530 Subject: [PATCH] Fixed negative data and throughput values in an output of class RawErasureCoderBenchmark --- .../erasurecode/rawcoder/RawErasureCoderBenchmark.java | 1 + .../rawcoder/TestRawErasureCoderBenchmark.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java index 17fc6354ab5..75e1dbb5d5a 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/RawErasureCoderBenchmark.java @@ -320,6 +320,7 @@ public final class RawErasureCoderBenchmark { private ByteBuffer[] decodeInputs = new ByteBuffer[NUM_ALL_UNITS]; public static void configure(int dataSizeMB, int chunkSizeKB) { + Preconditions.checkArgument(dataSizeMB > 0); chunkSize = chunkSizeKB * 1024; // buffer size needs to be a multiple of (numDataUnits * chunkSize) int round = (int) Math.round( diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawErasureCoderBenchmark.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawErasureCoderBenchmark.java index 3ba0260b1a7..195605ea8b3 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawErasureCoderBenchmark.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/erasurecode/rawcoder/TestRawErasureCoderBenchmark.java @@ -18,6 +18,7 @@ package org.apache.hadoop.io.erasurecode.rawcoder; import org.apache.hadoop.io.erasurecode.ErasureCodeNative; +import org.junit.Assert; import org.junit.Assume; import org.junit.Test; @@ -33,6 +34,14 @@ public class TestRawErasureCoderBenchmark { RawErasureCoderBenchmark.CODER.DUMMY_CODER, 2, 100, 1024); RawErasureCoderBenchmark.performBench("decode", RawErasureCoderBenchmark.CODER.DUMMY_CODER, 5, 150, 100); + + try { + RawErasureCoderBenchmark.performBench("decode", + RawErasureCoderBenchmark.CODER.DUMMY_CODER, 5, -150, 100); + Assert.fail("should have thrown an IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // intentionally swallow exception + } } @Test