refactor: remove legacy session store enum
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user