Skip to content

Commit

Permalink
OF-2833: Fix serialization of User when date properties are null
Browse files Browse the repository at this point in the history
Since OF-2768, various 'date'-based properties of the User class are more likely to be null (especially in context of LDAP/AD).

In this commit, a serialization issue is fixed that is triggered by these null-values.
  • Loading branch information
guusdk committed Jun 28, 2024
1 parent 1a7c4fd commit 4daaf50
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 4daaf50

Please sign in to comment.