[#1011111] postmaster hangs if JVM does not close nicely in windows

View Trackers | Patches | Download .csv | Monitor

Date:
2011-11-04 12:29
Priority:
3
State:
Open
Submitted by:
Nathan Egge (negge)
Assigned to:
Nobody (None)
Category:
Group:
Summary:
postmaster hangs if JVM does not close nicely in windows

Detailed description
I came across an issue where the postmaster process was not shutting down after a client disconnected because there were resources and threads still running in the Java Virtual Machine. This only happens in Windows because in Linux the JVM is forcefully destroyed.

In order to fix this, I added a BackendListener class which can receive events about the JVM being destroyed before it happens and cleanly shutdown any resources its holding. Patch is attached.

I have tested this in Windows and Linux and works well.

Followup

Message
Date: 2011-11-09 16:57
Sender: Nathan Egge

I was asked to attach an example showing how this would work
so I will include one here:

public class Commands {

protected static MyService myService;

static {
myService=new MyService();
// start complex service, which spawns threads, locks
resources
myService.start();
// add a call back to stop the service before trying to
stop the JVM
Backend.addBackendListener(new BackendListener() {
public void onDestroyJavaVM() {
myService.stop();
}
});
}

public static void someCommand() {
myService.doSomething();
}

};

Attached Files:

Attachments:
pljava-Backend_events.patch

Changes:

Field Old Value Date By
File Added696: pljava-Backend_events.patch2011-11-04 17:45negge
Powered By FusionForge