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

Support for Kotlin 1.3.0 #40

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions build.gradle
@@ -1,6 +1,6 @@
buildscript {
ext.kotlin_version = "1.2.70"
ext.kotlin_coroutines_version = "0.26.0"
ext.kotlin_version = "1.3.0"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.3.11

ext.kotlin_coroutines_version = "1.0.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.1.0

ext.spock_version = '1.1-groovy-2.4'
ext.spring_version = "5.0.9.RELEASE"
ext.spring_data_version = "2.0.10.RELEASE"
Expand Down Expand Up @@ -46,12 +46,6 @@ subprojects {
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

kotlin {
experimental {
coroutines "enable"
}
}
}

project(":spring-kotlin-coroutine") {
Expand All @@ -71,7 +65,6 @@ project(":spring-kotlin-coroutine") {
compile "org.springframework:spring-web:$spring_version", optional
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlin_coroutines_version", optional
compile "org.jetbrains.kotlinx:kotlinx-coroutines-rx1:$kotlin_coroutines_version", optional
compile "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlin_coroutines_version", optional
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

Expand Down
Expand Up @@ -16,7 +16,7 @@

package test

import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.channels.ReceiveChannel
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.Field
Expand Down
Expand Up @@ -16,7 +16,7 @@

package org.springframework.data.mongodb.repository.query;

import kotlin.coroutines.experimental.Continuation;
import kotlin.coroutines.Continuation;
import org.springframework.core.MethodParameter;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.lang.Nullable;
Expand Down
Expand Up @@ -16,7 +16,7 @@

package org.springframework.kotlin.experimental.coroutine.util;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think experimental can be dropped from package itself


import kotlin.coroutines.experimental.Continuation;
import kotlin.coroutines.Continuation;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Expand Up @@ -17,8 +17,8 @@
package org.springframework.data.mongodb.core

import com.mongodb.reactivestreams.client.MongoDatabase
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.reactive.openSubscription
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.reactive.openSubscription

interface CoroutineDatabaseCallback<T> {
val reactiveDatabaseCallback: ReactiveDatabaseCallback<T>
Expand All @@ -34,4 +34,4 @@ interface CoroutineDatabaseCallback<T> {
callback.doInDB(db).openSubscription()
}
}
}
}
Expand Up @@ -20,7 +20,7 @@ import com.mongodb.ReadPreference
import com.mongodb.client.result.DeleteResult
import com.mongodb.client.result.UpdateResult
import com.mongodb.coroutines.client.CoroutineMongoCollection
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.channels.ReceiveChannel
import org.bson.Document
import org.reactivestreams.Subscription
import org.springframework.data.geo.GeoResult
Expand Down
Expand Up @@ -21,12 +21,12 @@ import com.mongodb.client.result.DeleteResult
import com.mongodb.client.result.UpdateResult
import com.mongodb.coroutines.client.CoroutineMongoCollection
import com.mongodb.coroutines.client.asCoroutineMongoCollection
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.reactive.awaitFirst
import kotlinx.coroutines.experimental.reactive.awaitFirstOrDefault
import kotlinx.coroutines.experimental.reactive.awaitLast
import kotlinx.coroutines.experimental.reactive.awaitSingle
import kotlinx.coroutines.experimental.reactive.openSubscription
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.reactive.awaitFirst
import kotlinx.coroutines.reactive.awaitFirstOrDefault
import kotlinx.coroutines.reactive.awaitLast
import kotlinx.coroutines.reactive.awaitSingle
import kotlinx.coroutines.reactive.openSubscription
import org.bson.Document
import org.springframework.data.geo.GeoResult
import org.springframework.data.mongodb.core.aggregation.Aggregation
Expand Down Expand Up @@ -280,4 +280,4 @@ open class CoroutineMongoTemplate(

override fun <T> tail(query: Query, entityClass: Class<T>, collectionName: String): ReceiveChannel<T> =
reactiveMongoOperations.tail(query, entityClass, collectionName).openSubscription()
}
}
Expand Up @@ -16,15 +16,15 @@

package org.springframework.data.mongodb.repository.query

import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import org.springframework.core.convert.converter.Converter
import org.springframework.data.convert.EntityInstantiators
import org.springframework.data.mongodb.core.CoroutineMongoOperations
import org.springframework.data.mongodb.core.query.Query
import org.springframework.data.repository.query.ParameterAccessor
import org.springframework.data.repository.query.RepositoryQuery
import org.springframework.kotlin.experimental.coroutine.util.executeSuspend
import kotlin.coroutines.experimental.Continuation
import kotlin.coroutines.Continuation

abstract class AbstractCoroutineMongoQuery(
private val method: CoroutineMongoQueryMethod,
Expand Down
Expand Up @@ -16,9 +16,9 @@

package org.springframework.data.mongodb.repository.query

import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.reactive.openSubscription
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.reactive.openSubscription
import org.springframework.core.convert.converter.Converter
import org.springframework.data.convert.EntityInstantiators
import org.springframework.data.domain.Pageable
Expand Down
Expand Up @@ -35,7 +35,7 @@ import org.springframework.kotlin.experimental.coroutine.isCoroutineCollection
import org.springframework.kotlin.experimental.coroutine.returnTypeMetadata
import org.springframework.util.ClassUtils
import java.lang.reflect.Method
import kotlin.coroutines.experimental.Continuation
import kotlin.coroutines.Continuation

open class CoroutineMongoQueryMethod(
val method: Method,
Expand Down
Expand Up @@ -16,8 +16,8 @@

package org.springframework.data.mongodb.repository.support

import kotlinx.coroutines.experimental.reactive.awaitFirstOrDefault
import kotlinx.coroutines.experimental.reactive.awaitSingle
import kotlinx.coroutines.reactive.awaitFirstOrDefault
import kotlinx.coroutines.reactive.awaitSingle
import org.springframework.data.mongodb.core.CoroutineMongoOperations
import org.springframework.data.mongodb.core.CoroutineMongoTemplate
import org.springframework.data.mongodb.repository.CoroutineMongoRepository
Expand Down
Expand Up @@ -16,7 +16,7 @@

package org.springframework.data.repository.coroutine

import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.channels.ReceiveChannel
import org.springframework.data.repository.NoRepositoryBean
import org.springframework.data.repository.Repository

Expand Down Expand Up @@ -111,4 +111,4 @@ interface CoroutineCrudRepository<T, ID>: Repository<T, ID> {
*
*/
suspend fun deleteAll(): Unit
}
}
Expand Up @@ -16,8 +16,8 @@

package org.springframework.kotlin.experimental.coroutine.util
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experimental can be dropped...


import kotlin.coroutines.experimental.Continuation
import kotlin.coroutines.Continuation

interface SuspendExecutor {
fun <T> execute(cont: Continuation<T>, lambda: suspend () -> T): Any?
}
}
Expand Up @@ -16,11 +16,11 @@

package org.springframework.kotlin.experimental.coroutine.util

import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlin.coroutines.experimental.Continuation
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.consumeEach
import kotlin.coroutines.Continuation

fun <T> executeSuspend(cont: Continuation<T>, lambda: suspend () -> T): Any? =
DefaultSuspendExecutor.INSTANCE.execute(cont, lambda)

suspend fun ReceiveChannel<*>.flush() = consumeEach { }
suspend fun ReceiveChannel<*>.flush() = consumeEach { }
Expand Up @@ -19,7 +19,7 @@ package demo.app.event
import demo.app.util.logger
import demo.app.web.DemoApplicationEvent
import demo.app.web.SimpleEvent
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.delay
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component

Expand All @@ -40,4 +40,4 @@ open class CoroutineListener {
companion object {
private val logger = logger()
}
}
}
Expand Up @@ -17,7 +17,7 @@
package demo.app.service

import demo.app.util.logger
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.delay
import org.springframework.cache.annotation.Cacheable
import org.springframework.kotlin.experimental.coroutine.annotation.Coroutine
import org.springframework.kotlin.experimental.coroutine.context.DEFAULT_DISPATCHER
Expand Down Expand Up @@ -73,4 +73,4 @@ open class DemoService {
companion object {
private val logger = logger()
}
}
}
Expand Up @@ -16,13 +16,15 @@

package org.springframework.kotlin.experimental.coroutine

import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.experimental.channels.consumeEach
import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.suspendCancellableCoroutine
import java.util.Optional
import kotlin.coroutines.experimental.Continuation
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.Continuation
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

@Suppress("UNCHECKED_CAST")
fun <T: Any> runBlocking(lambda: (Continuation<T>) -> Any) = runBlocking {
Expand All @@ -43,4 +45,4 @@ fun <T> ReceiveChannel<T>.asList(): List<T> = runBlocking {
mutableListOf<T>().apply {
consumeEach { add(it) }
}
}
}
Expand Up @@ -16,18 +16,18 @@

package org.springframework.kotlin.experimental.coroutine.util;

import kotlin.coroutines.experimental.Continuation;
import kotlin.coroutines.experimental.CoroutineContext;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function2;
import kotlinx.coroutines.experimental.BuildersKt;
import kotlinx.coroutines.experimental.CoroutineScope;
import kotlinx.coroutines.experimental.CoroutineStart;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineStart;

public abstract class CoroutineUtils {
private CoroutineUtils() {
}

static public <T> Object runCoroutine(final CoroutineContext context, final Function2<CoroutineScope, Continuation<? super T>, ? super T> fun, final Continuation<? super T> continuation) {
return BuildersKt.withContext(context, CoroutineStart.DEFAULT, fun, continuation);
return BuildersKt.withContext(context, fun, continuation);
}
}
Expand Up @@ -16,15 +16,17 @@

package org.springframework.context.event

import kotlinx.coroutines.experimental.runBlocking
import kotlinx.coroutines.runBlocking
import org.springframework.context.ApplicationEvent
import org.springframework.kotlin.experimental.coroutine.event.CoroutineApplicationListener
import org.springframework.kotlin.experimental.coroutine.event.CoroutineApplicationEventPublisher
import org.springframework.kotlin.experimental.coroutine.event.CoroutineEvent
import org.springframework.util.ObjectUtils
import java.lang.reflect.Method
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.experimental.suspendCoroutine
import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED
import kotlin.coroutines.suspendCoroutine
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

internal open class SimpleCoroutineApplicationListenerMethodAdapter(beanName: String,
targetClass: Class<*>, method: Method, val publisher: CoroutineApplicationEventPublisher
Expand Down Expand Up @@ -86,4 +88,4 @@ internal open class SimpleCoroutineApplicationListenerMethodAdapter(beanName: St
publisher.publishEvent(event)
}
}
}
}
Expand Up @@ -16,11 +16,11 @@

package org.springframework.kotlin.experimental.coroutine

import kotlinx.coroutines.experimental.CoroutineDispatcher
import kotlinx.coroutines.experimental.channels.ReceiveChannel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.channels.ReceiveChannel
import org.springframework.util.ClassUtils
import java.lang.reflect.Method
import kotlin.coroutines.experimental.CoroutineContext
import kotlin.coroutines.CoroutineContext
import kotlin.reflect.KClass
import kotlin.reflect.jvm.kotlinFunction

Expand Down