mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Fix Deprecation Warnings (#1187)
This commit is contained in:
@@ -88,11 +88,12 @@ public final class QuickJs implements Closeable {
|
||||
context.getBindings("js").putMember(name, object);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.context.leave();
|
||||
this.context.close();
|
||||
this.context = null;
|
||||
if (this.context != null) {
|
||||
this.context.leave();
|
||||
this.context.close();
|
||||
this.context = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
@@ -68,7 +67,6 @@ fun Call.asObservableSuccess(): Observable<Response> =
|
||||
}
|
||||
|
||||
// Based on https://github.com/gildor/kotlin-coroutines-okhttp
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private suspend fun Call.await(callStack: Array<StackTraceElement>): Response {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
val callback =
|
||||
@@ -77,8 +75,9 @@ private suspend fun Call.await(callStack: Array<StackTraceElement>): Response {
|
||||
call: Call,
|
||||
response: Response,
|
||||
) {
|
||||
continuation.resume(response) {
|
||||
continuation.resume(response) { _, resourceToClose, _ ->
|
||||
response.body.close()
|
||||
resourceToClose.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.net.URLClassLoader
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import kotlin.io.path.Path
|
||||
|
||||
object PackageTools {
|
||||
private val logger = KotlinLogging.logger {}
|
||||
@@ -152,7 +153,7 @@ object PackageTools {
|
||||
): Any {
|
||||
try {
|
||||
logger.debug { "loading jar with path: $jarPath" }
|
||||
val classLoader = jarLoaderMap[jarPath] ?: URLClassLoader(arrayOf<URL>(URL("file:$jarPath")))
|
||||
val classLoader = jarLoaderMap[jarPath] ?: URLClassLoader(arrayOf<URL>(Path(jarPath).toUri().toURL()))
|
||||
val classToLoad = Class.forName(className, false, classLoader)
|
||||
|
||||
jarLoaderMap[jarPath] = classLoader
|
||||
|
||||
@@ -7,7 +7,6 @@ package suwayomi.tachidesk.manga.impl.util.network
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
@@ -17,7 +16,6 @@ import java.io.IOException
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
// Based on https://github.com/gildor/kotlin-coroutines-okhttp
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
suspend fun Call.await(): Response {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
enqueue(
|
||||
@@ -31,8 +29,9 @@ suspend fun Call.await(): Response {
|
||||
return
|
||||
}
|
||||
|
||||
continuation.resume(response) {
|
||||
continuation.resume(response) { _, resourceToClose, _ ->
|
||||
response.body.closeQuietly()
|
||||
resourceToClose.closeQuietly()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.security.MessageDigest
|
||||
import java.util.Date
|
||||
@@ -723,7 +723,7 @@ object WebInterfaceManager {
|
||||
|
||||
zipFile.outputStream().use { webUIZipFileOut ->
|
||||
|
||||
val connection = URL(url).openConnection() as HttpURLConnection
|
||||
val connection = URI.create(url).toURL().openConnection() as HttpURLConnection
|
||||
connection.connect()
|
||||
val contentLength = connection.contentLength
|
||||
|
||||
|
||||
Reference in New Issue
Block a user