Skip to content

Commit 21d07ad

Browse files
author
jjuzna
committed
Added stop() method to java object.
It breaks the internal indefinite loop and allows Node process to quit without SIGTERM. Solves bug joeferner#539 - The process refuses to quit.
1 parent ce4f251 commit 21d07ad

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/java.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void uvAsyncCb_dynamicProxyJsCall(uv_async_t *handle) {
106106
Nan::SetPrototypeMethod(t, "getStaticFieldValue", getStaticFieldValue);
107107
Nan::SetPrototypeMethod(t, "setStaticFieldValue", setStaticFieldValue);
108108
Nan::SetPrototypeMethod(t, "instanceOf", instanceOf);
109+
Nan::SetPrototypeMethod(t, "stop", stop);
109110

110111
Nan::Set(target, Nan::New<v8::String>("Java").ToLocalChecked(), Nan::GetFunction(t).ToLocalChecked());
111112

@@ -1239,6 +1240,10 @@ NAN_METHOD(Java::instanceOf) {
12391240
info.GetReturnValue().Set(Nan::New<v8::Boolean>(res));
12401241
}
12411242

1243+
NAN_METHOD(Java::stop) {
1244+
uv_close((uv_handle_t *)&uvAsync_dynamicProxyJsCall, NULL);
1245+
}
1246+
12421247
template <typename T>
12431248
std::string to_string(T value) {
12441249
std::ostringstream os;

src/java.h

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Java : public Nan::ObjectWrap {
5656
static NAN_METHOD(getStaticFieldValue);
5757
static NAN_METHOD(setStaticFieldValue);
5858
static NAN_METHOD(instanceOf);
59+
static NAN_METHOD(stop);
5960
static NAN_GETTER(AccessorProhibitsOverwritingGetter);
6061
static NAN_SETTER(AccessorProhibitsOverwritingSetter);
6162
v8::Local<v8::Value> ensureJvm();

0 commit comments

Comments
 (0)