You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2015/09/12 21:00:51 UTC

svn commit: r1702664 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java

Author: uschindler
Date: Sat Sep 12 19:00:49 2015
New Revision: 1702664

URL: http://svn.apache.org/r1702664
Log:
Merged revision(s) 1702663 from lucene/dev/trunk:
Slightly more elegant rethrower (from AttributeFactory) :-)

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java?rev=1702664&r1=1702663&r2=1702664&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/Rethrow.java Sat Sep 12 19:00:49 2015
@@ -24,22 +24,19 @@ package org.apache.lucene.util;
  * <p>Pulled from <a href="http://www.javapuzzlers.com">Java Puzzlers</a>.</p>
  * @see <a href="http://www.amazon.com/Java-Puzzlers-Traps-Pitfalls-Corner/dp/032133678X">http://www.amazon.com/Java-Puzzlers-Traps-Pitfalls-Corner/dp/032133678X</a>
  */
-@SuppressWarnings({"unchecked","rawtypes"})
 public final class Rethrow {
-  /**
-   * Classy puzzler to rethrow any checked exception as an unchecked one.
-   */
-  private static class Rethrower<T extends Throwable> {
-    private void rethrow(Throwable t) throws T {
-      throw (T) t;
-    }
-  }
-  
+  private Rethrow() {}
+
   /**
    * Rethrows <code>t</code> (identical object).
    */
   public static void rethrow(Throwable t) {
-    new Rethrower<Error>().rethrow(t);
+    Rethrow.<Error>rethrow0(t);
+  }
+  
+  @SuppressWarnings("unchecked")
+  private static <T extends Throwable> void rethrow0(Throwable t) throws T {
+    throw (T) t;
   }
 }