Skip to content

Commit

Permalink
Capped the infinite session expire interval to 100 years (as seconds …
Browse files Browse the repository at this point in the history
…instead of UINT max value)
  • Loading branch information
andsel committed Mar 3, 2023
1 parent 69ae603 commit 8fa896f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion broker/src/main/java/io/moquette/broker/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
import org.slf4j.LoggerFactory;

import java.net.InetSocketAddress;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -46,7 +49,9 @@
class Session {

private static final Logger LOG = LoggerFactory.getLogger(Session.class);
static final int INFINITE_EXPIRY = 0xFFFFFFFF;
// By specification session expiry value of 0xFFFFFFFF (UINT_MAX) (seconds) means
// session that doesn't expire, it's ~136 years, we can set a cap at 100 year
static final int INFINITE_EXPIRY = (int) Duration.of(100, ChronoUnit.YEARS).toMillis() / 1000;

static class InFlightPacket implements Delayed {

Expand Down

0 comments on commit 8fa896f

Please sign in to comment.