Skip to content

Commit

Permalink
Merge pull request #1493 from Pandrex247/PAYARA-1542-Embedded-Payara-…
Browse files Browse the repository at this point in the history
…Micro-does-not-shut-down

PAYARA-1542 Embedded Micro doesn't shut down
  • Loading branch information
Pandrex247 authored Apr 3, 2017
2 parents de81d57 + e94591d commit 431261a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,28 @@ public void start() throws GlassFishException {

@Override
public void stop() throws GlassFishException {
if (status == Status.STOPPED || status == Status.STOPPING || status == Status.DISPOSED) {
throw new IllegalStateException("Already in " + status + " state.");
}

status = Status.STOPPING;
kernel.stop();
status = Status.STOPPED;
}

@Override
public void dispose() throws GlassFishException {
if (status == Status.DISPOSED) {
throw new IllegalStateException("Already disposed.");
} else if (status != Status.STOPPED) {
try {
stop();
} catch (Exception e) {
// ignore and continue.
e.printStackTrace();
}
}

kernel = null;
habitat = null;
status = Status.DISPOSED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,12 @@ private void addShutdownHook() {
public void run() {
try {
if (gf != null) {
gf.stop();
gf.dispose();
}
} catch (GlassFishException ex) {
} catch (IllegalStateException ex) {
// Just log at a fine level and move on
LOGGER.log(Level.FINE, "Already shut down");
}
}
});
Expand Down

0 comments on commit 431261a

Please sign in to comment.