From 46c075bf6daed5bd6fa18fbbf0d5406077b55d1b Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sat, 1 Apr 2023 10:37:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20classloader=E3=81=AE=E5=91=BC=E3=81=B3?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/usbharu/hideout/routing/UserRouting.kt | 2 +- .../dev/usbharu/hideout/routing/UserRoutingKtTest.kt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt diff --git a/src/main/kotlin/dev/usbharu/hideout/routing/UserRouting.kt b/src/main/kotlin/dev/usbharu/hideout/routing/UserRouting.kt index d39c3c7f..af03a5fa 100644 --- a/src/main/kotlin/dev/usbharu/hideout/routing/UserRouting.kt +++ b/src/main/kotlin/dev/usbharu/hideout/routing/UserRouting.kt @@ -67,7 +67,7 @@ fun Application.user(userService: UserService, activityPubUserService: ActivityP } } get("/{name}/icon.png"){ - call.respondBytes(Application::class.java.classLoader.getResourceAsStream("/icon.png").readAllBytes(),ContentType.Image.PNG) + call.respondBytes(javaClass.classLoader.getResourceAsStream("icon.png").readAllBytes(),ContentType.Image.PNG) } } diff --git a/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt b/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt new file mode 100644 index 00000000..6027b7e2 --- /dev/null +++ b/src/test/kotlin/dev/usbharu/hideout/routing/UserRoutingKtTest.kt @@ -0,0 +1,12 @@ +package dev.usbharu.hideout.routing + +import org.junit.jupiter.api.Test + +class UserRoutingKtTest { + @Test + fun userIconTest() { + println(String.Companion::class.java.classLoader) + println(String::class.java.classLoader) + println(String.javaClass.classLoader.getResourceAsStream("icon.png")?.readAllBytes()) + } +}