You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@reef.apache.org by af...@apache.org on 2016/01/16 01:54:06 UTC

reef git commit: [REEF-1105] Enable IllegalThrows checkstyle check

Repository: reef
Updated Branches:
  refs/heads/master 4190a6c55 -> 7a890d88a


[REEF-1105] Enable IllegalThrows checkstyle check

This patch:
 * Adds the IllegalThrows check to checkstyle.xml and checkstyle-strict.xml
 * Suppresses the check for files with the word "Test" in the filename
 * Fixes the violations of the check in the REEF Java codebase

JIRA:
 [REEF-1105] (https://issues.apache.org/jira/browse/REEF-1105)

Pull Request:
  Closes #772


Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/7a890d88
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/7a890d88
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/7a890d88

Branch: refs/heads/master
Commit: 7a890d88abc0349330d3d6a5173f551d73dba021
Parents: 4190a6c
Author: sergey.dudoladov@tu-berlin.de <se...@tu-berlin.de>
Authored: Fri Jan 15 14:12:18 2016 +0100
Committer: Andrew Chung <af...@gmail.com>
Committed: Fri Jan 15 16:53:22 2016 -0800

----------------------------------------------------------------------
 lang/java/reef-common/src/main/resources/checkstyle-strict.xml | 6 ++++++
 .../reef-common/src/main/resources/checkstyle-suppress.xml     | 1 +
 lang/java/reef-common/src/main/resources/checkstyle.xml        | 5 +++++
 .../src/main/java/org/apache/reef/util/Optional.java           | 6 +++---
 .../src/test/java/org/apache/reef/util/OptionalTest.java       | 2 +-
 5 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/reef/blob/7a890d88/lang/java/reef-common/src/main/resources/checkstyle-strict.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/resources/checkstyle-strict.xml b/lang/java/reef-common/src/main/resources/checkstyle-strict.xml
index 21d6735..3412d94 100644
--- a/lang/java/reef-common/src/main/resources/checkstyle-strict.xml
+++ b/lang/java/reef-common/src/main/resources/checkstyle-strict.xml
@@ -227,6 +227,12 @@
             <property name="commentFormat" value="This is expected"/>
             <property name="exceptionVariableName" value="expected|ignored"/>
         </module>
+
+        <!-- IllegalThrows is suppressed for files with the word "Test" in the filename -->
+        <module name="IllegalThrows">
+            <property name="illegalClassNames" value="Throwable, Error, RuntimeException, NullPointerException"/>
+        </module>
+
     </module>
 
 </module>

http://git-wip-us.apache.org/repos/asf/reef/blob/7a890d88/lang/java/reef-common/src/main/resources/checkstyle-suppress.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/resources/checkstyle-suppress.xml b/lang/java/reef-common/src/main/resources/checkstyle-suppress.xml
index 45631d0..6a9da64 100644
--- a/lang/java/reef-common/src/main/resources/checkstyle-suppress.xml
+++ b/lang/java/reef-common/src/main/resources/checkstyle-suppress.xml
@@ -21,4 +21,5 @@
 -->
 <suppressions>
     <suppress checks=".*" files=".*\\target\\generated-sources\\.*" />
+    <suppress checks="IllegalThrows" files=".*Test.*" />
 </suppressions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/reef/blob/7a890d88/lang/java/reef-common/src/main/resources/checkstyle.xml
----------------------------------------------------------------------
diff --git a/lang/java/reef-common/src/main/resources/checkstyle.xml b/lang/java/reef-common/src/main/resources/checkstyle.xml
index ff4ad78..a21196c 100644
--- a/lang/java/reef-common/src/main/resources/checkstyle.xml
+++ b/lang/java/reef-common/src/main/resources/checkstyle.xml
@@ -230,6 +230,11 @@
             <property name="exceptionVariableName" value="expected|ignored"/>
         </module>
 
+        <!-- IllegalThrows is suppressed for files with the word "Test" in the filename -->
+        <module name="IllegalThrows">
+            <property name="illegalClassNames" value="Throwable, Error, RuntimeException, NullPointerException"/>
+        </module>
+
     </module>
 
 </module>

http://git-wip-us.apache.org/repos/asf/reef/blob/7a890d88/lang/java/reef-utils/src/main/java/org/apache/reef/util/Optional.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-utils/src/main/java/org/apache/reef/util/Optional.java b/lang/java/reef-utils/src/main/java/org/apache/reef/util/Optional.java
index b60fdcc..93927c1 100644
--- a/lang/java/reef-utils/src/main/java/org/apache/reef/util/Optional.java
+++ b/lang/java/reef-utils/src/main/java/org/apache/reef/util/Optional.java
@@ -52,11 +52,11 @@ public final class Optional<T> implements Serializable {
 
   /**
    * @return An Optional with the given value.
-   * @throws NullPointerException if the value is null
+   * @throws IllegalArgumentException if the value is null
    */
-  public static <T> Optional<T> of(final T value) throws NullPointerException {
+  public static <T> Optional<T> of(final T value) throws IllegalArgumentException {
     if (null == value) {
-      throw new NullPointerException("Passed a null value. Use ofNullable() instead");
+      throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead");
     }
     return new Optional<>(value);
   }

http://git-wip-us.apache.org/repos/asf/reef/blob/7a890d88/lang/java/reef-utils/src/test/java/org/apache/reef/util/OptionalTest.java
----------------------------------------------------------------------
diff --git a/lang/java/reef-utils/src/test/java/org/apache/reef/util/OptionalTest.java b/lang/java/reef-utils/src/test/java/org/apache/reef/util/OptionalTest.java
index ac7a761..f53219d 100644
--- a/lang/java/reef-utils/src/test/java/org/apache/reef/util/OptionalTest.java
+++ b/lang/java/reef-utils/src/test/java/org/apache/reef/util/OptionalTest.java
@@ -40,7 +40,7 @@ public class OptionalTest {
         Optional.of(2).isPresent());
   }
 
-  @Test(expected = NullPointerException.class)
+  @Test(expected = IllegalArgumentException.class)
   public void testOfNull() {
     final Optional<Integer> o = Optional.of(null);
   }