From c39daf98af89ccda6997cee6b00b6a66b74ea19b Mon Sep 17 00:00:00 2001 From: Renjie Liu Date: Wed, 31 Jan 2024 09:50:42 +0800 Subject: [PATCH] Tests done --- .../src/main/java/org/apache/iceberg/common/README.md | 4 ++-- src/connector/src/sink/iceberg/jni_catalog.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/README.md b/java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/README.md index 21ae34ca3c734..e817f66e2d93e 100644 --- a/java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/README.md +++ b/java/connector-node/risingwave-sink-iceberg/src/main/java/org/apache/iceberg/common/README.md @@ -1,6 +1,6 @@ # Why we need this package? -In this package we have overrided the `iceberg-common` package, since in original `iceberg-common` it uses `Thread.getContextClassLoader` to load classes dynamically. -While this works well in most cases, it will fail when invoked by jni, since by default jni threads was passed bootstrap class loader, and `Thread.getContextClassLoader` +In this package we have override the `iceberg-common` package, since in original `iceberg-common` it uses `Thread.getContextClassLoader` to load classes dynamically. +While this works well in most cases, it will fail when invoked by jni, since by default jni threads was passed bootstrap class loader, and `Thread.getContextClassLoader` will inherit parent thread's class loader. That's to say, all threads created by jni will use bootstrap class loader. While we can use `Thread.setContextClassLoader` to it system class loader manually, but it's not possible in all cases since iceberg used thread pools internally, which can't be hooked by us. \ No newline at end of file diff --git a/src/connector/src/sink/iceberg/jni_catalog.rs b/src/connector/src/sink/iceberg/jni_catalog.rs index 814f265becedf..dac13b7c4829a 100644 --- a/src/connector/src/sink/iceberg/jni_catalog.rs +++ b/src/connector/src/sink/iceberg/jni_catalog.rs @@ -207,15 +207,20 @@ mod tests { ("s3.endpoint", "http://192.168.166.3:9301"), ("s3.path-style-access", "true"), ("s3.access-key-id", "hummockadmin"), - ("s3.secret-access-key", "hummockadmin") + ("s3.secret-access-key", "hummockadmin"), ] .into_iter() .map(|(k, v)| (k.to_string(), v.to_string())) .collect(); - let catalog = JniCatalog::build(config, "demo", "org.apache.iceberg.hive.HiveCatalog", props).unwrap(); + let catalog = + JniCatalog::build(config, "demo", "org.apache.iceberg.hive.HiveCatalog", props) + .unwrap(); - let table = catalog.load_table(&TableIdentifier::new(vec!["s1", "t1"]).unwrap()).await.unwrap(); + let table = catalog + .load_table(&TableIdentifier::new(vec!["s1", "t1"]).unwrap()) + .await + .unwrap(); println!("{:?}", table.table_name()) }