Skip to content

Commit

Permalink
Merge pull request #2038 from square/py/fix_service_watcher_crash
Browse files Browse the repository at this point in the history
Fix crash for methods with no arguments and rethrow exceptions
  • Loading branch information
pyricau authored Dec 23, 2020
2 parents af08bf1 + cfcbe94 commit ff9ace5
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.IBinder
import leakcanary.internal.friendly.checkMainThread
import shark.SharkLog
import java.lang.ref.WeakReference
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Proxy
import java.util.WeakHashMap

Expand Down Expand Up @@ -77,7 +78,15 @@ class ServiceWatcher(private val reachabilityWatcher: ReachabilityWatcher) : Ins
onServiceDestroyed(token)
}
}
method.invoke(activityManagerInstance, *args)
try {
if (args == null) {
method.invoke(activityManagerInstance)
} else {
method.invoke(activityManagerInstance, *args)
}
} catch (invocationException: InvocationTargetException) {
throw invocationException.targetException
}
}
}
} catch (ignored: Throwable) {
Expand Down

0 comments on commit ff9ace5

Please sign in to comment.