From 203b6f2f2c8c51cc41d2a44cef5f28a86fb456b4 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 23 Nov 2016 16:04:36 +0100 Subject: [PATCH 1/2] Fix undertow session persistence with spring-boot-devtools Fixes gh-7460 --- .../embedded/undertow/FileSessionPersistence.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java index acd4ee4225..e8a6007e3b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java @@ -30,6 +30,8 @@ import java.util.Map; import io.undertow.servlet.UndertowServletLogger; import io.undertow.servlet.api.SessionPersistenceManager; +import org.springframework.core.ConfigurableObjectInputStream; + /** * {@link SessionPersistenceManager} that stores session information in a file. * @@ -82,7 +84,7 @@ public class FileSessionPersistence implements SessionPersistenceManager { try { File file = getSessionFile(deploymentName); if (file.exists()) { - return load(file); + return load(file, classLoader); } } catch (Exception ex) { @@ -91,9 +93,10 @@ public class FileSessionPersistence implements SessionPersistenceManager { return null; } - private Map load(File file) + private Map load(File file, ClassLoader classLoader) throws IOException, ClassNotFoundException { - ObjectInputStream stream = new ObjectInputStream(new FileInputStream(file)); + ObjectInputStream stream = new ConfigurableObjectInputStream( + new FileInputStream(file), classLoader); try { return load(stream); } From 4c61c9f26ad49472a9d434c22f4a24b3225d6aa9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 24 Nov 2016 16:07:03 +0100 Subject: [PATCH 2/2] Polish contribution Closes gh-7462 --- .../boot/context/embedded/undertow/FileSessionPersistence.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java index e8a6007e3b..afd16c98bb 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/FileSessionPersistence.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.core.ConfigurableObjectInputStream; * {@link SessionPersistenceManager} that stores session information in a file. * * @author Phillip Webb + * @author Peter Leibiger * @since 1.3.0 */ public class FileSessionPersistence implements SessionPersistenceManager {