Minor lambda simplifications and removing unused import.

This commit is contained in:
Chris Rankin 2019-07-19 00:53:52 +01:00
parent c15d6e9d62
commit 58f7fb9d4e
2 changed files with 3 additions and 4 deletions

View File

@ -19,7 +19,6 @@ import java.io.IOException
import java.io.InputStream
import java.net.*
import java.util.*
import java.util.jar.JarInputStream
/**
* A custom ClassLoader that knows how to load classes from a set of attachments. The attachments themselves only
@ -318,14 +317,14 @@ object AttachmentsClassLoaderBuilder {
isAttachmentTrusted: (Attachment) -> Boolean,
parent: ClassLoader = ClassLoader.getSystemClassLoader(),
block: (ClassLoader) -> T): T {
val attachmentIds = attachments.map { it.id }.toSet()
val attachmentIds = attachments.map(Attachment::id).toSet()
val serializationContext = cache.computeIfAbsent(Key(attachmentIds, params)) {
// Create classloader and load serializers, whitelisted classes
val transactionClassLoader = AttachmentsClassLoader(attachments, params, txId, isAttachmentTrusted, parent)
val serializers = createInstancesOfClassesImplementing(transactionClassLoader, SerializationCustomSerializer::class.java)
val whitelistedClasses = ServiceLoader.load(SerializationWhitelist::class.java, transactionClassLoader)
.flatMap { it.whitelist }
.flatMap(SerializationWhitelist::whitelist)
.toList()
// Create a new serializationContext for the current transaction. In this context we will forbid

View File

@ -151,7 +151,7 @@ private constructor(
// Switch thread local deserialization context to using a cached attachments classloader. This classloader enforces various rules
// like no-overlap, package namespace ownership and (in future) deterministic Java.
return AttachmentsClassLoaderBuilder.withAttachmentsClassloaderContext(
this.attachments + extraAttachments,
attachments + extraAttachments,
getParamsWithGoo(),
id,
isAttachmentTrusted = isAttachmentTrusted) { transactionClassLoader ->