2626import org .springframework .boot .actuate .health .HealthIndicator ;
2727import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
2828import org .springframework .boot .autoconfigure .data .redis .RedisAutoConfiguration ;
29+ import org .springframework .boot .info .BuildProperties ;
2930import org .springframework .context .annotation .Bean ;
3031import org .springframework .context .annotation .Configuration ;
3132import org .springframework .context .annotation .Import ;
@@ -49,12 +50,13 @@ public class RedisSessionConfig {
4950 private final String redisNamespace ;
5051 private final Environment environment ;
5152
52- public RedisSessionConfig (IdentifierService identifierService , Environment environment ) {
53+ public RedisSessionConfig (IdentifierService identifierService , Environment environment , BuildProperties buildProperties ) {
5354 this .environment = environment ;
55+ String version = buildProperties .getVersion ().replace ("." , "_" ).replace ("-" , "_" );
5456 if (identifierService .realmId != null ) {
55- redisNamespace = String .format ("shinyproxy__%s__%s" , identifierService .realmId , RedisIndexedSessionRepository .DEFAULT_NAMESPACE );
57+ redisNamespace = String .format ("shinyproxy__%s__%s__% s" , identifierService .realmId , version , RedisIndexedSessionRepository .DEFAULT_NAMESPACE );
5658 } else {
57- redisNamespace = String .format ("shinyproxy__%s" , RedisIndexedSessionRepository .DEFAULT_NAMESPACE );
59+ redisNamespace = String .format ("shinyproxy__%s__%s" , version , RedisIndexedSessionRepository .DEFAULT_NAMESPACE );
5860 }
5961 }
6062
@@ -106,8 +108,7 @@ class SafeRedisSessionMapper implements BiFunction<String, Map<String, Object>,
106108 public MapSession apply (String sessionId , Map <String , Object > map ) {
107109 try {
108110 return this .delegate .apply (sessionId , map );
109- }
110- catch (IllegalStateException ex ) {
111+ } catch (IllegalStateException ex ) {
111112 // do not invoke RedisIndexedSessionRepository#deleteById to avoid an infinite loop because the method also invokes this mapper
112113 redisOperations .delete (getRedisNamespace () + ":sessions:" + sessionId );
113114 return null ;
0 commit comments