This is an automated email from the ASF dual-hosted git repository. yong pushed a commit to branch branch-4.17 in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit 22fe67ffd2e14c62e8137fc3d3f4e627bdfdc0c7 Author: fengyubiao <[email protected]> AuthorDate: Wed Oct 22 12:53:14 2025 +0800 [fix]compile error of the file native_io_jni.c for the env jdk11 & windows (#4665) Co-authored-by: fengyubiao <[email protected]> (cherry picked from commit 5154149936e3f8187ae9e2755f43ea9c0ecb866e) --- native-io/src/main/native-io-jni/cpp/native_io_jni.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/native-io/src/main/native-io-jni/cpp/native_io_jni.c b/native-io/src/main/native-io-jni/cpp/native_io_jni.c index d3bc164bec..7be468518b 100644 --- a/native-io/src/main/native-io-jni/cpp/native_io_jni.c +++ b/native-io/src/main/native-io-jni/cpp/native_io_jni.c @@ -20,11 +20,16 @@ */ #define _GNU_SOURCE +#include <jni.h> #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> +#ifdef _WIN32 +#include <io.h> +#else #include <unistd.h> +#endif #include <org_apache_bookkeeper_common_util_nativeio_NativeIOJni.h> @@ -165,7 +170,14 @@ JNIEXPORT jint JNICALL Java_org_apache_bookkeeper_common_util_nativeio_NativeIOJni_fsync(JNIEnv * env, jclass clazz, jint fd) { - int res = fsync(fd); + int res; + + // Guarantee compatibility for winsows. + #ifdef _WIN32 + res = _commit((int)fd); + #else + res = fsync((int)fd); + #endif if (res == -1) { throwExceptionWithErrno(env, "Failed to fsync");
