You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Angela Schreiber (Jira)" <ji...@apache.org> on 2021/02/04 11:02:00 UTC
[jira] [Commented] (OAK-9344) JcrLastModifiedConflictHandler prone
to NPE
[ https://issues.apache.org/jira/browse/OAK-9344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17278766#comment-17278766 ]
Angela Schreiber commented on OAK-9344:
---------------------------------------
[~mreutegg], proposed fix attached. i would appreciate if you could review it. in particular the change that returns {{Resolution.IGNORED}} if the the conflict could not be merged due to null values as NodeBuilder.setProperty mandates the value to be notnull).
> JcrLastModifiedConflictHandler prone to NPE
> -------------------------------------------
>
> Key: OAK-9344
> URL: https://issues.apache.org/jira/browse/OAK-9344
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: core
> Reporter: Angela Schreiber
> Priority: Major
> Attachments: OAK-9344.patch
>
>
> [~mreutegg], while working on OAK-9343 i noticed that {{JcrLastModifiedConflictHandler}} is prone to NPE as {{ISO8601.parse}} may return null. the return values however are passed to the 'pick' method which doesn't handle a potential null value... a similar problem was spotted with {{ExternalIdentityConflictHandler}} (see also OAK-8700).
> {code}
> private static void merge(@NotNull NodeBuilder parent, @NotNull PropertyState ours, @NotNull PropertyState theirs) {
> Calendar o = parse(ours.getValue(Type.DATE));
> Calendar t = parse(theirs.getValue(Type.DATE));
> if (JCR_CREATED.equals(ours.getName())) {
> parent.setProperty(ours.getName(), pick(o, t, true));
> } else {
> parent.setProperty(ours.getName(), pick(o, t, false));
> }
> }
> private static Calendar pick(Calendar a, Calendar b, boolean jcrCreated) {
> if (a.before(b)) {
> return jcrCreated ? a : b;
> } else {
> return jcrCreated ? b : a;
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)