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

Update to latest core #7837

Merged
merged 11 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## 10.16.2 (YYYY-MM-DD)

### Breaking Changes
* None.

### Enhancements
* None.

### Fixed
* Rare corruption causing 'Invalid streaming format cookie'-exception. Typically following compact, convert or copying to a new file. (Issue [#7775](https://github.com/realm/realm-java/issues/7775), since v10.13.0 (Core v12.12.0))
* [RealmApp] Crash when opening a Realm with a proxy enabled. (Issue [#7828](https://github.com/realm/realm-java/issues/7828))

### Compatibility
* File format: Generates Realms with format v23. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.
* APIs are backwards compatible with all previous release of realm-java in the 10.6.y series.
* Realm Studio 13.0.0 or above is required to open Realms created by this version.
* Gradle 7.5 and above.
* Android Gradle Plugin 7.4.0 and above.

### Internal
* Updated to Realm Core 13.17.1, commit fb5bdccba1daad0bd6e65757a6a1596dc98cebf4.


## 10.16.1 (2023-06-26)

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct ChangeCallback {

// The local ref of jstring needs to be released to avoid reach the local ref table size limitation.
std::vector<JavaGlobalRefByMove> field_names;
auto table = m_wrapper->m_object.obj().get_table();
auto table = m_wrapper->m_object.get_obj().get_table();
for (const auto& col: change_set.columns) {
if (col.second.empty()) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ JNIEXPORT jlong JNICALL Java_io_realm_internal_objectstore_OsAppCredentials_nati
}
case io_realm_internal_objectstore_OsAppCredentials_TYPE_API_KEY: {
JStringAccessor token(env, (jstring) env->GetObjectArrayElement(j_args, 0));
creds = AppCredentials::user_api_key(token);
break;
}
case io_realm_internal_objectstore_OsAppCredentials_TYPE_SERVER_API_KEY: {
JStringAccessor token(env, (jstring) env->GetObjectArrayElement(j_args, 0));
creds = AppCredentials::server_api_key(token);
creds = AppCredentials::api_key(token);
break;
}
case io_realm_internal_objectstore_OsAppCredentials_TYPE_CUSTOM_FUNCTION: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ JNIEXPORT jlong JNICALL Java_io_realm_internal_objectstore_OsObjectBuilder_nativ
auto list = *reinterpret_cast<OsObjectData*>(builder_ptr);
JavaValue values = JavaValue(list);
Object obj = Object::create(ctx, shared_realm, object_schema, values, policy);
return reinterpret_cast<jlong>(new Obj(obj.obj()));
return reinterpret_cast<jlong>(new Obj(obj.get_obj()));
}
CATCH_STD()
return realm::npos;
Expand All @@ -249,7 +249,7 @@ JNIEXPORT jlong JNICALL Java_io_realm_internal_objectstore_OsObjectBuilder_nativ
auto list = *reinterpret_cast<OsObjectData*>(builder_ptr);
JavaValue values = JavaValue(list);
Object obj = Object::create(ctx, shared_realm, object_schema, values, policy, embedded_object_key);
return reinterpret_cast<jlong>(new Obj(obj.obj()));
return reinterpret_cast<jlong>(new Obj(obj.get_obj()));
}
CATCH_STD()
return realm::npos;
Expand Down
2 changes: 1 addition & 1 deletion realm/realm-library/src/main/cpp/java_object_accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ inline Obj JavaContext::unbox(JavaValue const& v, CreatePolicy policy, ObjKey cu
return Obj();
}
REALM_ASSERT(object_schema);
return Object::create(const_cast<JavaContext&>(*this), realm, *object_schema, v, policy, current_row).obj();
return Object::create(const_cast<JavaContext&>(*this), realm, *object_schema, v, policy, current_row).get_obj();
}

template <>
Expand Down
2 changes: 1 addition & 1 deletion realm/realm-library/src/main/cpp/realm-core
Submodule realm-core updated 176 files
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,17 @@ private OsRealmConfig(final RealmConfiguration config,
SocketAddress address = proxy.address();
if (address instanceof InetSocketAddress) {
InetSocketAddress inetAddress = (InetSocketAddress) address;

nativeSetSyncConfigProxySettings(
nativePtr,
proxyType,
getHostString(inetAddress),
inetAddress.getPort()
);
String hostname = getHostString(inetAddress);
if (hostname != null) {
nativeSetSyncConfigProxySettings(
nativePtr,
proxyType,
hostname,
inetAddress.getPort()
);
} else {
RealmLog.error("Could not retrieve proxy's hostname.");
}
} else {
RealmLog.error("Unsupported proxy socket address type: " + address.getClass().getName());
}
Expand All @@ -378,15 +382,26 @@ private OsRealmConfig(final RealmConfiguration config,
this.resolvedRealmURI = resolvedRealmURI;
}

// Backport the behavior from InetSocketAddress.getHostString, a function that is only available
// on SDK>=19 (KITKAT)
/**
* Backport the behavior from <a href="https://github.com/openjdk-mirror/jdk7u-jdk/blob/f4d80957e89a19a29bb9f9807d2a28351ed7f7df/src/share/classes/java/net/InetSocketAddress.java#L242">InetSocketAddress.getHostString</a>, a function that is only available
* from SDK 19 (KITKAT)
*
* @param socketAddress address to extract the hostname from.
* @return hostname or the String form of the address.
*/
private String getHostString(InetSocketAddress socketAddress) {
InetAddress address = socketAddress.getAddress();
if (socketAddress.getHostName() != null) {
return socketAddress.getHostName();
}
if (socketAddress.getAddress() != null) {
InetAddress address = socketAddress.getAddress();

if (address.getHostName() != null)
return address.getHostName();
else
return address.getHostAddress();
if (address.getHostName() != null) {
return address.getHostName();
} else
return address.getHostAddress();
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ public class OsAppCredentials implements NativeObject {

private static final int TYPE_ANONYMOUS = 1;
private static final int TYPE_API_KEY = 2;
private static final int TYPE_SERVER_API_KEY = 3;
private static final int TYPE_APPLE = 4;
private static final int TYPE_CUSTOM_FUNCTION = 5;
private static final int TYPE_EMAIL_PASSWORD = 6;
private static final int TYPE_FACEBOOK = 7;
private static final int TYPE_JWT = 8;
private static final int TYPE_GOOGLE_AUTH_CODE = 9;
private static final int TYPE_GOOGLE_ID_TOKEN = 10;
private static final int TYPE_APPLE = 3;
private static final int TYPE_CUSTOM_FUNCTION = 4;
private static final int TYPE_EMAIL_PASSWORD = 5;
private static final int TYPE_FACEBOOK = 6;
private static final int TYPE_JWT = 7;
private static final int TYPE_GOOGLE_AUTH_CODE = 8;
private static final int TYPE_GOOGLE_ID_TOKEN = 9;

private static final long finalizerPtr = nativeGetFinalizerMethodPtr();

Expand All @@ -51,10 +50,6 @@ public static OsAppCredentials apiKey(String key) {
return new OsAppCredentials(nativeCreate(TYPE_API_KEY, key));
}

public static OsAppCredentials serverApiKey(String key) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't really used and not exposed in the SDK. Removed from core in realm/realm-core#5914

return new OsAppCredentials(nativeCreate(TYPE_SERVER_API_KEY, key));
}

public static OsAppCredentials apple(String idToken) {
return new OsAppCredentials(nativeCreate(TYPE_APPLE, idToken));
}
Expand Down
Loading