diff --git a/src/main/kotlin/com/pseuco/api/PseuCoShare.kt b/src/main/kotlin/com/pseuco/api/PseuCoShare.kt index b2703aeda33bf778163740f807d5c704db766cc6..74b59eec9ea283959a654df019524f7e496c8c44 100644 --- a/src/main/kotlin/com/pseuco/api/PseuCoShare.kt +++ b/src/main/kotlin/com/pseuco/api/PseuCoShare.kt @@ -8,6 +8,7 @@ import io.ktor.client.features.json.JsonFeature import io.ktor.client.features.json.serializer.KotlinxSerializer import io.ktor.client.request.accept import io.ktor.client.request.get +import io.ktor.client.request.parameter import io.ktor.client.request.post import io.ktor.client.statement.HttpStatement import io.ktor.http.ContentType @@ -62,6 +63,8 @@ object PseuCoShare : FileSharer { @Throws(PseuCoShareException::class) override suspend fun uploadFile(file: PseuCoComFile): URI = shareFile(file, true) + private val jsonAllowingStructuredMapKeys = Json { allowStructuredMapKeys = true } + /** * Uploads [file] to the [pseuCo.com](https://pseuco.com) sharing API. * @@ -92,7 +95,7 @@ object PseuCoShare : FileSharer { return try { URI( - Json { allowStructuredMapKeys = true }.parseToJsonElement( + jsonAllowingStructuredMapKeys.parseToJsonElement( c.content.toInputStream().reader().use { it.readText() }).jsonObject["url"]!!.jsonPrimitive.content ) } catch (e: SerializationException) { @@ -119,7 +122,7 @@ object PseuCoShare : FileSharer { host = "pseuco.com" port = protocol.defaultPort path("api", "paste", "get") - parameters["id"] = id + parameter("id", id) } accept(ContentType.Application.Json.withCharset(Charsets.UTF_8)) }.execute() diff --git a/src/main/kotlin/fxGui/PseucoAlert.kt b/src/main/kotlin/fxGui/PseucoAlert.kt index 0b33b88cbc51b305976174980f905e2d60d85d14..2de95bca9d318a341eb3ac569433fc4c43d19afa 100644 --- a/src/main/kotlin/fxGui/PseucoAlert.kt +++ b/src/main/kotlin/fxGui/PseucoAlert.kt @@ -52,6 +52,7 @@ internal open class PseucoAlert(alertType: Alert.AlertType) : Alert(alertType) { * @author Konstantin Kopper * @since 2.0.0 */ + @Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") private val STYLESHEET = PseucoAlert::class.java.getResource("/fxGui/css/alert.css").toExternalForm() } } diff --git a/src/main/kotlin/fxGui/debugger/channels/ChannelElement.kt b/src/main/kotlin/fxGui/debugger/channels/ChannelElement.kt index fa7bdc5de17cb9fcde3e6054b25753df2a20e65d..2c5dd0d6f38dcb6cae8d0f96c9081b2807000485 100644 --- a/src/main/kotlin/fxGui/debugger/channels/ChannelElement.kt +++ b/src/main/kotlin/fxGui/debugger/channels/ChannelElement.kt @@ -2,11 +2,10 @@ package fxGui.debugger.channels import javafx.scene.control.Label -internal class ChannelElement(private val element: String, private val type: ChannelType) : Label(element) { +@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") +internal class ChannelElement(element: String, type: ChannelType) : Label(element) { - internal constructor(element: Int, type: ChannelType) : this(element.toString(), type) - - internal constructor(element: Boolean, type: ChannelType) : this(element.toString(), type) + internal constructor(element: Any, type: ChannelType) : this(element.toString(), type) init { stylesheets += this::class.java.getResource("/fxGui/css/general.css").toExternalForm() diff --git a/src/main/kotlin/fxGui/debugger/channels/ChannelPane.kt b/src/main/kotlin/fxGui/debugger/channels/ChannelPane.kt index e154df6caa2799d8b9aea5f61e1fb1196cfe1e05..38fc35810ef082765b17828342dd55d7c00d11a2 100644 --- a/src/main/kotlin/fxGui/debugger/channels/ChannelPane.kt +++ b/src/main/kotlin/fxGui/debugger/channels/ChannelPane.kt @@ -7,7 +7,8 @@ import javafx.scene.layout.AnchorPane import javafx.scene.layout.HBox import java.util.concurrent.BlockingQueue -internal class ChannelPane<T>(internal val queue: BlockingQueue<T>, internal val type: ChannelType) : AnchorPane() { +internal class ChannelPane<T : Any>(internal val queue: BlockingQueue<T>, internal val type: ChannelType) : + AnchorPane() { /** * The label indicating the capacity of this channel. @@ -64,9 +65,10 @@ internal class ChannelPane<T>(internal val queue: BlockingQueue<T>, internal val internal fun update() { elements.children.clear() - queue.takeIf { it.isNotEmpty() }?.forEach { elements.children += ChannelElement(it.toString(), this.type) } - ?: { elements.children += ChannelElement("Channel is empty!", ChannelType.NONE) }() + queue.takeIf { it.isNotEmpty() }?.forEach { elements.children += ChannelElement(it, this.type) } + ?: run { elements.children += ChannelElement("Channel is empty!", ChannelType.NONE) } - channelPane.style = if (queue.remainingCapacity() == 0) "-fx-border-width: 3px; -fx-border-color: indianred;" else "" + channelPane.style = + if (queue.remainingCapacity() == 0) "-fx-border-width: 3px; -fx-border-color: indianred;" else "" } } diff --git a/src/main/kotlin/properties/AboutProperties.kt b/src/main/kotlin/properties/AboutProperties.kt index b6815d15830aaec067c32daf3fe9cb9fe6178f58..019366cef35f945ace868473f5edf30a10ce2720 100644 --- a/src/main/kotlin/properties/AboutProperties.kt +++ b/src/main/kotlin/properties/AboutProperties.kt @@ -56,7 +56,7 @@ object AboutProperties : Properties() { init { try { - load(this::class.java.getResourceAsStream("/about.properties")) + this::class.java.getResourceAsStream("/about.properties").use { load(it) } } catch (e: IOException) { System.err.println("Could not read properties. Using some default values.") if (Main.DEBUG) diff --git a/src/main/kotlin/properties/BuildProperties.kt b/src/main/kotlin/properties/BuildProperties.kt index 377a6a3d8354ff99fb1716e3121853ea7d78a7a5..16287f7bb77b7b88513a8a054d8b875fa92422c3 100644 --- a/src/main/kotlin/properties/BuildProperties.kt +++ b/src/main/kotlin/properties/BuildProperties.kt @@ -38,7 +38,7 @@ object BuildProperties : Properties() { init { try { - load(this::class.java.getResourceAsStream("/build.properties")) + this::class.java.getResourceAsStream("/build.properties").use { load(it) } } catch (e: IOException) { System.err.println("Reading build properties failed.") if (Main.DEBUG) diff --git a/src/main/kotlin/util/ZipUtilities.kt b/src/main/kotlin/util/ZipUtilities.kt index 0b61eb7c63cc645df5ec793120b6ebff2c74bf01..77dbe784ad98b7759be6272c7023a1f405bd43e0 100644 --- a/src/main/kotlin/util/ZipUtilities.kt +++ b/src/main/kotlin/util/ZipUtilities.kt @@ -32,6 +32,7 @@ object ZipUtilities { val buffer = ByteArray(1024) + @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") val inputStream = ZipInputStream(ZipUtilities::class.java.getResourceAsStream(name)) try { diff --git a/src/main/kotlin/webapp/CompanionWebApp.kt b/src/main/kotlin/webapp/CompanionWebApp.kt index 65cdc2dcdc07e2253a7e6a7a0cdabdd1cb8dd6be..6c6c9a5062202faecf2f8953223e8a42a2661990 100644 --- a/src/main/kotlin/webapp/CompanionWebApp.kt +++ b/src/main/kotlin/webapp/CompanionWebApp.kt @@ -22,6 +22,7 @@ import io.ktor.routing.post import io.ktor.routing.routing import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import java.awt.Desktop import java.net.URI @@ -117,7 +118,7 @@ object CompanionWebApp { Config.file.deleteOnExit() launch { // Wait for response to be sent and kill IDE afterwards. - Thread.sleep(250) + delay(250) exitProcess(0) } call.respond(HttpStatusCode.OK, "Success. Please close this tab and restart the IDE.")