net.corda.core.flows.UnexpectedFlowEndException: пытался получить доступ к завершенному сеансу SessionId (toLong = 8223329095323268472) с пустым буфером - PullRequest
0 голосов
/ 17 января 2019

я * использую Corda 4.0 RC1 и имею клон репозитория наличных денег эмитента; там у меня есть Corda-ResponderFlow, который должен сделать бизнес-тест; в настоящее время это вызывает исключение; поток запрограммирован таким образом

class ReceiveBankAccount(val otherSession: FlowSession) : FlowLogic<Unit>() {
    @Suspendable
    override fun call() {
        logger.info("Starting ReceiveBankAccount flow...")

        val signedTransactionFlow = object : SignTransactionFlow(otherSession) {
            @Suspendable
            override fun checkTransaction(stx: SignedTransaction) = requireThat {
                val bankAccountState = stx.tx.outputsOfType<BankAccountState>().single()
                val result = getBankAccountStateByAccountNumber(bankAccountState.accountNumber, serviceHub)
                if (result != null) {
                    val linearId = result.state.data.linearId
                    throw IllegalArgumentException("Bank account $bankAccountState already exists with linearId ($linearId).")
                }
            }
        }

        subFlow(signedTransactionFlow)

        if (!serviceHub.myInfo.isLegalIdentity(otherSession.counterparty)) {
            subFlow(ReceiveFinalityFlow(otherSession))
        }
    }
}

после выполнения родительского корда-потока AddBankAccount я получаю следующую ошибку net.corda.core.flows.UnexpectedFlowEndException: Tried to access ended session SessionId(toLong=8223329095323268472) with empty buffer что я не прав? кто-нибудь может мне помочь?

моя трассировка стека

net.corda.core.flows.UnexpectedFlowEndException: Tried to access ended session SessionId(toLong=8017581909056924623) with empty buffer
    at net.corda.node.services.statemachine.FlowStateMachineImpl.processEventsUntilFlowIsResumed(FlowStateMachineImpl.kt:161) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.suspend(FlowStateMachineImpl.kt:407) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:67) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:71) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:294) ~[corda-core-4.0-RC01.jar:?]
    at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:198) ~[corda-core-4.0-RC01.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:290) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:311) ~[corda-core-4.0-RC01.jar:?]
    at com.r3.corda.finance.cash.issuer.service.flows.ReceiveBankAccount.call(ReceiveBankAccount.kt:31) ~[classes/:?]
    at com.r3.corda.finance.cash.issuer.service.flows.ReceiveBankAccount.call(ReceiveBankAccount.kt:12) ~[classes/:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:228) ~[corda-node-4.0-RC01.jar:?]
    at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:45) ~[corda-node-4.0-RC01.jar:?]
    at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
    at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
    at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
    at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_131]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_131]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_131]
    at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.0-RC01.jar:?]
 @Suspendable
    override fun call(): SignedTransaction {
        logger.info("Starting AddBankAccount flow...")
        val accountNumber = bankAccount.accountNumber

        logger.info("Checking for existence of state for $bankAccount.")
        val result = getBankAccountStateByAccountNumber(accountNumber, serviceHub)

        if (result != null) {
            val linearId = result.state.data.linearId
            throw IllegalArgumentException("Bank account $accountNumber already exists with linearId ($linearId).")
        }

        logger.info("No state for $bankAccount. Adding it.")
        progressTracker.currentStep = TX_BUILDING
        val bankAccountState = bankAccount.toState(ourIdentity, verifier)
        val notary = serviceHub.networkMapCache.notaryIdentities.first()
        val verifierSsession = initiateFlow(bankAccountState.verifier)

        // The node running this flow is always the only signer.
        val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey))
        val outputStateAndContract = StateAndContract(bankAccountState, BankAccountContract.CONTRACT_ID)
        val unsignedTransaction = TransactionBuilder(notary = notary).withItems(command, outputStateAndContract)

        progressTracker.currentStep = TX_SIGNING
        val partiallySignedTransaction = serviceHub.signInitialTransaction(unsignedTransaction)

        progressTracker.currentStep = TX_VERIFICATION
        partiallySignedTransaction.verify(serviceHub)

        progressTracker.currentStep = SIGS_GATHERING
        val sessionsForFinality = if (serviceHub.myInfo.isLegalIdentity(bankAccountState.verifier)) emptyList() else listOf(verifierSsession)
        val fullySignedTx = subFlow(CollectSignaturesFlow(partiallySignedTransaction, sessionsForFinality, SIGS_GATHERING.childProgressTracker()))

        progressTracker.currentStep = VERIFYING_SIGS
        fullySignedTx.verifyRequiredSignatures()

        progressTracker.currentStep = FINALISATION
        // Share the added bank account state with the verifier/issuer.
        return subFlow(FinalityFlow(fullySignedTx, sessionsForFinality, FINALISATION.childProgressTracker()))
    }

ОШИБКА в InitiatorFlow:

flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer: exception: Collection contains no element matching the predicate.
Fri Jan 18 11:14:03 CET 2019>>> [ERROR] 11:14:03+0100 [pool-8-thread-2] command.CRaSHSession.execute - Error while evaluating request 'flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer' flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer: exception: Collection contains no element matching the predicate. [errorCode=hf0q78, moreInformationAt=https://errors.corda.net/OS/4.0-RC01/hf0q78]

ПРЕДУПРЕЖДЕНИЯ в InitiatorFlow:

[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.
[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.
[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.

1 Ответ

0 голосов
/ 24 февраля 2019

Вам нужно будет добавить ключ bankAccountState.verifier в команду.

В вашей команде изменения потока инициатора с:

val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey))

до:

val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey,bankAccountState.verifier.owningKey))
...