refactor: remove legacy session store enum

This commit is contained in:
lingniu
2026-07-01 10:35:12 +08:00
parent 87830fee09
commit e2b6ab63d6
2 changed files with 14 additions and 10 deletions

View File

@@ -3,23 +3,25 @@ package com.lingniu.ingest.session;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.time.Duration;
import java.util.Locale;
@ConfigurationProperties(prefix = "lingniu.ingest.session")
public class SessionProperties {
private Store store = Store.REDIS;
private String store = "redis";
private Duration ttl = Duration.ofMinutes(30);
public Store getStore() {
public String getStore() {
return store;
}
public void setStore(Store store) {
if (store == Store.MEMORY) {
throw new IllegalStateException("session.store supports only redis; configured value: memory");
public void setStore(String store) {
String value = store == null || store.isBlank() ? "redis" : store.trim().toLowerCase(Locale.ROOT);
if (!"redis".equals(value)) {
throw new IllegalStateException("session.store supports only redis; configured value: " + store);
}
this.store = store;
this.store = value;
}
public Duration getTtl() {
@@ -30,8 +32,4 @@ public class SessionProperties {
this.ttl = ttl;
}
public enum Store {
MEMORY,
REDIS
}
}

View File

@@ -61,4 +61,10 @@ class SessionCoreAutoConfigurationTest {
.hasStackTraceContaining("session.store supports only redis")
.hasStackTraceContaining("memory"));
}
@Test
void sessionPropertiesDoNotExposeLegacyStoreEnum() {
assertThatThrownBy(() -> Class.forName("com.lingniu.ingest.session.SessionProperties$Store"))
.isInstanceOf(ClassNotFoundException.class);
}
}