hello, I am curious about <https://youtrack.jetbra...
# getting-started
t
hello, I am curious about https://youtrack.jetbrains.com/issue/KT-18324 and the decision to respect default methods. I am more or less on the same boat as people commenting there, since java 8 that decision renders delegation mostly useless, given that default methods are a nice way for library to keep a level of compatibility when introducing new functionality. I am basically ending always with the manual delegation pattern, eg:
Copy code
private class EnhancedServerRequestObservationConvention(properties: ObservationProperties): ServerRequestObservationConvention {
        private val delegate = DefaultServerRequestObservationConvention(properties.http.server.requests.name)

        override fun getLowCardinalityKeyValues(context: ServerRequestObservationContext): KeyValues {
            val eventId = context.pathPattern?.let { UriTemplate(it).match(context.carrier.requestURI)["eventId"] } ?: "none"
            return delegate.getLowCardinalityKeyValues(context).and(KeyValue.of("eventId", eventId))
        }

        override fun supportsContext(context: Observation.Context): Boolean = delegate.supportsContext(context)
        override fun getContextualName(context: ServerRequestObservationContext): String? = delegate.getContextualName(context)
        override fun getName(): String? = delegate.name
        override fun getHighCardinalityKeyValues(context: ServerRequestObservationContext): KeyValues =
            delegate.getHighCardinalityKeyValues(context)
    }
the interface provides 5 methods, and I only need to customize one of them, so it be nice to have
private class EnhancedServerRequestObservationConvention(private val delegate: DefaultServerRequestObservationConvention) : ServerRequestObservationConvention by delegate
but alas cannot. I am wondering if other use cases (non spring server, eg android, other web framework) delegation as is is still somehow useful and if there is any desire to change that behavior, maybe in kotlin 3 or whatever
t
oh nice, I did not find that one, thanks 💯
e
it's linked to by the issue you posted
t
which is funny because it's linked in the issue I posted
exactly, I read the whole description and comments, and still missed the link 🤦