Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OF-2833: Fix serialization of User when date properties are null #2466

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2004-2008 Jive Software, 2017-2019 Ignite Realtime Foundation. All rights reserved.
* Copyright (C) 2004-2008 Jive Software, 2017-2024 Ignite Realtime Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -531,8 +531,10 @@ public void writeExternal(ObjectOutput out) throws IOException {
if (email != null) {
ExternalizableUtil.getInstance().writeSafeUTF(out, email);
}
ExternalizableUtil.getInstance().writeLong(out, creationDate.getTime());
ExternalizableUtil.getInstance().writeLong(out, modificationDate.getTime());

// OF-2833/OF-1768: Handle null values. Here, we represent null with a zero (instead of the customary boolean) to retain backwards compatibility with cluster nodes that assume that these values are never null.
ExternalizableUtil.getInstance().writeLong(out, creationDate == null ? 0 : creationDate.getTime());
ExternalizableUtil.getInstance().writeLong(out, modificationDate == null ? 0 : modificationDate.getTime());
}

@Override
Expand All @@ -542,8 +544,10 @@ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundExcept
if (ExternalizableUtil.getInstance().readBoolean(in)) {
email = ExternalizableUtil.getInstance().readSafeUTF(in);
}
creationDate = new Date(ExternalizableUtil.getInstance().readLong(in));
modificationDate = new Date(ExternalizableUtil.getInstance().readLong(in));
final long creation = ExternalizableUtil.getInstance().readLong(in);
creationDate = creation == 0 ? null: new Date(creation);
final long modification = ExternalizableUtil.getInstance().readLong(in);
modificationDate = modification == 0 ? null : new Date(modification);
}

/*
Expand Down
Loading