Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DriverDSLImpl: incompatible API between Corda CE and OS (4.6.1) #6826

Open
manosbatsis opened this issue Nov 26, 2020 · 2 comments
Open

DriverDSLImpl: incompatible API between Corda CE and OS (4.6.1) #6826

manosbatsis opened this issue Nov 26, 2020 · 2 comments
Labels

Comments

@manosbatsis
Copy link
Contributor

  • A clear description of the issue

Tools designed to use OS' DriverDSLImpl fail constructing an instance of the same class using CE.
The reason seems to be that CE adds an enableSNI: Boolean constructor parameter, perhaps without a default value.

  • Any logs or stack traces that you can provide (use a site like https://pastebin.com for larger logs)
java.lang.NoSuchMethodError: net.corda.testing.node.internal.DriverDSLImpl.<init>(Lnet/corda/testing/driver/PortAllocation;Lnet/corda/testing/driver/PortAllocation;Ljava/util/Map;Ljava/nio/file/Path;ZZZZLjava/util/List;Lnet/corda/testing/driver/JmxPolicy;Ljava/util/List;Lnet/corda/testing/node/internal/CompatibilityZoneParams;Lnet/corda/core/node/NetworkParameters;Ljava/util/Map;ZLjava/util/Collection;Ljava/nio/file/Path;Ljava/util/List;Ljava/util/Map;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
  • Steps to reproduce the issue

Try to construct an instance like

DriverDSLImpl(
                    portAllocation = defaultParameters.portAllocation,
                    debugPortAllocation = defaultParameters.debugPortAllocation,
                    systemProperties = defaultParameters.systemProperties,
                    driverDirectory = defaultParameters.driverDirectory.toAbsolutePath(),
                    useTestClock = defaultParameters.useTestClock,
                    isDebug = defaultParameters.isDebug,
                    startNodesInProcess = defaultParameters.startNodesInProcess,
                    waitForAllNodesToFinish = defaultParameters.waitForAllNodesToFinish,
                    extraCordappPackagesToScan = @Suppress("DEPRECATION") defaultParameters.extraCordappPackagesToScan,
                    notarySpecs = defaultParameters.notarySpecs,
                    jmxPolicy = defaultParameters.jmxPolicy,
                    compatibilityZone = null,
                    networkParameters = defaultParameters.networkParameters,
                    notaryCustomOverrides = defaultParameters.notaryCustomOverrides,
                    inMemoryDB = defaultParameters.inMemoryDB,
                    cordappsForAllNodes = uncheckedCast(defaultParameters.cordappsForAllNodes),
                    djvmBootstrapSource = defaultParameters.djvmBootstrapSource,
                    djvmCordaSource = defaultParameters.djvmCordaSource,
                    environmentVariables = defaultParameters.environmentVariables,
                    // This is missing from OS so it wont compile
                    // enableSNI = true,
                    allowHibernateToManageAppSchema = true,
                    premigrateH2Database = true
  • The version/tag/release or commit hash it occurred on

Corda CE 4.6.1

@r3jirabot
Copy link

Automatically created Jira issue: CORDA-4090

@manosbatsis
Copy link
Contributor Author

For the unlikely future bloke looking for a workaround, i used this in my node driver helper:

fun createDriver(defaultParameters: DriverParameters ): DriverDSLImpl {
    val driverParams = mapOf(
            "portAllocation" to defaultParameters.portAllocation,
            "debugPortAllocation" to defaultParameters.debugPortAllocation,
            "systemProperties" to defaultParameters.systemProperties,
            "driverDirectory" to defaultParameters.driverDirectory.toAbsolutePath(),
            "useTestClock" to defaultParameters.useTestClock,
            "isDebug" to defaultParameters.isDebug,
            "startNodesInProcess" to defaultParameters.startNodesInProcess,
            "waitForAllNodesToFinish" to defaultParameters.waitForAllNodesToFinish,
            "extraCordappPackagesToScan" to emptyList<String>(),//@Suppress("DEPRECATION") defaultParameters.extraCordappPackagesToScan,
            "notarySpecs" to defaultParameters.notarySpecs,
            "jmxPolicy" to defaultParameters.jmxPolicy,
            "compatibilityZone" to null,
            "networkParameters" to defaultParameters.networkParameters,
            "notaryCustomOverrides" to defaultParameters.notaryCustomOverrides,
            "inMemoryDB" to defaultParameters.inMemoryDB,
            "cordappsForAllNodes" to defaultParameters.cordappsForAllNodes as Collection<TestCordappInternal>?,
            "djvmBootstrapSource" to defaultParameters.djvmBootstrapSource,
            "djvmCordaSource" to defaultParameters.djvmCordaSource,
            "environmentVariables" to defaultParameters.environmentVariables,
            "enableSNI" to true,
            "allowHibernateToManageAppSchema" to true,
            "premigrateH2Database" to true

    )
    return createDriver(DriverDSLImpl::class, driverParams)
}


/**
 * A reflection-based tmp fix for managing differences
 * between Corda 4.0 and 4.6, also servig as a workaround for
 * - https://github.com/corda/corda/issues/6826
 * - https://r3-cev.atlassian.net/browse/CORDA-4090
 */
fun <T: Any> createDriver(
        targetClass: KClass<T>,
        parameters: Map<String,Any?>,
        targetConstructor: KFunction<T> = targetClass.primaryConstructor!!
):T{
    val constructorParameters = targetConstructor.parameters.associateBy({it},{ parameters[it.name] })
    return targetConstructor.callBy(constructorParameters)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants