Skip to content

Commit

Permalink
[fix]byte buffer refer error (#31631)
Browse files Browse the repository at this point in the history
Fix and reopen java tests closed in #31375

Co-authored-by: Marcus Zhang <zxl265370@antgroup.com>
  • Loading branch information
2 people authored and AmeerHajAli committed Jan 12, 2023
1 parent ee07818 commit c86f2f8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public UniqueId getCurrentWorkerId() {

@Override
public JobId getCurrentJobId() {
return JobId.fromByteBuffer(nativeGetCurrentJobId());
return JobId.fromBytes(nativeGetCurrentJobId());
}

@Override
Expand Down Expand Up @@ -62,7 +62,7 @@ public RuntimeEnv getCurrentRuntimeEnv() {

private static native ByteBuffer nativeGetCurrentTaskId();

private static native ByteBuffer nativeGetCurrentJobId();
private static native byte[] nativeGetCurrentJobId();

private static native ByteBuffer nativeGetCurrentWorkerId();

Expand Down
2 changes: 0 additions & 2 deletions java/test/src/main/java/io/ray/test/RayJavaLoggingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public boolean log() {
}
}

// TODO(MisterLin1995 ): Fix JobConfig related Java test.
@Test(enabled = false)
public void testJavaLoggingRotate() {
ActorHandle<HeavyLoggingActor> loggingActor =
Ray.actor(HeavyLoggingActor::new)
Expand Down
4 changes: 0 additions & 4 deletions java/test/src/main/java/io/ray/test/RuntimeContextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public void setUp() {
System.setProperty("ray.job.id", JOB_ID.toString());
}

// TODO(MisterLin1995 ): Fix JobConfig related Java test.
@Test(enabled = false)
public void testRuntimeContextInDriver() {
Assert.assertEquals(JOB_ID, Ray.getRuntimeContext().getCurrentJobId());
Assert.assertNotEquals(Ray.getRuntimeContext().getCurrentTaskId(), TaskId.NIL);
Expand All @@ -60,8 +58,6 @@ public String testRuntimeContext(ActorId actorId) {
}
}

// TODO(MisterLin1995 ): Fix JobConfig related Java test.
@Test(enabled = false)
public void testRuntimeContextInActor() {
ActorHandle<RuntimeContextTester> actor = Ray.actor(RuntimeContextTester::new).remote();
Assert.assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ Java_io_ray_runtime_context_NativeWorkerContext_nativeGetCurrentTaskId(JNIEnv *e
return IdToJavaByteBuffer<TaskID>(env, task_id);
}

JNIEXPORT jobject JNICALL
JNIEXPORT jbyteArray JNICALL
Java_io_ray_runtime_context_NativeWorkerContext_nativeGetCurrentJobId(JNIEnv *env,
jclass) {
const auto job_id =
CoreWorkerProcess::GetCoreWorker().GetWorkerContext().GetCurrentJobID();
return IdToJavaByteBuffer<JobID>(env, job_id);
return IdToJavaByteArray<JobID>(env, job_id);
}

JNIEXPORT jobject JNICALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Java_io_ray_runtime_context_NativeWorkerContext_nativeGetCurrentTaskId(JNIEnv *,
/*
* Class: io_ray_runtime_context_NativeWorkerContext
* Method: nativeGetCurrentJobId
* Signature: ()Ljava/nio/ByteBuffer;
* Signature: ()[B
*/
JNIEXPORT jobject JNICALL
JNIEXPORT jbyteArray JNICALL
Java_io_ray_runtime_context_NativeWorkerContext_nativeGetCurrentJobId(JNIEnv *, jclass);

/*
Expand Down

0 comments on commit c86f2f8

Please sign in to comment.