Skip to content

[maven-4.0.x] MonotonicClock.withZone() ignores zone parameter, violating Clock contract #12608

Description

@elharo

MonotonicClock.withZone() ignores zone parameter, violating Clock contract

Found in: maven-4.0.x branch
File: api/maven-api-core/src/main/java/org/apache/maven/api/MonotonicClock.java (lines 147-150)
Severity: Low

Description

withZone() ignores the zone parameter and returns this, violating the java.time.Clock.withZone() contract:

@Override
public Clock withZone(ZoneId zone) {
    return this;    // ignores the zone parameter
}

The Clock.withZone() contract states: "Returns a copy of this clock with a different time-zone. The returned clock is functionally equivalent to this clock but with the specified time-zone." Ignoring the parameter and returning this means callers that pass a specific timezone expecting a clock in that zone will silently get UTC instead, leading to subtle timezone bugs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:minorMinor loss of function, or other problem where easy workaround is present

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions