Skip to content

Commit

Permalink
feat: 升级jdk到17 #197
Browse files Browse the repository at this point in the history
  • Loading branch information
stubenhuang committed Jul 23, 2024
1 parent 6746104 commit bd43daf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import com.tencent.devops.plugin.api.EXTENSION_LOCATION
import com.tencent.devops.plugin.api.ExtensionType
import com.tencent.devops.plugin.api.PluginInfo
import com.tencent.devops.plugin.api.PluginMetadata
import org.springframework.boot.loader.LaunchedURLClassLoader
import org.springframework.boot.loader.archive.Archive
import org.springframework.boot.loader.archive.JarFileArchive
import org.springframework.boot.loader.launch.LaunchedClassLoader
import org.springframework.boot.loader.launch.Archive
import java.io.IOException
import java.net.URL
import java.nio.file.Files
import java.nio.file.Path
import java.security.MessageDigest
import java.util.LinkedList
import java.util.Properties
import java.util.function.Predicate
import java.util.jar.JarFile

/**
Expand Down Expand Up @@ -115,13 +115,13 @@ class PluginLoader(
}

private fun createClassloader(pluginPath: Path): ClassLoader {
val jarArchive = JarFileArchive(pluginPath.toFile())
val archives = jarArchive.getNestedArchives(searchFilter, nestedFilter)
val urls = mutableListOf<URL>(jarArchive.url)
val jarArchive = Archive.create(pluginPath.toFile())
val archives = jarArchive.getClassPathUrls(includeFilter, directorySearchFilter)
val urls = mutableListOf<URL>()
archives.forEach {
urls.add(it.url)
urls.add(it)
}
return LaunchedURLClassLoader(false, jarArchive, urls.toTypedArray(), javaClass.classLoader)
return LaunchedClassLoader(false, jarArchive, urls.toTypedArray(), javaClass.classLoader)
}

companion object {
Expand All @@ -131,9 +131,11 @@ class PluginLoader(
private const val PLUGIN_SCOPE = "Plugin-Scope"
private const val PLUGIN_AUTHOR = "Plugin-Author"
private const val PLUGIN_DESCRIPTION = "Plugin-Description"
val searchFilter = Archive.EntryFilter { entry -> entry.name.startsWith("lib/") }
val nestedFilter = Archive.EntryFilter { entry ->
!entry.isDirectory && entry.name.startsWith("lib/")
val directorySearchFilter = Predicate<Archive.Entry>() { entry ->
entry.name().startsWith("lib/")
}
val includeFilter = Predicate<Archive.Entry>() { entry ->
!entry.isDirectory && entry.name().startsWith("lib/")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object JwtUtils {
IllegalArgumentException::class
)
fun validateToken(signingKey: Key, token: String): Jws<Claims> {
return Jwts.parserBuilder().setSigningKey(signingKey).build().parseClaimsJws(token)
return Jwts.parser().setSigningKey(signingKey).build().parseClaimsJws(token)
}

fun createSigningKey(secretKey: String): Key {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class K8sShellHandler(
val api = CoreV1Api(client)
try {
val configMapName = "schedule-shell-$jobId-${updateTime.toEpochMilli()}"
if (api.exec { api.readNamespacedConfigMap(configMapName, namespace, null, null, null) } == null) {
if (api.exec { api.readNamespacedConfigMap(configMapName, namespace, null) } == null) {
val configMapBody = V1ConfigMap {
metadata {
name = configMapName
}
data = mapOf(CMD to source)
}
api.createNamespacedConfigMap(namespace, configMapBody, null, null, null)
api.createNamespacedConfigMap(namespace, configMapBody, null, null, null, null)
logger.info("Created configmap $configMapName")
}
val podBody = V1Pod {
Expand Down Expand Up @@ -105,15 +105,15 @@ class K8sShellHandler(
restartPolicy = "Never"
}
}
api.createNamespacedPod(namespace, podBody, null, null, null)
api.createNamespacedPod(namespace, podBody, null, null, null, null)
logger.info("Created pod $podName")
createdPod = true
var pod = api.exec { api.readNamespacedPod(podName, namespace, null, null, null) }
var pod = api.exec { api.readNamespacedPod(podName, namespace, null) }
var status = pod?.status?.phase.orEmpty()
logger.info("Pod status: $status")
while (pod != null && (status == "Running" || status == "Pending")) {
Thread.sleep(1000)
pod = api.exec { api.readNamespacedPod(podName, namespace, null, null, null) }
pod = api.exec { api.readNamespacedPod(podName, namespace, null) }
status = pod?.status?.phase.orEmpty()
}
logger.info("Pod status: $status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.io.InputStream
*/
object JsonUtils {
val objectMapper = ObjectMapper().apply {
registerModule(KotlinModule())
registerModule(KotlinModule.Builder().build())
registerModule(JavaTimeModule())
registerModule(ParameterNamesModule())
registerModule(Jdk8Module())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.context.annotation.Primary
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping

/**
* Sample FeignClient
Expand Down
1 change: 1 addition & 0 deletions devops-boot-sample/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.internal.mpp12x.deprecation.suppress=true

0 comments on commit bd43daf

Please sign in to comment.