From 80177e87126b60789ee5931d6d87e5d18bc14e98 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Mon, 7 Aug 2017 16:29:41 +0200 Subject: [PATCH] KEYCLOAK-4187 Include version when marshalling UserSessionEntity --- .../infinispan/entities/UserSessionEntity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/entities/UserSessionEntity.java b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/entities/UserSessionEntity.java index 394fbd8aae..d57c64918d 100755 --- a/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/entities/UserSessionEntity.java +++ b/model/infinispan/src/main/java/org/keycloak/models/sessions/infinispan/entities/UserSessionEntity.java @@ -194,8 +194,12 @@ public class UserSessionEntity extends SessionEntity { public static class ExternalizerImpl implements Externalizer { + private static final int VERSION_1 = 1; + @Override public void writeObject(ObjectOutput output, UserSessionEntity session) throws IOException { + output.writeByte(VERSION_1); + MarshallUtil.marshallString(session.getAuthMethod(), output); MarshallUtil.marshallString(session.getBrokerSessionId(), output); MarshallUtil.marshallString(session.getBrokerUserId(), output); @@ -223,6 +227,15 @@ public class UserSessionEntity extends SessionEntity { @Override public UserSessionEntity readObject(ObjectInput input) throws IOException, ClassNotFoundException { + switch (input.readByte()) { + case VERSION_1: + return readObjectVersion1(input); + default: + throw new IOException("Unknown version"); + } + } + + public UserSessionEntity readObjectVersion1(ObjectInput input) throws IOException, ClassNotFoundException { UserSessionEntity sessionEntity = new UserSessionEntity(); sessionEntity.setAuthMethod(MarshallUtil.unmarshallString(input));