Skip to content

Commit a8104c7

Browse files
committed
Changed exception when there are too many alive sessions, now throws a http code 429
1 parent a6ab506 commit a8104c7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

JShellAPI/src/main/java/org/togetherjava/jshellapi/service/JShellSessionService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package org.togetherjava.jshellapi.service;
22

33
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.http.HttpStatus;
45
import org.springframework.stereotype.Service;
6+
import org.springframework.web.server.ResponseStatusException;
57
import org.togetherjava.jshellapi.Config;
68
import org.togetherjava.jshellapi.exceptions.DockerException;
79

@@ -64,7 +66,7 @@ private synchronized JShellService createSession(String id, long sessionTimeout,
6466
return jshellSessions.get(id);
6567
}
6668
if(jshellSessions.size() >= config.maxAliveSessions()) {
67-
throw new DockerException("Too many sessions.");
69+
throw new ResponseStatusException(HttpStatus.TOO_MANY_REQUESTS, "Too many sessions, try again later :(.");
6870
}
6971
JShellService service = new JShellService(this, id, sessionTimeout, renewable, evalTimeout);
7072
jshellSessions.put(id, service);

0 commit comments

Comments
 (0)