fix: NPE when set up server with session timeout property

This commit is contained in:
Robin Shen 2025-10-31 23:01:52 +08:00
parent 8a45bb03f7
commit cb86f2087e
4 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import static io.onedev.server.model.support.administration.SystemSetting.PROP_D
import static io.onedev.server.model.support.administration.SystemSetting.PROP_GIT_LOCATION;
import static io.onedev.server.model.support.administration.SystemSetting.PROP_SSH_ROOT_URL;
import static io.onedev.server.model.support.administration.SystemSetting.PROP_USE_AVATAR_SERVICE;
import static io.onedev.server.model.support.administration.SystemSetting.PROP_SESSION_TIMEOUT;
import static io.onedev.server.persistence.PersistenceUtils.tableExists;
import static org.unbescape.html.HtmlEscape.escapeHtml5;
@ -714,7 +715,7 @@ public class DefaultDataService implements DataService, Serializable {
}
if (systemSetting != null) {
Collection<String> excludedProps = Sets.newHashSet(PROP_SSH_ROOT_URL, PROP_DISABLE_AUTO_UPDATE_CHECK, PROP_USE_AVATAR_SERVICE);
Collection<String> excludedProps = Sets.newHashSet(PROP_SSH_ROOT_URL, PROP_DISABLE_AUTO_UPDATE_CHECK, PROP_USE_AVATAR_SERVICE, PROP_SESSION_TIMEOUT);
if (Bootstrap.isInDocker()) {
excludedProps.add(PROP_GIT_LOCATION);
excludedProps.add(PROP_CURL_LOCATION);

View File

@ -88,7 +88,8 @@ public class DefaultJettyService implements JettyService, Provider<ServletContex
servletContextHandler.getSessionHandler().setSessionIdPathParameterName(null);
servletContextHandler.getSessionHandler().setSameSite(SameSite.LAX);
servletContextHandler.getSessionHandler().setHttpOnly(true);
servletContextHandler.getSessionHandler().setMaxInactiveInterval(settingService.getSystemSetting().getSessionTimeout() * 60);
if (settingService.getSystemSetting() != null)
servletContextHandler.getSessionHandler().setMaxInactiveInterval(settingService.getSystemSetting().getSessionTimeout() * 60);
/*
* By default contributions is in reverse dependency order. We reverse the order so that

View File

@ -40,6 +40,8 @@ public class SystemSetting implements Serializable, Validatable {
public static final String PROP_CURL_LOCATION = "curlLocation";
public static final String PROP_SSH_ROOT_URL = "sshRootUrl";
public static final String PROP_SESSION_TIMEOUT = "sessionTimeout";
public static final String PROP_USE_AVATAR_SERVICE = "useAvatarService";

@ -1 +1 @@
Subproject commit fc8f4fad4f001fce72b1f6805383e0b0951dd17a
Subproject commit 28e98b3e7f1b189e3fd64bb5a1f554a51bfba64d