Skip to content

Commit

Permalink
Fix lost updates in Java example.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 9081b015baed288ee7a901c89d4bdf4933aaf6d8
  • Loading branch information
levlam committed Jul 31, 2018
1 parent 986962b commit 6999ec4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion example/java/td_jni.cpp
Expand Up @@ -42,10 +42,13 @@ static jint Client_nativeClientReceive(JNIEnv *env, jclass clazz, jlong client_i
jdouble timeout) {
auto client = get_client(client_id);
jsize events_size = env->GetArrayLength(ids); // ids and events size must be of equal size
if (events_size == 0) {
return 0;
}
jsize result_size = 0;

auto response = client->receive(timeout);
while (response.object && result_size < events_size) {
while (response.object) {
jlong result_id = static_cast<jlong>(response.id);
env->SetLongArrayRegion(ids, result_size, 1, &result_id);

Expand All @@ -55,6 +58,10 @@ static jint Client_nativeClientReceive(JNIEnv *env, jclass clazz, jlong client_i
env->DeleteLocalRef(object);

result_size++;
if (result_size == events_size) {
break;
}

response = client->receive(0);
}
return result_size;
Expand Down

0 comments on commit 6999ec4

Please sign in to comment.