From 70a6d6fd99dbc1d9a5e3460354de64706bd79da3 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Mon, 5 Aug 2024 16:02:24 +0200 Subject: [PATCH] Merge 'main' into 'dev/1.0.0' (#153) * build: Sync with eclipse-zenoh/zenoh@9d09742 from 2024-06-11 (#109) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@ed6c636 from 2024-06-12 (#112) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@8160b01 from 2024-06-13 (#115) Co-authored-by: eclipse-zenoh-bot * Enable releasing from any branch (#114) * build: Sync with eclipse-zenoh/zenoh@7adad94 from 2024-06-14 (#117) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@93f93d2 from 2024-06-17 (#118) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@2500e5a from 2024-06-20 (#119) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@869ace6 from 2024-07-02 (#120) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@b93ca84 from 2024-07-03 (#121) Co-authored-by: eclipse-zenoh-bot * Enabling snapshot publications for dev/1.0.0 on the CI * fix: wrong syntax in ci workflow (#124) * build: Sync with eclipse-zenoh/zenoh@b3e42ce from 2024-07-08 (#126) Co-authored-by: eclipse-zenoh-bot * Update main release workflow (#133) * Using 'android' property to enable/disable Android configuration (#127) * Enabling snapshot publications for dev/1.0.0 * refactor(gradle): using 'android' property to enable/disable Android configuration Examples: - `gradle build -Pandroid=true` enables build with android - `gradle build` won't consider any android configuration - `gradle publishAndroidReleaseToMavenLocal -Pandroid=true` publishes to maven local, without `-Pandroid=true` it won't work. * refactor(gradle): updating publication workflows * refactor(gradle): updating readme instructions --------- Co-authored-by: zettascale-bot <161707711+zettascale-bot@users.noreply.github.com> * fix(local publication): triggering compilation of zenoh jni when publishing jvm to maven local (#128) * Update actions (#130) * chore: Update setup-java to v4 * chore: update gradle action to newer version * chore: update gradle/wrapper-validation-action@v3 --------- Co-authored-by: Darius Maitia Co-authored-by: zettascale-bot <161707711+zettascale-bot@users.noreply.github.com> * fix: Update gradle actions to newer versions (#134) * fix: Update buildDir usage for gradle 8 * Update gradle wrapper action to newer version * calling gradle action via arguments is deprecated * fix: remove unnecessary call to buildDir() * fix: add -Pandroid to gradle dokkaHtml call Otherwise the docs won't build * Fix documentation publication error on CI (#136) * build: Sync with eclipse-zenoh/zenoh@0a969cb from 2024-07-25 (#141) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@e587aa9 from 2024-07-26 (#144) Co-authored-by: eclipse-zenoh-bot * build: Sync with eclipse-zenoh/zenoh@2d88c7b from 2024-07-29 (#147) Co-authored-by: eclipse-zenoh-bot * Fix JVM crash when finalizing a session that wasn't properly initialized (#139) (#140) * Fix snapshot publications on the CI (#149) * Fix ZPubThr example imports (#142) --------- Co-authored-by: eclipse-zenoh-bot <61247838+eclipse-zenoh-bot@users.noreply.github.com> Co-authored-by: eclipse-zenoh-bot Co-authored-by: Mahmoud Mazouz Co-authored-by: kydos Co-authored-by: Diogo Matsubara Co-authored-by: zettascale-bot <161707711+zettascale-bot@users.noreply.github.com> Co-authored-by: Jonathan Hepp --- .github/workflows/publish-dokka.yml | 2 +- .github/workflows/release.yml | 5 +++++ zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt | 7 +++++-- .../src/commonTest/kotlin/io/zenoh/SessionTest.kt | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-dokka.yml b/.github/workflows/publish-dokka.yml index 9b3dd3231..6e18fb58a 100644 --- a/.github/workflows/publish-dokka.yml +++ b/.github/workflows/publish-dokka.yml @@ -33,7 +33,7 @@ jobs: link-to-sdk: true - name: Build doc - run: gradle -Pandroid dokkaHtml + run: gradle -Pandroid=true dokkaHtml - name: Deploy doc if: ${{ inputs.live-run || false }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6225f9320..b8d09014a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,10 @@ on: type: string description: Release number of Zenoh required: false + branch: + type: string + description: Release branch + required: false jobs: tag: @@ -45,6 +49,7 @@ jobs: repo: ${{ github.repository }} live-run: ${{ inputs.live-run || false }} version: ${{ inputs.version }} + branch: ${{ inputs.branch }} github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }} - name: Checkout this repository diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt index 5416148c8..56a3cb085 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt @@ -54,7 +54,7 @@ import java.time.Duration */ class Session private constructor(private val config: Config) : AutoCloseable { - private var jniSession: JNISession? = JNISession() + private var jniSession: JNISession? = null private var declarations = mutableListOf() @@ -897,7 +897,10 @@ class Session private constructor(private val config: Config) : AutoCloseable { /** Launches the session through the jni session, returning the [Session] on success. */ private fun launch(): Result = runCatching { - return jniSession!!.open(config).map { this@Session } + jniSession = JNISession() + return jniSession!!.open(config) + .map { this@Session } + .onFailure { jniSession = null } } } diff --git a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/SessionTest.kt b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/SessionTest.kt index 57f83d631..336e404f9 100644 --- a/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/SessionTest.kt +++ b/zenoh-kotlin/src/commonTest/kotlin/io/zenoh/SessionTest.kt @@ -17,8 +17,8 @@ package io.zenoh import io.zenoh.exceptions.SessionException import io.zenoh.keyexpr.KeyExpr import io.zenoh.keyexpr.intoKeyExpr -import io.zenoh.sample.Sample import kotlinx.coroutines.runBlocking +import java.nio.file.Path import kotlin.test.* class SessionTest { @@ -42,6 +42,12 @@ class SessionTest { assertFalse(session.isOpen()) } + @Test + fun sessionOpeningFailure() { + val invalidConfig = Config.from(Path.of("invalid")) + assertFailsWith { Session.open(invalidConfig).getOrThrow() } + } + @Test fun sessionClose_succeedsDespiteNotFreeingAllDeclarations() { val session = Session.open().getOrThrow()