This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new d093c5f Add missing javadoc for exceptions thrown on invalid arguments (#2594) d093c5f is described below commit d093c5f850954b192d5bafa3bca3a931535937a8 Author: Diego Marcilio <dvmarci...@gmail.com> AuthorDate: Mon Mar 28 15:28:48 2022 +0200 Add missing javadoc for exceptions thrown on invalid arguments (#2594) * Fixing wrong javadoc for null outputStream in SerializationUtil.serialize() * Adding a couple @throws javadocs and tests for invalid arguments --- .../java/org/apache/accumulo/core/conf/ClientProperty.java | 2 ++ .../apache/accumulo/core/metadata/schema/MetadataTime.java | 2 ++ .../org/apache/accumulo/core/conf/ClientPropertyTest.java | 5 +++++ .../accumulo/core/metadata/schema/MetadataTimeTest.java | 11 +++++++++++ .../java/org/apache/accumulo/test/util/SerializationUtil.java | 2 +- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java b/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java index 9f453ce..306e449 100644 --- a/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java +++ b/core/src/main/java/org/apache/accumulo/core/conf/ClientProperty.java @@ -340,6 +340,8 @@ public enum ClientProperty { /** * @throws IllegalArgumentException * if Properties does not contain all required + * @throws NullPointerException + * if {@code properties == null} */ public static void validate(Properties properties) { validate(properties, true); diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java index 0418b49..40852d4 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataTime.java @@ -40,6 +40,8 @@ public final class MetadataTime implements Comparable<MetadataTime> { * @param timestr * string representation of a metatdata time, ex. "M12345678" * @return a MetadataTime object represented by string + * @throws IllegalArgumentException + * if {@code timesstr == null} or {@code timestr.length() <= 1)} */ public static MetadataTime parse(String timestr) throws IllegalArgumentException { diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java index db76b93..53ef1d1 100644 --- a/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java +++ b/core/src/test/java/org/apache/accumulo/core/conf/ClientPropertyTest.java @@ -78,4 +78,9 @@ public class ClientPropertyTest { assertThrows(IllegalStateException.class, () -> ClientProperty.BATCH_WRITER_LATENCY_MAX.getBytes(props)); } + + @Test + public void validateThrowsNPEOnNullProperties() { + assertThrows(NullPointerException.class, () -> ClientProperty.validate(null)); + } } diff --git a/core/src/test/java/org/apache/accumulo/core/metadata/schema/MetadataTimeTest.java b/core/src/test/java/org/apache/accumulo/core/metadata/schema/MetadataTimeTest.java index 10f2547..62a8f8a 100644 --- a/core/src/test/java/org/apache/accumulo/core/metadata/schema/MetadataTimeTest.java +++ b/core/src/test/java/org/apache/accumulo/core/metadata/schema/MetadataTimeTest.java @@ -49,6 +49,17 @@ public class MetadataTimeTest { } @Test + public void testGetInstance_nullArgument() { + assertThrows(IllegalArgumentException.class, () -> MetadataTime.parse(null)); + } + + @Test + public void testGetInstance_Invalid_timestr() { + assertThrows(IllegalArgumentException.class, () -> MetadataTime.parse("")); + assertThrows(IllegalArgumentException.class, () -> MetadataTime.parse("X")); + } + + @Test public void testGetInstance_Millis() { assertEquals(1234, m1234.getTime()); assertEquals(TimeType.MILLIS, m1234.getType()); diff --git a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java index cae2079..4660fc6 100644 --- a/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java +++ b/test/src/main/java/org/apache/accumulo/test/util/SerializationUtil.java @@ -161,7 +161,7 @@ public class SerializationUtil { * the object to serialize to bytes, may be null * @param outputStream * the stream to write to, must not be null - * @throws IllegalArgumentException + * @throws NullPointerException * if {@code outputStream} is {@code null} */ public static void serialize(Serializable obj, OutputStream outputStream) {