1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-24 18:41:06 +03:00

Don't assert about suppressed exceptions in GraalVM (#6441)

This commit is contained in:
Jesse Wilson
2020-11-22 00:35:23 -05:00
committed by GitHub
parent 5f2732de5a
commit 2f361c245f
5 changed files with 42 additions and 11 deletions

View File

@@ -29,6 +29,10 @@ object TestUtil {
@JvmField
val UNREACHABLE_ADDRESS = InetSocketAddress("198.51.100.1", 8080)
/** See `org.graalvm.nativeimage.ImageInfo`. */
@JvmStatic
private val isGraalVmImage = System.getProperty("org.graalvm.nativeimage.imagecode") != null
@JvmStatic
fun headerEntries(vararg elements: String?): List<Header> {
return List(elements.size / 2) { Header(elements[it * 2]!!, elements[it * 2 + 1]!!) }
@@ -105,4 +109,16 @@ object TestUtil {
@JvmStatic
val windows: Boolean
get() = System.getProperty("os.name", "?").startsWith("Windows")
/**
* Make assertions about the suppressed exceptions on this. Prefer this over making direct calls
* so tests pass on GraalVM, where suppressed exceptions are silently discarded.
*
* https://github.com/oracle/graal/issues/3008
*/
@JvmStatic
fun Throwable.assertSuppressed(block: (List<@JvmSuppressWildcards Throwable>) -> Unit) {
if (isGraalVmImage) return
block(suppressed.toList())
}
}