Permalink
Browse files
Merge pull request #12222 from pferraro/web
WFLY-11975 Distributed web session metadata payload contains unnecessary nanosecond precision
- Loading branch information
|
|
@@ -30,7 +30,6 @@ |
|
|
|
|
|
import org.kohsuke.MetaInfServices; |
|
|
import org.wildfly.clustering.marshalling.Externalizer; |
|
|
import org.wildfly.clustering.marshalling.spi.DefaultExternalizer; |
|
|
import org.wildfly.clustering.marshalling.spi.IndexSerializer; |
|
|
|
|
|
/** |
|
|
@@ -43,13 +42,14 @@ |
|
|
@Override |
|
|
public void writeObject(ObjectOutput output, SessionCreationMetaDataEntry<Object> entry) throws IOException { |
|
|
SessionCreationMetaData metaData = entry.getMetaData(); |
|
|
DefaultExternalizer.INSTANT.cast(Instant.class).writeObject(output, metaData.getCreationTime()); |
|
|
// We only need millisecond precision |
|
|
output.writeLong(metaData.getCreationTime().toEpochMilli()); |
|
|
IndexSerializer.VARIABLE.writeInt(output, (int) metaData.getMaxInactiveInterval().getSeconds()); |
|
|
} |
|
|
|
|
|
@Override |
|
|
public SessionCreationMetaDataEntry<Object> readObject(ObjectInput input) throws IOException, ClassNotFoundException { |
|
|
SessionCreationMetaData metaData = new SimpleSessionCreationMetaData(DefaultExternalizer.INSTANT.cast(Instant.class).readObject(input)); |
|
|
SessionCreationMetaData metaData = new SimpleSessionCreationMetaData(Instant.ofEpochMilli(input.readLong())); |
|
|
metaData.setMaxInactiveInterval(Duration.ofSeconds(IndexSerializer.VARIABLE.readInt(input))); |
|
|
return new SessionCreationMetaDataEntry<>(metaData); |
|
|
} |
|
|
|
|
|
@@ -46,7 +46,8 @@ public void test() throws ClassNotFoundException, IOException { |
|
|
} |
|
|
|
|
|
static void assertEquals(SessionCreationMetaDataEntry<Object> entry1, SessionCreationMetaDataEntry<Object> entry2) { |
|
|
Assert.assertEquals(entry1.getMetaData().getCreationTime(), entry2.getMetaData().getCreationTime()); |
|
|
// Compare only to millisecond precision |
|
|
Assert.assertEquals(entry1.getMetaData().getCreationTime().toEpochMilli(), entry2.getMetaData().getCreationTime().toEpochMilli()); |
|
|
Assert.assertEquals(entry1.getMetaData().getMaxInactiveInterval(), entry2.getMetaData().getMaxInactiveInterval()); |
|
|
} |
|
|
} |