Skip to content

Commit

Permalink
Interpreting zero timeout value as "infinite" (actually, max long)
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed May 31, 2018
1 parent 2c3aab2 commit bfd4dcc
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -75,10 +76,10 @@ public void init() {
configureLogging();
log("Initialising WebDriverServlet");

String value = getServletContext().getInitParameter(SESSION_TIMEOUT_PARAMETER);
long inactiveSessionTimeout = value != null ?
SECONDS.toMillis(Long.parseLong(value)) :
Long.MAX_VALUE;
long inactiveSessionTimeout = Optional.ofNullable(getServletContext().getInitParameter(SESSION_TIMEOUT_PARAMETER))
.map(value -> SECONDS.toMillis(Long.parseLong(value)))
.filter(value -> value > 0)
.orElse(Long.MAX_VALUE);

allSessions = (ActiveSessions) getServletContext().getAttribute(ACTIVE_SESSIONS_KEY);
if (allSessions == null) {
Expand Down

0 comments on commit bfd4dcc

Please sign in to comment.