diff options
author | Jonathan Scott <scottjonathan@google.com> | 2021-07-14 21:07:02 +0100 |
---|---|---|
committer | Jonathan Scott <scottjonathan@google.com> | 2021-07-23 14:47:20 +0000 |
commit | 2c546635a49710ebb6970b6ef455c27db8651128 (patch) | |
tree | c1f9f2bfd78b02643591c1e788686052e3c17746 | |
parent | b2c23c6d6a57a176279b725def95cdfddb1a0c70 (diff) | |
download | connectedappssdk-2c546635a49710ebb6970b6ef455c27db8651128.tar.gz |
Fix bug when throwing a runtime exception in a method which declares an
exception.
Bug: 188894962
Change-Id: Ibda6e44f9222fb42479a7b68b8bc197b31d218f4
-rw-r--r-- | processor/src/main/java/com/google/android/enterprise/connectedapps/processor/OtherProfileGenerator.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/processor/src/main/java/com/google/android/enterprise/connectedapps/processor/OtherProfileGenerator.java b/processor/src/main/java/com/google/android/enterprise/connectedapps/processor/OtherProfileGenerator.java index ace2f9e..08011ca 100644 --- a/processor/src/main/java/com/google/android/enterprise/connectedapps/processor/OtherProfileGenerator.java +++ b/processor/src/main/java/com/google/android/enterprise/connectedapps/processor/OtherProfileGenerator.java @@ -19,6 +19,7 @@ import static com.google.android.enterprise.connectedapps.processor.CommonClassN import static com.google.android.enterprise.connectedapps.processor.CommonClassNames.LOCAL_CALLBACK_CLASSNAME; import static com.google.android.enterprise.connectedapps.processor.CommonClassNames.PARCEL_CLASSNAME; import static com.google.android.enterprise.connectedapps.processor.CommonClassNames.PROFILE_CONNECTOR_CLASSNAME; +import static com.google.android.enterprise.connectedapps.processor.CommonClassNames.PROFILE_RUNTIME_EXCEPTION_CLASSNAME; import static com.google.android.enterprise.connectedapps.processor.CommonClassNames.UNAVAILABLE_PROFILE_EXCEPTION_CLASSNAME; import static com.google.android.enterprise.connectedapps.processor.containers.CrossProfileMethodInfo.AutomaticallyResolvedParameterFilterBehaviour.REMOVE_AUTOMATICALLY_RESOLVED_PARAMETERS; import static com.google.common.base.Preconditions.checkNotNull; @@ -209,9 +210,12 @@ final class OtherProfileGenerator { methodBuilder.addStatement("throw e"); } + methodBuilder.nextControlFlow("catch ($T e)", PROFILE_RUNTIME_EXCEPTION_CLASSNAME); + methodBuilder.addStatement("throw e"); + methodBuilder.nextControlFlow("catch ($T e)", Throwable.class); methodBuilder.addStatement( - "throw new $T($S)", IllegalStateException.class, "Unexpected exception thrown"); + "throw new $T($S, e)", IllegalStateException.class, "Unexpected exception thrown"); methodBuilder.endControlFlow(); } |