Horis 2 жил өмнө
parent
commit
e10e243a97

+ 1 - 1
app/src/main/java/io/legado/app/data/entities/BaseSource.kt

@@ -97,7 +97,7 @@ interface BaseSource : JsExtensions {
      * 解析header规则
      */
     fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
-        if (checkRhinoRecursiveCall()) return@apply
+        checkRhinoRecursiveCall()
         header?.let {
             GSON.fromJsonObject<Map<String, String>>(
                 when {

+ 8 - 4
app/src/main/java/io/legado/app/utils/RhinoContextExtensions.kt

@@ -13,10 +13,14 @@ fun Context?.getEnterCount(): Int {
     return enterCountField.get(this) as Int
 }
 
-fun checkRhinoRecursiveCall(): Boolean {
-    return Context.getCurrentContext().getEnterCount() > 1
+fun checkRhinoRecursiveCall() {
+    check(Context.getCurrentContext().getEnterCount() <= 1) {
+        "Rhino recursive call detected."
+    }
 }
 
-fun checkRhinoCall(): Boolean {
-    return Context.getCurrentContext() != null
+fun checkRhinoCall() {
+    check(Context.getCurrentContext() == null) {
+        "Rhino call detected."
+    }
 }