|
16 | 16 |
|
17 | 17 | import java.io.ByteArrayInputStream;
|
18 | 18 | import java.io.IOException;
|
19 |
| -import java.io.ObjectInputStream; |
20 | 19 | import java.nio.ByteBuffer;
|
21 | 20 | import java.util.Collections;
|
22 | 21 | import java.util.HashSet;
|
23 | 22 | import java.util.Map;
|
24 | 23 | import java.util.Set;
|
25 | 24 |
|
| 25 | +import org.apache.catalina.Container; |
26 | 26 | import org.apache.catalina.Session;
|
27 | 27 | import org.apache.catalina.session.StandardSession;
|
28 | 28 | import org.apache.catalina.session.StoreBase;
|
| 29 | +import org.apache.catalina.util.CustomObjectInputStream; |
29 | 30 |
|
30 | 31 | import com.amazonaws.services.dynamodb.sessionmanager.util.DynamoUtils;
|
31 | 32 | import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
|
@@ -113,9 +114,17 @@ public Session load(String id) throws ClassNotFoundException, IOException {
|
113 | 114 |
|
114 | 115 | ByteBuffer byteBuffer = item.get(SessionTableAttributes.SESSION_DATA_ATTRIBUTE).getB();
|
115 | 116 | ByteArrayInputStream inputStream = new ByteArrayInputStream(byteBuffer.array());
|
116 |
| - ObjectInputStream objectInputStream = new ObjectInputStream(inputStream); |
117 | 117 |
|
118 |
| - Object readObject = objectInputStream.readObject(); |
| 118 | + Object readObject; |
| 119 | + CustomObjectInputStream objectInputStream = null; |
| 120 | + try { |
| 121 | + Container webapp = getManager().getContainer(); |
| 122 | + objectInputStream = new CustomObjectInputStream(inputStream, webapp.getLoader().getClassLoader()); |
| 123 | + |
| 124 | + readObject = objectInputStream.readObject(); |
| 125 | + } finally { |
| 126 | + try { objectInputStream.close(); } catch (Exception e) {} |
| 127 | + } |
119 | 128 |
|
120 | 129 | if (readObject instanceof Map<?, ?>) {
|
121 | 130 | Map<String, Object> sessionAttributeMap = (Map<String, Object>)readObject;
|
|
0 commit comments