forked from treasure-data/digdag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guava Throwables deprecation warning (treasure-data#1604)
* Create sub project digdag-commons and implement ThrowablesUtil * Upgrade gradle to 6.8.3 * Upgrade JUnit to 4.13.2 * Upgrade guava version to `30.1.1-jre` * Change assertThat from JUnit to Hamcrest to stop deprecation warning
- Loading branch information
Showing
219 changed files
with
601 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
dependencies { | ||
compile "com.google.guava:guava:${project.ext.guavaVersion}" | ||
} |
40 changes: 40 additions & 0 deletions
40
digdag-commons/src/main/java/io/digdag/commons/ThrowablesUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.digdag.commons; | ||
|
||
import com.google.common.base.Throwables; | ||
|
||
public class ThrowablesUtil | ||
{ | ||
/** | ||
* Original code from com.google.common.base.Throwables.propagate | ||
* This method is provided for reduce guava dependencies, suppress many warnings on deprecation. | ||
* As the wiki describe, propagate() is not necessary in most of cases. | ||
* So not use this method for new updated code. | ||
* Reference: https://github.com/google/guava/wiki/Why-we-deprecated-Throwables.propagate | ||
*/ | ||
public static RuntimeException propagate(Throwable throwable) | ||
{ | ||
Throwables.throwIfUnchecked(throwable); | ||
throw new RuntimeException(throwable); | ||
} | ||
|
||
/** | ||
* Original code from com.google.common.base.Throwables.propagateIfInstanceOf | ||
*/ | ||
public static <X extends Throwable> void propagateIfInstanceOf(Throwable throwable, Class<X> declaredType) | ||
throws X | ||
{ | ||
if (throwable != null) { | ||
Throwables.throwIfInstanceOf(throwable, declaredType); | ||
} | ||
} | ||
|
||
/** | ||
* Original code from com.google.common.base.Throwables.propagateIfPossible | ||
*/ | ||
public static void propagateIfPossible(Throwable throwable) | ||
{ | ||
if (throwable != null) { | ||
Throwables.throwIfUnchecked(throwable); | ||
} | ||
} | ||
} |
Oops, something went wrong.