Skip to content

Commit

Permalink
Update versions, use newer APIs, enable Gradle configuration cache (#251
Browse files Browse the repository at this point in the history
)

* Gradle 8.6
* Kotlin 1.9.22
* Coroutines 1.8.0
* use kotlinx-coroutines-test module
* replace deprecated on native currentMillis
  • Loading branch information
whyoleg authored Mar 2, 2024
1 parent 61459a6 commit 2239c5c
Show file tree
Hide file tree
Showing 32 changed files with 131 additions and 171 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2015-2023 the original author or authors.
# Copyright 2015-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,13 +16,13 @@
group=io.rsocket.kotlin
version=0.16.0-SNAPSHOT
#Kotlin
kotlin.js.compiler=ir
kotlin.native.ignoreIncorrectDependencies=true
kotlinx.atomicfu.enableJvmIrTransformation=true
kotlinx.atomicfu.enableJsIrTransformation=true
kotlinx.atomicfu.enableNativeIrTransformations=true
#Gradle
org.gradle.jvmargs=-Xmx2g
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2g
org.gradle.vfs.watch=true
11 changes: 4 additions & 7 deletions gradle/libs.updates.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

/**
* run to check for dependencies:
* ./gradlew :dependencyUpdates --init-script gradle/libs.updates.gradle.kts --no-configure-on-demand
* ./gradlew dependencyUpdates --init-script gradle/libs.updates.gradle.kts --no-configuration-cache
*/

initscript {
Expand All @@ -28,12 +28,9 @@ initscript {
}
}

allprojects {
println("Project: $name / ${rootProject.name}")
rootProject {
apply<com.github.benmanes.gradle.versions.VersionsPlugin>()

// for root project add dependency on included builds
if (name == "rsocket-kotlin") tasks.named("dependencyUpdates") {
tasks.named("dependencyUpdates") {
gradle.includedBuilds.forEach {
dependsOn(it.task(":dependencyUpdates"))
}
Expand Down
11 changes: 6 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[versions]
kotlinx-atomicfu = "0.20.2"
kotlinx-coroutines = "1.6.4" #1.7.0 needs ktor with 1.7.0...
kotlinx-atomicfu = "0.23.2"
kotlinx-coroutines = "1.8.0"
kotlinx-benchmark = "0.4.8"
kotlinx-bcv = "0.13.1"
kotlinx-bcv = "0.14.0"

ktor = "2.3.0"
ktor = "2.3.8"

turbine = "0.12.3" #0.13.0 needs coroutines 1.7.0
turbine = "1.0.0"

rsocket-java = "1.1.3"

jmh = "1.36"

[libraries]
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor", version.ref = "kotlinx-coroutines" }

kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "kotlinx-atomicfu" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,8 +14,6 @@
* limitations under the License.
*/

import org.jetbrains.kotlin.gradle.*

plugins {
kotlin("multiplatform")
id("build-parameters")
Expand All @@ -24,9 +22,6 @@ plugins {
kotlin {
jvmToolchain(8)

@OptIn(ExperimentalKotlinGradlePluginApi::class)
targetHierarchy.default()

targets.configureEach {
compilations.configureEach {
compilerOptions.configure {
Expand All @@ -44,6 +39,5 @@ kotlin {
}

val buildParameters = the<buildparameters.BuildParametersExtension>()

tasks.matching { it.name.endsWith("test", ignoreCase = true) }.configureEach { onlyIf { !buildParameters.skip.test } }
tasks.matching { it.name.startsWith("link", ignoreCase = true) }.configureEach { onlyIf { !buildParameters.skip.link } }
if (buildParameters.skip.test) tasks.matching { it.name.endsWith("test", ignoreCase = true) }.configureEach { onlyIf { false } }
if (buildParameters.skip.link) tasks.matching { it.name.startsWith("link", ignoreCase = true) }.configureEach { onlyIf { false } }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@ plugins {
id("build-parameters")
}

val kotlinVersion = "1.8.21"
val kotlinVersion = "1.9.22"
val kotlinVersionOverride = the<buildparameters.BuildParametersExtension>().useKotlin.orNull?.takeIf(String::isNotBlank)

if (kotlinVersionOverride != null) logger.lifecycle("Kotlin version override: $kotlinVersionOverride")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
19 changes: 18 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
#
# Copyright 2015-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
26 changes: 15 additions & 11 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright 2015-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -130,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
4 changes: 4 additions & 0 deletions rsocket-core/api/rsocket-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public final class io/rsocket/kotlin/core/WellKnownMimeType : java/lang/Enum, io
public static final field VideoH264 Lio/rsocket/kotlin/core/WellKnownMimeType;
public static final field VideoH265 Lio/rsocket/kotlin/core/WellKnownMimeType;
public static final field VideoVp8 Lio/rsocket/kotlin/core/WellKnownMimeType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public fun getIdentifier ()B
public fun getText ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
Expand Down Expand Up @@ -383,6 +384,7 @@ public final class io/rsocket/kotlin/logging/LoggingLevel : java/lang/Enum {
public static final field INFO Lio/rsocket/kotlin/logging/LoggingLevel;
public static final field TRACE Lio/rsocket/kotlin/logging/LoggingLevel;
public static final field WARN Lio/rsocket/kotlin/logging/LoggingLevel;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/rsocket/kotlin/logging/LoggingLevel;
public static fun values ()[Lio/rsocket/kotlin/logging/LoggingLevel;
}
Expand Down Expand Up @@ -581,6 +583,7 @@ public final class io/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind : java/
public static final field NotSampled Lio/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind;
public static final field Sample Lio/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind;
public static final field Unspecified Lio/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind;
public static fun values ()[Lio/rsocket/kotlin/metadata/ZipkinTracingMetadata$Kind;
}
Expand Down Expand Up @@ -728,6 +731,7 @@ public final class io/rsocket/kotlin/metadata/security/WellKnowAuthType : java/l
public static final field Bearer Lio/rsocket/kotlin/metadata/security/WellKnowAuthType;
public static final field Companion Lio/rsocket/kotlin/metadata/security/WellKnowAuthType$Companion;
public static final field Simple Lio/rsocket/kotlin/metadata/security/WellKnowAuthType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public fun getIdentifier ()B
public fun getText ()Ljava/lang/String;
public fun toString ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,25 +22,27 @@ import io.rsocket.kotlin.frame.*
import io.rsocket.kotlin.keepalive.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlin.time.*

internal class KeepAliveHandler(
private val keepAlive: KeepAlive,
private val sender: FrameSender
private val sender: FrameSender,
) {
private val lastMark = atomic(currentMillis()) // mark initial timestamp for keepalive
private val initial = TimeSource.Monotonic.markNow()
private fun currentDelayMillis() = initial.elapsedNow().inWholeMilliseconds

private val lastMark = atomic(currentDelayMillis()) // mark initial timestamp for keepalive

suspend fun mark(frame: KeepAliveFrame) {
lastMark.value = currentMillis()
lastMark.value = currentDelayMillis()
if (frame.respond) sender.sendKeepAlive(false, 0, frame.data)
}

suspend fun tick() {
delay(keepAlive.intervalMillis.toLong())
if (currentMillis() - lastMark.value >= keepAlive.maxLifetimeMillis)
if (currentDelayMillis() - lastMark.value >= keepAlive.maxLifetimeMillis)
throw RSocketError.ConnectionError("No keep-alive for ${keepAlive.maxLifetimeMillis} ms")

sender.sendKeepAlive(true, 0, ByteReadPacket.Empty)
}
}

internal expect fun currentMillis(): Long
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2022 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,7 +44,7 @@ internal suspend inline fun FlowCollector<Payload>.emitAllWithRequestN(
) {
val collector = object : RequestFlowCollector(this, strategy) {
override suspend fun onRequest(n: Int) {
@OptIn(ExperimentalCoroutinesApi::class)
@OptIn(DelicateCoroutinesApi::class)
if (!channel.isClosedForReceive) onRequest(n)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ internal abstract class ResponderFrameHandler : FrameHandler(), SendFrameHandler
}
}

@Suppress("DEPRECATION")
private object NoPool : ObjectPool<ChunkBuffer> {
override val capacity: Int
get() = error("should not be called")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class RequesterRequestChannelFrameHandler(
return isCancelled
}

@OptIn(ExperimentalCoroutinesApi::class)
@OptIn(DelicateCoroutinesApi::class)
override fun onSendComplete() {
if (channel.isClosedForSend) streamsStorage.remove(id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal class ResponderRequestChannelFrameHandler(
}

override fun onSendComplete() {
@OptIn(ExperimentalCoroutinesApi::class)
@OptIn(DelicateCoroutinesApi::class)
if (channel.isClosedForSend) streamsStorage.remove(id)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,7 @@ import kotlinx.coroutines.*
import kotlin.test.*

class ConnectionEstablishmentTest : SuspendTest, TestWithLeakCheck {
@Ignore // it will be rewritten anyway
@Test
fun responderRejectSetup() = test {
val errorMessage = "error"
Expand Down
Loading

0 comments on commit 2239c5c

Please sign in to comment.