mirror of
https://github.com/corda/corda.git
synced 2025-01-02 03:06:45 +00:00
Add RPC registration diagnostics
Add diagnostic information if attempting to use an RPC interface with duplicate method names, rather than throwing a collection error.
This commit is contained in:
parent
37e183652e
commit
f148765c57
@ -40,6 +40,7 @@ import rx.Observable
|
|||||||
import rx.Subscriber
|
import rx.Subscriber
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
|
import java.lang.reflect.Method
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.*
|
import java.util.concurrent.*
|
||||||
@ -92,7 +93,7 @@ class RPCServer(
|
|||||||
}
|
}
|
||||||
private val lifeCycle = LifeCycle(State.UNSTARTED)
|
private val lifeCycle = LifeCycle(State.UNSTARTED)
|
||||||
// The methodname->Method map to use for dispatching.
|
// The methodname->Method map to use for dispatching.
|
||||||
private val methodTable = ops.javaClass.declaredMethods.groupBy { it.name }.mapValues { it.value.single() }
|
private val methodTable: Map<String, Method>
|
||||||
// The observable subscription mapping.
|
// The observable subscription mapping.
|
||||||
private val observableMap = createObservableSubscriptionMap()
|
private val observableMap = createObservableSubscriptionMap()
|
||||||
// A mapping from client addresses to IDs of associated Observables
|
// A mapping from client addresses to IDs of associated Observables
|
||||||
@ -114,6 +115,16 @@ class RPCServer(
|
|||||||
private var clientBindingRemovalConsumer: ClientConsumer? = null
|
private var clientBindingRemovalConsumer: ClientConsumer? = null
|
||||||
private var serverControl: ActiveMQServerControl? = null
|
private var serverControl: ActiveMQServerControl? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
val groupedMethods = ops.javaClass.declaredMethods.groupBy { it.name }
|
||||||
|
groupedMethods.forEach { name, methods ->
|
||||||
|
if (methods.size > 1) {
|
||||||
|
throw IllegalArgumentException("Encountered more than one method called ${name} on ${ops.javaClass.name}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodTable = groupedMethods.mapValues { it.value.single() }
|
||||||
|
}
|
||||||
|
|
||||||
private fun createObservableSubscriptionMap(): ObservableSubscriptionMap {
|
private fun createObservableSubscriptionMap(): ObservableSubscriptionMap {
|
||||||
val onObservableRemove = RemovalListener<RPCApi.ObservableId, ObservableSubscription> {
|
val onObservableRemove = RemovalListener<RPCApi.ObservableId, ObservableSubscription> {
|
||||||
log.debug { "Unsubscribing from Observable with id ${it.key} because of ${it.cause}" }
|
log.debug { "Unsubscribing from Observable with id ${it.key} because of ${it.cause}" }
|
||||||
|
Loading…
Reference in New Issue
Block a user