Skip to content

Commit

Permalink
[resources] Delete Thread.currentThread().contextClassLoader on JVM t…
Browse files Browse the repository at this point in the history
…argets (#4895)

The class loader retrieval method has been modified in both
`ResourceReader.android.kt` and `ResourceReader.desktop.kt` files. The
return statement has been changed to prioritize java class classLoader
and provides a clearer error message when it can't be found.

Fixes #4887
Fixes #4742

## Release Notes
### Fixes - Resources
- Delete contextClassLoader usage on JVM targets
  • Loading branch information
terrakok committed May 29, 2024
1 parent 6604add commit c519a69
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
}

private fun getClassLoader(): ClassLoader {
return Thread.currentThread().contextClassLoader ?: this.javaClass.classLoader!!
return this.javaClass.classLoader ?: error("Cannot find class loader")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
}

private fun getClassLoader(): ClassLoader {
return Thread.currentThread().contextClassLoader ?: this.javaClass.classLoader!!
return this.javaClass.classLoader ?: error("Cannot find class loader")
}
}

0 comments on commit c519a69

Please sign in to comment.