Skip to content

Commit 4cb345a

Browse files
committed
Remove try/catch block on @Backgournd/@UIThread methods
Because the exception is now propagated, there is no need of catching it.
1 parent c4e8e3d commit 4cb345a

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/helper/APTCodeModelHelper.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public String getIdStringFromIdFieldRef(JFieldRef idRef) {
228228
throw new IllegalStateException("Unable to extract target name from JFieldRef");
229229
}
230230

231-
public JTryBlock surroundWithTryCatch(EBeanHolder holder, JBlock block, JBlock content, String exceptionMessage, boolean propagate) {
231+
public JTryBlock surroundWithTryCatch(EBeanHolder holder, JBlock block, JBlock content, String exceptionMessage) {
232232
Classes classes = holder.classes();
233233
JTryBlock tryBlock = block._try();
234234
tryBlock.body().add(content);
@@ -239,16 +239,12 @@ public JTryBlock surroundWithTryCatch(EBeanHolder holder, JBlock block, JBlock c
239239
errorInvoke.arg(exceptionMessage);
240240
errorInvoke.arg(exceptionParam);
241241
catchBlock.body().add(errorInvoke);
242-
if (propagate) {
243-
catchBlock.body()._throw(exceptionParam);
244-
}
245242
return tryBlock;
246243
}
247244

248245
public JDefinedClass createDelegatingAnonymousRunnableClass(EBeanHolder holder, JMethod delegatedMethod) {
249246

250247
JCodeModel codeModel = holder.codeModel();
251-
Classes classes = holder.classes();
252248

253249
JDefinedClass anonymousRunnableClass;
254250
JBlock previousMethodBody = removeBody(delegatedMethod);
@@ -258,9 +254,7 @@ public JDefinedClass createDelegatingAnonymousRunnableClass(EBeanHolder holder,
258254
JMethod runMethod = anonymousRunnableClass.method(JMod.PUBLIC, codeModel.VOID, "run");
259255
runMethod.annotate(Override.class);
260256

261-
JBlock runMethodBody = runMethod.body();
262-
263-
surroundWithTryCatch(holder, runMethodBody, previousMethodBody, "A runtime exception was thrown while executing code in a runnable", true);
257+
runMethod.body().add( previousMethodBody );
264258

265259
return anonymousRunnableClass;
266260
}

‎AndroidAnnotations/androidannotations/src/main/java/org/androidannotations/processing/BackgroundProcessor.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public void process(Element element, JCodeModel codeModel, EBeanHolder holder) t
6060
JMethod executeMethod = anonymousTaskClass.method(JMod.PUBLIC, codeModel.VOID, "execute");
6161
executeMethod.annotate(Override.class);
6262

63-
JBlock runMethodBody = executeMethod.body();
64-
helper.surroundWithTryCatch(holder, runMethodBody, previousMethodBody, "A runtime exception was thrown while executing code in a background task", true);
63+
executeMethod.body().add( previousMethodBody );
6564

6665
Background annotation = element.getAnnotation(Background.class);
6766
String id = annotation.id();

0 commit comments

Comments
 (0)