Skip to content

Commit d839e1e

Browse files
committed
Remove redundant restart-compatible Redis serializer
Previously, Spring Data Redis assumed that the class loader that loaded its classes would also be able to load the application’s classes. This assumption is faulty when there are multiple class loaders involved such as when using dev tools or when Spring Data Redis is installed as a shared library in a servlet container. DATAREDIS-427 and DATAREDIS-501 removed this assumption by making the default serialiser use the bean class loader. DevTools configures this class loader to be the restart class loader which can load the application’s classes. As a result of moving to Hopper SR2 snapshots, these fixes are now available and we can remove our custom serialised. Closes gh-5760
1 parent 1b252c3 commit d839e1e

File tree

3 files changed

+0
-147
lines changed

3 files changed

+0
-147
lines changed

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import java.util.List;
2222

2323
import org.springframework.beans.factory.annotation.Autowired;
24-
import org.springframework.beans.factory.annotation.Qualifier;
2524
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
26-
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2725
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2826
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2927
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -42,7 +40,6 @@
4240
import org.springframework.context.annotation.Configuration;
4341
import org.springframework.context.event.ContextRefreshedEvent;
4442
import org.springframework.context.event.EventListener;
45-
import org.springframework.data.redis.core.RedisTemplate;
4643
import org.springframework.util.StringUtils;
4744

4845
/**
@@ -164,21 +161,6 @@ private FileSystemWatcher newFileSystemWatcher() {
164161
return watcher;
165162
}
166163

167-
@Configuration
168-
@ConditionalOnBean(name = RedisRestartConfiguration.SESSION_REDIS_TEMPLATE_BEAN_NAME)
169-
static class RedisRestartConfiguration {
170-
171-
static final String SESSION_REDIS_TEMPLATE_BEAN_NAME = "sessionRedisTemplate";
172-
173-
@Bean
174-
public RestartCompatibleRedisSerializerConfigurer restartCompatibleRedisSerializerConfigurer(
175-
@Qualifier(SESSION_REDIS_TEMPLATE_BEAN_NAME) RedisTemplate<?, ?> sessionRedisTemplate) {
176-
return new RestartCompatibleRedisSerializerConfigurer(
177-
sessionRedisTemplate);
178-
}
179-
180-
}
181-
182164
}
183165

184166
}

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RestartCompatibleRedisSerializerConfigurer.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.boot.SpringApplication;
3232
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
3333
import org.springframework.boot.autoconfigure.web.ResourceProperties;
34-
import org.springframework.boot.devtools.autoconfigure.RestartCompatibleRedisSerializerConfigurer.RestartCompatibleRedisSerializer;
3534
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
3635
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
3736
import org.springframework.boot.devtools.filewatch.ChangedFiles;
@@ -235,31 +234,6 @@ public void watchingAdditionalPaths() throws Exception {
235234
.containsKey(new File("src/test/java").getAbsoluteFile());
236235
}
237236

238-
@Test
239-
public void sessionRedisTemplateIsConfiguredWithCustomDeserializers()
240-
throws Exception {
241-
sessionRedisTemplateIsConfiguredWithCustomDeserializers(
242-
SessionRedisTemplateConfig.class);
243-
}
244-
245-
private void sessionRedisTemplateIsConfiguredWithCustomDeserializers(
246-
Object sessionConfig) throws Exception {
247-
SpringApplication application = new SpringApplication(sessionConfig,
248-
LocalDevToolsAutoConfiguration.class);
249-
application.setWebEnvironment(false);
250-
this.context = application.run();
251-
RedisTemplate<?, ?> redisTemplate = this.context.getBean("sessionRedisTemplate",
252-
RedisTemplate.class);
253-
assertThat(redisTemplate.getHashKeySerializer())
254-
.isInstanceOf(RestartCompatibleRedisSerializer.class);
255-
assertThat(redisTemplate.getHashValueSerializer())
256-
.isInstanceOf(RestartCompatibleRedisSerializer.class);
257-
assertThat(redisTemplate.getKeySerializer())
258-
.isInstanceOf(RestartCompatibleRedisSerializer.class);
259-
assertThat(redisTemplate.getValueSerializer())
260-
.isInstanceOf(RestartCompatibleRedisSerializer.class);
261-
}
262-
263237
private ConfigurableApplicationContext initializeAndRun(Class<?> config,
264238
String... args) {
265239
return initializeAndRun(config, Collections.<String, Object>emptyMap(), args);

0 commit comments

Comments
 (0)