jaykataria1111 commented on issue #3198:
URL:
https://github.com/apache/logging-log4j2/issues/3198#issuecomment-2480966660
Hi @ppkarwasz,
It seems like overriding the current implementation of `SystemClock` break
compatibility:
```
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.logging.log4j.core.util;
import java.time.Instant;
import org.apache.logging.log4j.core.time.MutableInstant;
import org.apache.logging.log4j.core.time.PreciseClock;
/**
* Implementation of the {@code Clock} interface that returns the system
time.
* @since 2.11
*/
public final class SystemClock implements Clock, PreciseClock {
/**
* Returns the system time.
* @return the result of calling {@code System.currentTimeMillis()}
*/
@Override
public long currentTimeMillis() {
return System.currentTimeMillis();
}
/**
* {@inheritDoc}
*/
@Override
public void init(final MutableInstant mutableInstant) {
final Instant instant = java.time.Clock.systemUTC().instant();
mutableInstant.initFromEpochSecond(instant.getEpochSecond(),
instant.getNano());
}
}
```
```
[ERROR] Failed to execute goal
biz.aQute.bnd:bnd-baseline-maven-plugin:7.0.0:baseline (check-api-compat) on
project log4j-core: An error occurred while calculating the baseline: Baseline
problems detected. See the report in
/Users/jay/workplace/log4j2/logging-log4j2/log4j-core/target/baseline/log4j-core-2.25.0-SNAPSHOT.txt.
[ERROR] ===============================================================
[ERROR] Name Type
Delta New Old Suggest
[ERROR] org.apache.logging.log4j.core BUNDLE
MAJOR 2.25.0.SNAPSHOT 2.24.1 -
[ERROR] ===============================================================
...
...
[ERROR] MINOR CLASS
org.apache.logging.log4j.core.util.SystemClock
[ERROR] ADDED IMPLEMENTS
org.apache.logging.log4j.core.time.PreciseClock
[ERROR] ADDED METHOD
init(org.apache.logging.log4j.core.time.MutableInstant)
[ERROR] ADDED RETURN void
```
I wonder why, The interesting part is in the context it shows that it is a
`MINOR` , but at the bundle level, it shows `MAJOR`, I did some research, and
realized that adding an interface, does not break the binary or the source
compatibility. I did some looking around and saw maybe code relying on runtime
reflection to inspect the class's interfaces may behave differently. But would
you know if people are consuming the Clock interface or PreciseClock interface
in such a way? Also what are the other scenarios it could break MAJOR
compatibility? would you know, it would be a great learning opportunity for me!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]