From 3207fac88e040a18f6fd5c8fcc0f37bde1a01183 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 28 Jul 2014 13:31:26 -0700 Subject: [PATCH] Use correct exception message when throw exception from native code Motivation: We sometimes not use the correct exception message when throw it from the native code. Modifications: Fixed the message. Result: Correct message in exception --- .../src/main/c/io_netty_channel_epoll_Native.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c b/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c index a9ecea777d..d6ed88d701 100644 --- a/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c +++ b/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c @@ -424,7 +424,7 @@ JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_eventFd(JNIEnv * env, if (eventFD < 0) { int err = errno; - throwRuntimeException(env, exceptionMessage("Error creating eventFD(...): ", err)); + throwRuntimeException(env, exceptionMessage("Error calling eventfd(...): ", err)); } return eventFD; } @@ -457,7 +457,12 @@ JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_epollCreate(JNIEnv * e } if (efd < 0) { int err = errno; - throwRuntimeException(env, exceptionMessage("Error during epoll_create(...): ", err)); + if (epoll_create1) { + throwRuntimeException(env, exceptionMessage("Error during epoll_create1(...): ", err)); + } else { + throwRuntimeException(env, exceptionMessage("Error during epoll_create(...): ", err)); + } + return efd; } if (!epoll_create1) { if (fcntl(efd, F_SETFD, FD_CLOEXEC) < 0) { @@ -954,7 +959,7 @@ JNIEXPORT jlong JNICALL Java_io_netty_channel_epoll_Native_sendfile(JNIEnv *env, if (err == EAGAIN) { return 0; } - throwIOException(env, exceptionMessage("Error during accept(...): ", err)); + throwIOException(env, exceptionMessage("Error during sendfile(...): ", err)); return -1; } if (res > 0) {