Skip to content

Commit eeca57d

Browse files
jonsimantova-maurice
authored andcommitted
Fix passing of future handle through Java, now passes a FutureHandleId instead.
PiperOrigin-RevId: 311166882
1 parent 9955165 commit eeca57d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

analytics/src/analytics_android.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,22 +402,23 @@ Future<std::string> GetAnalyticsInstanceId() {
402402
if (future_data) {
403403
bool success =
404404
result_code == util::kFutureResultSuccess && result != nullptr;
405+
FutureHandleId future_id =
406+
reinterpret_cast<FutureHandleId>(callback_data);
407+
FutureHandle handle(future_id);
405408
future_data->api()->CompleteWithResult(
406-
SafeFutureHandle<std::string>(
407-
*(reinterpret_cast<FutureHandle*>(&callback_data))),
408-
success ? 0 : -1,
409+
handle, success ? 0 : -1,
409410
success ? ""
410411
: status_message ? status_message
411412
: "Unknown error occurred",
412-
// Both JStringToString and GetMessageFromException are able to
413-
// handle a nullptr being passed in, and neither deletes the
414-
// object passed in (so delete it below).
413+
// Both JStringToString and GetMessageFromException are
414+
// able to handle a nullptr being passed in, and neither
415+
// deletes the object passed in (so delete it below).
415416
success ? util::JStringToString(env, result)
416417
: util::GetMessageFromException(env, result));
417418
}
418419
if (result) env->DeleteLocalRef(result);
419420
},
420-
*(reinterpret_cast<void* const*>(&future_handle)),
421+
reinterpret_cast<void*>(safe_future_handle.get().id()),
421422
internal::kAnalyticsModuleName);
422423
env->DeleteLocalRef(task);
423424
} else {

0 commit comments

Comments
 (0)