kotlin

Kafka Join not firing after re-key

拟墨画扇 提交于 2021-02-07 09:43:33
问题 I'm working on a Kafka streams application written in Kotlin, and I'm seeing some bizarre behavior with a join. At a high level, I'm streaming two topics with different keys. However, I can rekey one of the messages so that they keys line up. After I do this though, the subsequent join is not fired. Below I have supplied the simplified code (with irrelevant portions elided and replaced with comments) val builder = KStreamBuilder() val joinWindow = JoinWindows.of(/* 30 days */).until(/* 365

Kafka Join not firing after re-key

随声附和 提交于 2021-02-07 09:43:18
问题 I'm working on a Kafka streams application written in Kotlin, and I'm seeing some bizarre behavior with a join. At a high level, I'm streaming two topics with different keys. However, I can rekey one of the messages so that they keys line up. After I do this though, the subsequent join is not fired. Below I have supplied the simplified code (with irrelevant portions elided and replaced with comments) val builder = KStreamBuilder() val joinWindow = JoinWindows.of(/* 30 days */).until(/* 365

Adding a Configuration as a dependency is a confusing behavior which isn't recommended

天大地大妈咪最大 提交于 2021-02-07 09:19:23
问题 I have encountered the following warning after trying to build my Kotlin project with Gradle 7. > Configure project :app Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts

Adding a Configuration as a dependency is a confusing behavior which isn't recommended

倾然丶 夕夏残阳落幕 提交于 2021-02-07 09:17:58
问题 I have encountered the following warning after trying to build my Kotlin project with Gradle 7. > Configure project :app Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts

Can't mock final class in test using Mockito with Kotlin

旧城冷巷雨未停 提交于 2021-02-07 08:45:10
问题 I'm trying to run a simple instrumentation test: class DefaultTest { private val networkHelper = Mockito.mock(NetworkHelperImpl::class.java) @Test fun inter() { given(networkHelper.isConnectedToNetwork()).willReturn(true) assertFalse { networkHelper.isConnectedToNetwork(false) } } } But i cant bacause of error: Mockito cannot mock/spy because : - final class How can i avoid it? As this guide says: https://antonioleiva.com/mockito-2-kotlin/ I'm create file: With this line: mock-maker-inline

Can't mock final class in test using Mockito with Kotlin

给你一囗甜甜゛ 提交于 2021-02-07 08:44:38
问题 I'm trying to run a simple instrumentation test: class DefaultTest { private val networkHelper = Mockito.mock(NetworkHelperImpl::class.java) @Test fun inter() { given(networkHelper.isConnectedToNetwork()).willReturn(true) assertFalse { networkHelper.isConnectedToNetwork(false) } } } But i cant bacause of error: Mockito cannot mock/spy because : - final class How can i avoid it? As this guide says: https://antonioleiva.com/mockito-2-kotlin/ I'm create file: With this line: mock-maker-inline

How are nested functions and lexical scope compiled in JVM languages?

梦想与她 提交于 2021-02-07 08:12:28
问题 As a concrete example for my question, here's a snippet in Python (which should be readable to the broadest number of people and which has a JVM implementation anyway): def memo(f): cache = {} def g(*args): if args not in cache: cache[args] = f(*args) return cache[args] return g How do industrial-strength languages compile a definition like this, in order to realize static scope? What if we only have nested definition but no higher order function-value parameters or return values, à la Pascal

How are nested functions and lexical scope compiled in JVM languages?

柔情痞子 提交于 2021-02-07 08:11:33
问题 As a concrete example for my question, here's a snippet in Python (which should be readable to the broadest number of people and which has a JVM implementation anyway): def memo(f): cache = {} def g(*args): if args not in cache: cache[args] = f(*args) return cache[args] return g How do industrial-strength languages compile a definition like this, in order to realize static scope? What if we only have nested definition but no higher order function-value parameters or return values, à la Pascal

Hibernate with Kotlin: @ManyToOne(fetch = FetchType.LAZY)

不打扰是莪最后的温柔 提交于 2021-02-07 07:32:12
问题 I am using Hibernate with Kotlin and I am having an issue with FetchType.LAZY on @ManyToOne relations. Consider following: @ManyToOne(fetch = FetchType.LAZY) open var event: Event? The problem is that when FetchType.LAZY is used, the fetched Event will be of class Event_$$_jvst_... with JavaassistLazyInitializer on it. But the event will never be initialized, everything will be null or empty. Once the FetchType.LAZY is removed, everything works correctly. This didn't happen in Java. I tried

Dealing with R8 + JvmStatic Annotation + Lambda in public API for Android Library written in Kotlin

ぃ、小莉子 提交于 2021-02-07 05:52:08
问题 First of all, please note that I'm not expecting why do you want to obfuscate library comments. This is a genuine problem I'm asking about. I have been having an issue dealing with R8/obfuscation with an Android library written in Kotlin. I've a public API method which is annotated with @JvmStatic and that method takes a Lambda as parameter. For example, take a look at code below, typealias MyLambdaCallback = (String, Map<String, Any>) -> Unit @Keep object MyApi { private var callback: