@@ -27,6 +27,10 @@ public class JShellSessionService {
2727 private void initScheduler () {
2828 scheduler = Executors .newSingleThreadScheduledExecutor ();
2929 scheduler .scheduleAtFixedRate (() -> {
30+ jshellSessions .keySet ()
31+ .stream ()
32+ .filter (id -> jshellSessions .get (id ).isClosed ())
33+ .forEach (this ::notifyDeath );
3034 List <String > toDie = jshellSessions .keySet ()
3135 .stream ()
3236 .filter (id -> jshellSessions .get (id ).shouldDie ())
@@ -41,13 +45,12 @@ private void initScheduler() {
4145 }, config .schedulerSessionKillScanRateSeconds (), config .schedulerSessionKillScanRateSeconds (), TimeUnit .SECONDS );
4246 }
4347 void notifyDeath (String id ) {
44- JShellService shellService = jshellSessions .get (id );
48+ JShellService shellService = jshellSessions .remove (id );
4549 if (shellService == null ) return ;
4650 if (!shellService .isClosed ()) {
47- throw new IllegalStateException ("JShell Service isn't dead when it should for id " + id );
51+ LOGGER . error ("JShell Service isn't dead when it should for id {}." , id );
4852 }
4953 LOGGER .info ("Session {} died." , id );
50- jshellSessions .remove (id );
5154 }
5255
5356 public boolean hasSession (String id ) {
@@ -56,15 +59,15 @@ public boolean hasSession(String id) {
5659
5760 public JShellService session (String id , @ Nullable StartupScriptId startupScriptId ) throws DockerException {
5861 if (!hasSession (id )) {
59- return createSession (new SessionInfo (id , true , startupScriptId , config ));
62+ return createSession (new SessionInfo (id , true , startupScriptId , false , config ));
6063 }
6164 return jshellSessions .get (id );
6265 }
6366 public JShellService session (@ Nullable StartupScriptId startupScriptId ) throws DockerException {
64- return createSession (new SessionInfo (UUID .randomUUID ().toString (), false , startupScriptId , config ));
67+ return createSession (new SessionInfo (UUID .randomUUID ().toString (), false , startupScriptId , false , config ));
6568 }
6669 public JShellService oneTimeSession (@ Nullable StartupScriptId startupScriptId ) throws DockerException {
67- return createSession (new SessionInfo (UUID .randomUUID ().toString (), false , startupScriptId , config ));
70+ return createSession (new SessionInfo (UUID .randomUUID ().toString (), false , startupScriptId , true , config ));
6871 }
6972
7073 public void deleteSession (String id ) throws DockerException {
0 commit comments