Skip to content

Commit ede2132

Browse files
committed
remove throwables.propagate
1 parent eda0050 commit ede2132

21 files changed

Lines changed: 31 additions & 45 deletions

src/main/java/com/hubspot/jinjava/doc/JinjavaDocFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111

12-
import com.google.common.base.Throwables;
1312
import com.hubspot.jinjava.Jinjava;
1413
import com.hubspot.jinjava.doc.annotations.JinjavaMetaValue;
1514
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
@@ -79,7 +78,7 @@ private void addFnDocs(JinjavaDoc doc) {
7978
try {
8079
realMethod = (Method) realMethod.getDeclaringClass().getField("delegate").get(null);
8180
} catch (Exception e) {
82-
throw Throwables.propagate(e);
81+
throw new RuntimeException(e);
8382
}
8483
}
8584

src/main/java/com/hubspot/jinjava/el/ext/AbstractCallableMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public abstract class AbstractCallableMethod {
2222
try {
2323
EVAL_METHOD = AbstractCallableMethod.class.getMethod("evaluate", Object[].class);
2424
} catch (Exception e) {
25-
throw Throwables.propagate(e);
25+
Throwables.throwIfUnchecked(e);
26+
throw new RuntimeException(e);
2627
}
2728
}
2829

src/main/java/com/hubspot/jinjava/el/ext/ExtendedScanner.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import java.lang.reflect.InvocationTargetException;
55
import java.lang.reflect.Method;
66

7-
import com.google.common.base.Throwables;
8-
97
import de.odysseus.el.tree.impl.Scanner;
108

119
public class ExtendedScanner extends Scanner {
@@ -57,23 +55,23 @@ protected boolean isWhitespace(char c) {
5755
POSITION_FIELD = Scanner.class.getDeclaredField("position");
5856
POSITION_FIELD.setAccessible(true);
5957
} catch (NoSuchFieldException | SecurityException | NoSuchMethodException e) {
60-
throw Throwables.propagate(e);
58+
throw new RuntimeException(e);
6159
}
6260
}
6361

6462
protected static void addKeyToken(Token token) {
6563
try {
6664
ADD_KEY_TOKEN_METHOD.invoke(null, token);
6765
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
68-
throw Throwables.propagate(e);
66+
throw new RuntimeException(e);
6967
}
7068
}
7169

7270
protected void setToken(Token token) {
7371
try {
7472
TOKEN_FIELD.set(this, token);
7573
} catch (IllegalArgumentException | IllegalAccessException e) {
76-
throw Throwables.propagate(e);
74+
throw new RuntimeException(e);
7775
}
7876
}
7977

@@ -82,7 +80,7 @@ protected void incrPosition(int n) {
8280
try {
8381
POSITION_FIELD.set(this, getPosition() + n);
8482
} catch (IllegalArgumentException | IllegalAccessException e) {
85-
throw Throwables.propagate(e);
83+
throw new RuntimeException(e);
8684
}
8785
}
8886

src/main/java/com/hubspot/jinjava/lib/SimpleLibrary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public final List<T> registerClasses(Class<? extends T>... itemClass) {
7171

7272
return instances;
7373
} catch (Exception e) {
74-
throw Throwables.propagate(e);
74+
Throwables.throwIfUnchecked(e);
75+
throw new RuntimeException(e);
7576
}
7677
}
7778

src/main/java/com/hubspot/jinjava/lib/filter/UrlEncodeFilter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import org.apache.commons.lang3.StringUtils;
1111

12-
import com.google.common.base.Throwables;
1312
import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
1413
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
1514
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
@@ -61,7 +60,7 @@ private String urlEncode(String s) {
6160
try {
6261
return URLEncoder.encode(s, "UTF-8");
6362
} catch (UnsupportedEncodingException e) {
64-
throw Throwables.propagate(e);
63+
throw new RuntimeException(e);
6564
}
6665
}
6766

src/main/java/com/hubspot/jinjava/lib/fn/ELFunctionDefinition.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ private static Method resolveMethod(Class<?> methodClass, String methodName, Cla
2323
m.setAccessible(true);
2424
return m;
2525
} catch (Exception e) {
26-
throw Throwables.propagate(e);
26+
Throwables.throwIfUnchecked(e);
27+
throw new RuntimeException(e);
2728
}
2829
}
2930

src/main/java/com/hubspot/jinjava/lib/fn/InjectedContextFunctionProxy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import java.lang.reflect.Method;
66
import java.lang.reflect.Modifier;
77

8+
import com.google.common.base.Throwables;
9+
810
import javassist.ClassPool;
911
import javassist.CtClass;
1012
import javassist.CtField;
1113
import javassist.CtMethod;
1214
import javassist.CtNewMethod;
1315
import javassist.bytecode.AccessFlag;
1416

15-
import com.google.common.base.Throwables;
16-
1717
public class InjectedContextFunctionProxy {
1818

1919
public static ELFunctionDefinition defineProxy(String namespace, String name, Method m, Object injectedInstance)
@@ -69,7 +69,8 @@ public static ELFunctionDefinition defineProxy(String namespace, String name, Me
6969
return new ELFunctionDefinition(namespace, name, staticMethod);
7070
} catch (Throwable e) {
7171
ENGINE_LOG.error("Error creating injected context function", e);
72-
throw Throwables.propagate(e);
72+
Throwables.throwIfUnchecked(e);
73+
throw new RuntimeException(e);
7374
}
7475
}
7576

src/test/java/com/hubspot/jinjava/el/ExtendedSyntaxBuilderTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.junit.Before;
1414
import org.junit.Test;
1515

16-
import com.google.common.base.Throwables;
1716
import com.google.common.collect.Lists;
1817
import com.google.common.io.Resources;
1918
import com.hubspot.jinjava.Jinjava;
@@ -213,7 +212,7 @@ private String fixture(String name) {
213212
return Resources.toString(
214213
Resources.getResource(String.format("el/dict/%s.fixture", name)), StandardCharsets.UTF_8);
215214
} catch (IOException e) {
216-
throw Throwables.propagate(e);
215+
throw new RuntimeException(e);
217216
}
218217
}
219218

src/test/java/com/hubspot/jinjava/lib/filter/BatchFilterTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.junit.Before;
1212
import org.junit.Test;
1313

14-
import com.google.common.base.Throwables;
1514
import com.google.common.collect.ImmutableMap;
1615
import com.google.common.collect.Lists;
1716
import com.google.common.io.Resources;
@@ -68,7 +67,7 @@ private String render(String template, Map<String, Object> context) {
6867
try {
6968
return jinjava.render(Resources.toString(Resources.getResource(String.format("filter/%s.jinja", template)), StandardCharsets.UTF_8), context);
7069
} catch (Exception e) {
71-
throw Throwables.propagate(e);
70+
throw new RuntimeException(e);
7271
}
7372
}
7473

src/test/java/com/hubspot/jinjava/lib/filter/TruncateHtmlFilterTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package com.hubspot.jinjava.lib.filter;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4-
import static org.mockito.Mockito.mock;
4+
import static org.mockito.Mockito.*;
55

66
import java.io.IOException;
77
import java.nio.charset.StandardCharsets;
88

99
import org.junit.Before;
1010
import org.junit.Test;
1111

12-
import com.google.common.base.Throwables;
1312
import com.google.common.io.Resources;
1413
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
1514

@@ -43,7 +42,7 @@ private static String fixture(String name) {
4342
try {
4443
return Resources.toString(Resources.getResource(name), StandardCharsets.UTF_8);
4544
} catch (IOException e) {
46-
throw Throwables.propagate(e);
45+
throw new RuntimeException(e);
4746
}
4847
}
4948
}

0 commit comments

Comments
 (0)