Version comparisons are incorrectly implemented

Description

Errors occur in the class “JDBCStorageService”. At several places “returnedVersion != version” is used.

returnedVersion and version are of type “Long”. Unfortunately, the comparison behaves differently up to 127L than from 128L:

        Long version = 127L;
        Long returnedVersion = 127L;
        System.out.println(version != returnedVersion); //false
        System.out.println(version.longValue() != returnedVersion.longValue()); //false
        System.out.println(!version.equals(version)); //false

        version = 128L;
        returnedVersion = 128L;
        System.out.println(version != returnedVersion); //TRUE !
        System.out.println(version.longValue() != returnedVersion.longValue()); //false
        System.out.println(!version.equals(returnedVersion)); //false

        version = 129L;
        returnedVersion = 129L;
        System.out.println(version != returnedVersion); //TRUE !
        System.out.println(version.longValue() != returnedVersion.longValue()); //false
        System.out.println(!version.equals(returnedVersion)); //false

I would fix the errors with the longValue() addition.

The class also contains the “verion” type twice.

In "log.trace("Considering Version '{}', Expires '{}', Value '{}'", returnedVersion, returnedValue, returnedExpires);" returnedValue and returnedExpires are swapped.

Environment

None

Activity

Steffen HofmannSeptember 6, 2024 at 9:22 AM

Commit message says “JJDBC-28 Release JDBC Plugin 3.0.1”, but it is version 2.0.1

Rod WiddowsonSeptember 6, 2024 at 9:06 AM

Fixed

Scott CantorSeptember 3, 2024 at 1:42 PM

I’d only be concerned if it were somewhere other than the session cache, but yeah, I imagine mail would do it. Most places now use M365 for mail and can't use Shibboleth with it.

Steffen HofmannSeptember 3, 2024 at 1:31 PM

We also noticed it first in the monitoring. The checks run frequently. However, we also have some users who use Webmail and Wiki and reach the high version number very quickly. I'm looking at that right now, but it's not this problem.

Scott CantorSeptember 3, 2024 at 12:43 PM

I’m guessing that this hasn’t been noted simply because it’s pretty rare in general for recorfs to increment version that many times. We don’t actually use that feature too much outside the session cache if I had to guess.

I can see how some other use cases might be impacted though.

Fixed

Details

Affects versions

Fix versions

Assignee

Reporter

Created September 3, 2024 at 11:22 AM
Updated September 9, 2024 at 1:37 PM
Resolved September 6, 2024 at 9:06 AM