Skip to content

Commit

Permalink
Merge branch 'main' into releases
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	packages/external/core
#	packages/library-base/src/commonMain/kotlin/io/realm/kotlin/internal/RealmImpl.kt
  • Loading branch information
Christian Melchior committed Nov 1, 2023
2 parents 161ea05 + 65fa711 commit 0accea3
Show file tree
Hide file tree
Showing 73 changed files with 766 additions and 462 deletions.
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
## 1.11.2 (YYYY-MM-DD)
## 1.12.0-SNAPSHOT (YYYY-MM-DD)

### Enhancements
This release upgrades the Sync metadata in a way that is not compatible with older versions. To downgrade a Sync app from this version, you'll need to manually delete the metadata folder located at `$[SYNC-ROOT-DIRECTORY]/mongodb-realm/[APP-ID]/server-utility/metadata/`. This will log out all users.

### Breaking Changes
* None.

### Enhancements
* Realm will no longer set the JVM bytecode to 1.8 when applying the Realm plugin. (Issue [#1513](https://github.com/realm/realm-kotlin/issues/1513))
* The Realm Gradle Plugin no longer has a dependency on KAPT. (Issue [#1513](https://github.com/realm/realm-kotlin/issues/1513))

### Fixed
* `Realm.getNumberOfActiveVersions` now returns the actual number of active versions. (Core issue [#6960](https://github.com/realm/realm-core/pull/6960))
* Fixed memory leak on Darwin caused by a reference cycle between resources and the GC cleaner. (Issue [#1530](https://github.com/realm/realm-kotlin/pull/1530))
* Fixed memory leaks on the JVM platform, see PR for more information. (Issue [#1526](https://github.com/realm/realm-kotlin/pull/1526))
* Removed pin on the initial realm version after opening a Realm. (Issue [#1519](https://github.com/realm/realm-kotlin/pull/1519))
* `Realm.close()` is now idempotent.
* Fix error in `RealmAny.equals` that would sometimes return `true` when comparing RealmAnys wrapping same type but different values. (Issue [#1523](https://github.com/realm/realm-kotlin/pull/1523))
* [Sync] If calling a function on App Services that resulted in a redirect, it would only redirect for GET requests. (Issue [#1517](https://github.com/realm/realm-kotlin/pull/1517))
* [Sync] Manual client reset on Windows would not trigger correctly when run inside `onManualResetFallback`. (Issue [#1515](https://github.com/realm/realm-kotlin/pull/1515))
* [Sync] `ClientResetRequiredException.executeClientReset()` now returns a boolean indicating if the manual reset fully succeded or not. (Issue [#1515](https://github.com/realm/realm-kotlin/pull/1515))
* [Sync] If calling a function on App Services that resulted in a redirect, it would only redirect for
GET requests. (Issue [#1517](https://github.com/realm/realm-kotlin/pull/1517))
* [Sync] If calling a function on App Services that resulted in a redirect, it would only redirect for GET requests. (Issue [#1517](https://github.com/realm/realm-kotlin/pull/1517))

### Compatibility
* File format: Generates Realms with file format v23.
Expand All @@ -24,7 +38,7 @@
* Minimum Android SDK: 16.

### Internal
* Updated to Realm Core 13.20.0, commit a3717e492ec606e42995169cf706a82fc1cd0698.
* Updated to Realm Core 13.23.2, commit e6271d72308b40399890060f58a88cf568c2ee22.


## 1.11.1 (2023-09-07)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Next: head to the full KMM [example](https://github.com/realm/realm-kotlin-sampl
If you want to test recent bugfixes or features that have not been packaged in an official release yet, you can use a **-SNAPSHOT** release of the current development version of Realm via Gradle, available on [Maven Central](https://oss.sonatype.org/content/repositories/snapshots/io/realm/kotlin/)

## Groovy
```
```Gradle
// Global build.gradle
buildscript {
repositories {
Expand Down Expand Up @@ -280,7 +280,7 @@ apply plugin: "io.realm.kotlin"
```

## Kotlin
```
```Kotlin
// Global build.gradle

buildscript {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ android {
compileSdk = Versions.Android.compileSdkVersion

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = Versions.sourceCompatibilityVersion
targetCompatibility = Versions.targetCompatibilityVersion
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = Versions.kotlinJvmTarget
}

defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ allprojects {
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = Versions.jvmTarget
kotlinOptions.jvmTarget = Versions.kotlinJvmTarget
}
}

Expand Down
5 changes: 5 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ gradlePlugin {
}
}

java {
sourceCompatibility = Versions.sourceCompatibilityVersion
targetCompatibility = Versions.targetCompatibilityVersion
}

repositories {
google()
gradlePluginPortal()
Expand Down
14 changes: 8 additions & 6 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import org.gradle.api.JavaVersion

/**
* Enum describing operating systems we can build on.
Expand Down Expand Up @@ -62,7 +62,7 @@ val HOST_OS: OperatingSystem = findHostOs()

object Realm {
val ciBuild = (System.getenv("JENKINS_HOME") != null)
const val version = "1.11.2-SNAPSHOT"
const val version = "1.12.0-SNAPSHOT"
const val group = "io.realm.kotlin"
const val projectUrl = "https://realm.io"
const val pluginPortalId = "io.realm.kotlin"
Expand Down Expand Up @@ -124,20 +124,22 @@ object Versions {
const val jmh = "1.34" // https://github.com/openjdk/jmh
const val jmhPlugin = "0.6.6" // https://github.com/melix/jmh-gradle-plugin
const val junit = "4.13.2" // https://mvnrepository.com/artifact/junit/junit
const val jvmTarget = "1.8"
const val kbson = "0.3.0" // https://github.com/mongodb/kbson
// When updating the Kotlin version, also remember to update /examples/min-android-sample/build.gradle.kts
const val kotlin = "1.8.21" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details
const val latestKotlin = "1.9.0" // https://kotlinlang.org/docs/eap.html#build-details
const val kotlinJvmTarget = "1.8" // Which JVM bytecode version is kotlin compiled to.
const val latestKotlin = "1.9.20-Beta" // https://kotlinlang.org/docs/eap.html#build-details
const val kotlinCompileTesting = "1.5.0" // https://github.com/tschuchortdev/kotlin-compile-testing
const val ktlint = "0.45.2" // https://github.com/pinterest/ktlint
const val ktor = "2.1.2" // https://github.com/ktorio/ktor
const val multidex = "2.0.1" // https://developer.android.com/jetpack/androidx/releases/multidex
const val nexusPublishPlugin = "1.1.0" // https://github.com/gradle-nexus/publish-plugin
const val okio = "3.2.0" // https://square.github.io/okio/#releases
const val relinker = "1.4.5" // https://github.com/KeepSafe/ReLinker
const val serialization = "1.4.0" // https://kotlinlang.org/docs/releases.html#release-details
const val shadowJar = "6.1.0" // https://mvnrepository.com/artifact/com.github.johnrengelman.shadow/com.github.johnrengelman.shadow.gradle.plugin?repo=gradle-plugins
const val multidex = "2.0.1" // https://developer.android.com/jetpack/androidx/releases/multidex
const val kbson = "0.3.0" // https://github.com/mongodb/kbson
val sourceCompatibilityVersion = JavaVersion.VERSION_1_8 // Language level of any Java source code.
val targetCompatibilityVersion = JavaVersion.VERSION_1_8 // Version of generated JVM bytecode from Java files.
}

// Could be actual Dependency objects
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/realm-lint.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ allprojects {

description = "Check Kotlin code style."
classpath = ktlint
jvmArgs = listOf("--add-opens=java.base/java.lang=ALL-UNNAMED")
mainClass.set("com.pinterest.ktlint.Main")
args = listOf(
"src/**/*.kt",
Expand All @@ -74,6 +75,7 @@ allprojects {

description = "Fix Kotlin code style deviations."
classpath = ktlint
jvmArgs = listOf("--add-opens=java.base/java.lang=ALL-UNNAMED")
mainClass.set("com.pinterest.ktlint.Main")
args = listOf(
"-F",
Expand Down
6 changes: 3 additions & 3 deletions dependencies.list
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Version of MongoDB Realm used by integration tests
# See https://github.com/realm/ci/packages/147854 for available versions
MONGODB_REALM_SERVER=2023-05-15
MONGODB_REALM_SERVER=2023-10-10

# `BAAS` and `BAAS-UI` projects commit hashes matching MONGODB_REALM_SERVER image version
# note that the MONGODB_REALM_SERVER image is a nightly build, find the matching commits
# for that date within the following repositories:
# https://github.com/10gen/baas/
# https://github.com/10gen/baas-ui/
REALM_BAAS_GIT_HASH=92fc646871b507c73e48cc05ebec54fc9a134ae7
REALM_BAAS_UI_GIT_HASH=67ad3606ec1137640ea84dcfe7a1a1b29aa7508f
REALM_BAAS_GIT_HASH=8246fc548763eb908b8090df864e9924e3330a0d
REALM_BAAS_UI_GIT_HASH=8a1843be2bf24f2faa705c5470a5bdd8d954f7ea
4 changes: 2 additions & 2 deletions examples/kmm-sample/androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = Versions.sourceCompatibilityVersion
targetCompatibility = Versions.targetCompatibilityVersion
}
}
2 changes: 1 addition & 1 deletion examples/kmm-sample/compose-desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = Versions.jvmTarget
kotlinOptions.jvmTarget = Versions.kotlinJvmTarget
}

application {
Expand Down
6 changes: 3 additions & 3 deletions examples/realm-java-compatibility/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility Versions.sourceCompatibilityVersion
targetCompatibility Versions.targetCompatibilityVersion
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = Versions.kotlinJvmTarget
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = Versions.sourceCompatibilityVersion
targetCompatibility = Versions.targetCompatibilityVersion
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = Versions.kotlinJvmTarget
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ allprojects {
version = Realm.version
group = Realm.group

// Define JVM bytecode target for all Kotlin targets
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "${Versions.jvmTarget}"
kotlinOptions.jvmTarget = "${Versions.kotlinJvmTarget}"
}
}

Expand Down
14 changes: 4 additions & 10 deletions packages/cinterop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ val nativeLibraryIncludesIosSimulatorArm64Release =
includeBinaries(releaseLibs.map { "$absoluteCorePath/build-simulator-arm64/lib/$it" })

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = Versions.jvmTarget
}
}
jvm()
android("android") {
publishLibraryVariants("release")
}
Expand Down Expand Up @@ -344,12 +340,10 @@ android {
path = project.file("src/jvm/CMakeLists.txt")
}
}
// To avoid
// Failed to transform kotlinx-coroutines-core-jvm-1.5.0-native-mt.jar ...
// The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = Versions.sourceCompatibilityVersion
targetCompatibility = Versions.targetCompatibilityVersion
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import io.realm.kotlin.internal.interop.realm_sync_errno_connection_e
import io.realm.kotlin.internal.interop.realm_sync_errno_session_e
import io.realm.kotlin.internal.interop.realm_sync_session_resync_mode_e
import io.realm.kotlin.internal.interop.realm_sync_session_state_e
import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e
import io.realm.kotlin.internal.interop.realm_user_state_e
import io.realm.kotlin.internal.interop.realm_web_socket_errno_e
import io.realm.kotlin.internal.interop.sync.AuthProvider
Expand All @@ -38,6 +39,7 @@ import io.realm.kotlin.internal.interop.sync.MetadataMode
import io.realm.kotlin.internal.interop.sync.SyncConnectionErrorCode
import io.realm.kotlin.internal.interop.sync.SyncSessionErrorCode
import io.realm.kotlin.internal.interop.sync.SyncSessionResyncMode
import io.realm.kotlin.internal.interop.sync.WebsocketCallbackResult
import io.realm.kotlin.internal.interop.sync.WebsocketErrorCode
import org.junit.Test
import kotlin.reflect.KClass
Expand Down Expand Up @@ -135,6 +137,13 @@ class SyncEnumTests {
}
}

@Test
fun websocketResultCode() {
checkEnum(realm_sync_socket_callback_result_e::class) { nativeValue ->
WebsocketCallbackResult.of(nativeValue)
}
}

private inline fun <T : Any> checkEnum(
enumClass: KClass<out Any>,
mapNativeValue: (Int) -> T?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ expect object RealmInterop {
// User
fun realm_user_get_all_identities(user: RealmUserPointer): List<SyncUserIdentity>
fun realm_user_get_identity(user: RealmUserPointer): String
fun realm_user_get_auth_provider(user: RealmUserPointer): AuthProvider
fun realm_user_get_access_token(user: RealmUserPointer): String
fun realm_user_get_refresh_token(user: RealmUserPointer): String
fun realm_user_get_device_id(user: RealmUserPointer): String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,22 @@ expect enum class WebsocketErrorCode : CodeDescription {
internal fun of(nativeValue: Int): WebsocketErrorCode?
}
}

/**
* Wrapper for C-API `realm_sync_socket_callback_result`
* See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L298
*/
expect enum class WebsocketCallbackResult : CodeDescription {
RLM_ERR_SYNC_SOCKET_SUCCESS,
RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED,
RLM_ERR_SYNC_SOCKET_RUNTIME,
RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY,
RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED,
RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED,
RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED,
RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT;

companion object {
fun of(nativeValue: Int): WebsocketCallbackResult?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1157,10 +1157,6 @@ actual object RealmInterop {
return realmc.realm_user_get_identity(user.cptr())
}

actual fun realm_user_get_auth_provider(user: RealmUserPointer): AuthProvider {
return AuthProvider.of(realmc.realm_user_get_auth_provider(user.cptr()))
}

actual fun realm_user_get_access_token(user: RealmUserPointer): String {
return realmc.realm_user_get_access_token(user.cptr())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package io.realm.kotlin.internal.interop.sync
import io.realm.kotlin.internal.interop.CodeDescription
import io.realm.kotlin.internal.interop.realm_sync_errno_connection_e
import io.realm.kotlin.internal.interop.realm_sync_errno_session_e
import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e
import io.realm.kotlin.internal.interop.realm_web_socket_errno_e

actual enum class SyncConnectionErrorCode(
Expand Down Expand Up @@ -135,3 +136,46 @@ actual enum class WebsocketErrorCode(
}
}
}

actual enum class WebsocketCallbackResult(override val description: String, override val nativeValue: Int) : CodeDescription {

RLM_ERR_SYNC_SOCKET_SUCCESS(
"Websocket callback success",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_SUCCESS
),
RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED(
"Websocket callback aborted",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED
),
RLM_ERR_SYNC_SOCKET_RUNTIME(
"Websocket Runtime error",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_RUNTIME
),
RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY(
"Websocket out of memory ",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY
),
RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED(
"Websocket address space exhausted",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED
),
RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED(
"Websocket connection closed",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED
),
RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED(
"Websocket not supported",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED
),
RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT(
"Websocket invalid argument",
realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT
);

actual companion object {
actual fun of(nativeValue: Int): WebsocketCallbackResult? =
values().firstOrNull { value ->
value.nativeValue == nativeValue
}
}
}
2 changes: 1 addition & 1 deletion packages/cinterop/src/native/realm.def
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ headerFilter = realm.h realm/error_codes.h
// libraryPaths.macos_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/
// libraryPaths.ios_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/
linkerOpts = -lcompression -lz -framework Foundation -framework CoreFoundation -framework Security
strictEnums = realm_errno realm_error_category realm_sync_errno_client realm_sync_errno_connection realm_sync_errno_session realm_web_socket_errno
strictEnums = realm_errno realm_error_category realm_sync_errno_client realm_sync_errno_connection realm_sync_errno_session realm_web_socket_errno realm_sync_socket_callback_result
---
#include <pthread.h>
#include <time.h>
Expand Down
Loading

0 comments on commit 0accea3

Please sign in to comment.