Repository: logging-log4j2 Updated Branches: refs/heads/release-2.x 8201adf93 -> ed9c83ed0
LOG4J2-2271 - Move module-info.class to META-INF/versions/9 directory. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ed9c83ed Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ed9c83ed Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ed9c83ed Branch: refs/heads/release-2.x Commit: ed9c83ed0c071e57b826fcf0ca3564434c10618e Parents: 8201adf Author: Ralph Goers <[email protected]> Authored: Sun Feb 25 17:23:36 2018 -0700 Committer: Ralph Goers <[email protected]> Committed: Sun Feb 25 17:23:36 2018 -0700 ---------------------------------------------------------------------- log4j-api-java9/src/assembly/java9.xml | 8 - log4j-core-java9/src/assembly/java9.xml | 6 +- .../apache/logging/log4j/core/time/Instant.java | 77 +++++++++ .../logging/log4j/core/time/MutableInstant.java | 156 +++++++++++++++++++ .../logging/log4j/core/time/PreciseClock.java | 38 +++++ .../apache/logging/log4j/core/util/Instant.java | 75 --------- .../logging/log4j/core/util/MutableInstant.java | 155 ------------------ .../logging/log4j/core/util/PreciseClock.java | 36 ----- .../logging/log4j/core/util/SystemClock.java | 3 + src/changes/changes.xml | 3 + 10 files changed, 280 insertions(+), 277 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-api-java9/src/assembly/java9.xml ---------------------------------------------------------------------- diff --git a/log4j-api-java9/src/assembly/java9.xml b/log4j-api-java9/src/assembly/java9.xml index 3e59561..41a0da0 100644 --- a/log4j-api-java9/src/assembly/java9.xml +++ b/log4j-api-java9/src/assembly/java9.xml @@ -32,7 +32,6 @@ <include>**/*.class</include> </includes> <excludes> - <exclude>module-info.class</exclude> <exclude>**/Dummy.class</exclude> <exclude>**/spi/Provider.class</exclude> <exclude>**/util/PropertySource.class</exclude> @@ -40,12 +39,5 @@ <exclude>**/message/ThreadDumpMessage$ThreadInfoFactory.class</exclude> </excludes> </fileSet> - <fileSet> - <directory>${project.build.outputDirectory}</directory> - <outputDirectory>/classes</outputDirectory> - <includes> - <include>module-info.class</include> - </includes> - </fileSet> </fileSets> </assembly> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/assembly/java9.xml ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/assembly/java9.xml b/log4j-core-java9/src/assembly/java9.xml index f8f129d..f4e7c12 100644 --- a/log4j-core-java9/src/assembly/java9.xml +++ b/log4j-core-java9/src/assembly/java9.xml @@ -35,9 +35,9 @@ <exclude>module-info.class</exclude> <exclude>**/Dummy.class</exclude> <exclude>**/util/Clock.class</exclude> - <exclude>**/util/Instant.class</exclude> - <exclude>**/util/MutableInstant.class</exclude> - <exclude>**/util/PreciseClock.class</exclude> + <exclude>**/time/Instant.class</exclude> + <exclude>**/time/MutableInstant.class</exclude> + <exclude>**/time/PreciseClock.class</exclude> </excludes> </fileSet> <fileSet> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/Instant.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/Instant.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/Instant.java new file mode 100644 index 0000000..7153785 --- /dev/null +++ b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/Instant.java @@ -0,0 +1,77 @@ +/* + * 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.time; + +// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} +// to compile. It will not be copied into the log4j-core module. + +import org.apache.logging.log4j.core.util.Clock; + +/** + * Models a point in time, suitable for event timestamps. + * <p> + * Provides methods for obtaining high precision time information similar to the + * <a href="https://docs.oracle.com/javase/9/docs/api/java/time/Instant.html">Instant</a> class introduced in Java 8, + * while also supporting the legacy millisecond precision API. + * </p><p> + * Depending on the platform, time sources ({@link Clock} implementations) may produce high precision or millisecond + * precision time values. At the same time, some time value consumers (for example timestamp formatters) may only be + * able to consume time values of millisecond precision, while some others may require a high precision time value. + * </p><p> + * This class bridges these two time APIs. + * </p> + * @since 2.11 + */ +public interface Instant { + /** + * Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z. + * <p> + * The epoch second count is a simple incrementing count of seconds where second 0 is 1970-01-01T00:00:00Z. + * The nanosecond part of the day is returned by {@link #getNanoOfSecond()}. + * </p> + * @return the seconds from the epoch of 1970-01-01T00:00:00Z + */ + long getEpochSecond(); + + /** + * Gets the number of nanoseconds, later along the time-line, from the start of the second. + * <p> + * The nanosecond-of-second value measures the total number of nanoseconds from the second returned by {@link #getEpochSecond()}. + * </p> + * @return the nanoseconds within the second, always positive, never exceeds {@code 999,999,999} + */ + int getNanoOfSecond(); + + /** + * Gets the number of milliseconds from the Java epoch of 1970-01-01T00:00:00Z. + * <p> + * The epoch millisecond count is a simple incrementing count of milliseconds where millisecond 0 is 1970-01-01T00:00:00Z. + * The nanosecond part of the day is returned by {@link #getNanoOfMillisecond()}. + * </p> + * @return the milliseconds from the epoch of 1970-01-01T00:00:00Z + */ + long getEpochMillisecond(); + + /** + * Gets the number of nanoseconds, later along the time-line, from the start of the millisecond. + * <p> + * The nanosecond-of-millisecond value measures the total number of nanoseconds from the millisecond returned by {@link #getEpochMillisecond()}. + * </p> + * @return the nanoseconds within the millisecond, always positive, never exceeds {@code 999,999} + */ + int getNanoOfMillisecond(); +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/MutableInstant.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/MutableInstant.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/MutableInstant.java new file mode 100644 index 0000000..4f21a95 --- /dev/null +++ b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/MutableInstant.java @@ -0,0 +1,156 @@ +/* + * 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.time; + +import org.apache.logging.log4j.core.util.Clock; +import org.apache.logging.log4j.util.PerformanceSensitive; + +import java.io.Serializable; + +// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} +// to compile. It will not be copied into the log4j-core module. + +/** + * An instantaneous point on the time line, used for high-precision log event timestamps. + * Modelled on <a href="https://docs.oracle.com/javase/9/docs/api/index.html?java/time/class-use/Instant.html">java.time.Instant</a>, + * except that this version is mutable to prevent allocating temporary objects that need to be garbage-collected later. + * <p> + * Instances of this class are <em>not</em> thread-safe and should not be shared between threads. + * </p> + * + * @since 2.11 + */ +@PerformanceSensitive("allocation") +public class MutableInstant implements Instant, Serializable { + + private static final int MILLIS_PER_SECOND = 1000; + private static final int NANOS_PER_MILLI = 1000_000; + static final int NANOS_PER_SECOND = MILLIS_PER_SECOND * NANOS_PER_MILLI; + + private long epochSecond; + private int nanoOfSecond; + + @Override + public long getEpochSecond() { + return epochSecond; + } + + @Override + public int getNanoOfSecond() { + return nanoOfSecond; + } + + @Override + public long getEpochMillisecond() { + final int millis = nanoOfSecond / NANOS_PER_MILLI; + long epochMillisecond = epochSecond * MILLIS_PER_SECOND + millis; + return epochMillisecond; + } + + @Override + public int getNanoOfMillisecond() { + final int millis = nanoOfSecond / NANOS_PER_MILLI; + int nanoOfMillisecond = nanoOfSecond - (millis * NANOS_PER_MILLI); // cheaper than nanoOfSecond % NANOS_PER_MILLI + return nanoOfMillisecond; + } + + public void initFrom(final Instant other) { + this.epochSecond = other.getEpochSecond(); + this.nanoOfSecond = other.getNanoOfSecond(); + } + + /** + * Updates the fields of this {@code MutableInstant} from the specified epoch millis. + * @param epochMilli the number of milliseconds from the Java epoch of 1970-01-01T00:00:00Z + * @param nanoOfMillisecond the number of nanoseconds, later along the time-line, from the start of the millisecond + */ + public void initFromEpochMilli(final long epochMilli, final int nanoOfMillisecond) { + validateNanoOfMillisecond(nanoOfMillisecond); + this.epochSecond = epochMilli / MILLIS_PER_SECOND; + this.nanoOfSecond = (int) (epochMilli - (epochSecond * MILLIS_PER_SECOND)) * NANOS_PER_MILLI + nanoOfMillisecond; + } + + private void validateNanoOfMillisecond(final int nanoOfMillisecond) { + if (nanoOfMillisecond < 0 || nanoOfMillisecond >= NANOS_PER_MILLI) { + throw new IllegalArgumentException("Invalid nanoOfMillisecond " + nanoOfMillisecond); + } + } + + public void initFrom(final Clock clock) { + if (clock instanceof PreciseClock) { + ((PreciseClock) clock).init(this); + } else { + initFromEpochMilli(clock.currentTimeMillis(), 0); + } + } + + /** + * Updates the fields of this {@code MutableInstant} from the specified instant components. + * @param epochSecond the number of seconds from the Java epoch of 1970-01-01T00:00:00Z + * @param nano the number of nanoseconds, later along the time-line, from the start of the second + */ + public void initFromEpochSecond(final long epochSecond, final int nano) { + validateNanoOfSecond(nano); + this.epochSecond = epochSecond; + this.nanoOfSecond = nano; + } + + private void validateNanoOfSecond(final int nano) { + if (nano < 0 || nano >= NANOS_PER_SECOND) { + throw new IllegalArgumentException("Invalid nanoOfSecond " + nano); + } + } + + /** + * Updates the elements of the specified {@code long[]} result array from the specified instant components. + * @param epochSecond (input) the number of seconds from the Java epoch of 1970-01-01T00:00:00Z + * @param nano (input) the number of nanoseconds, later along the time-line, from the start of the second + * @param result (output) a two-element array to store the result: the first element is the number of milliseconds + * from the Java epoch of 1970-01-01T00:00:00Z, + * the second element is the number of nanoseconds, later along the time-line, from the start of the millisecond + */ + public static void instantToMillisAndNanos(final long epochSecond, final int nano, final long[] result) { + int millis = nano / NANOS_PER_MILLI; + result[0] = epochSecond * MILLIS_PER_SECOND + millis; + result[1] = nano - (millis * NANOS_PER_MILLI); // cheaper than nanoOfSecond % NANOS_PER_MILLI + } + + @Override + public boolean equals(final Object object) { + if (object == this) { + return true; + } + if (!(object instanceof MutableInstant)) { + return false; + } + MutableInstant other = (MutableInstant) object; + return epochSecond == other.epochSecond && nanoOfSecond == other.nanoOfSecond; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + (int) (epochSecond ^ (epochSecond >>> 32)); + result = 31 * result + nanoOfSecond; + return result; + } + + @Override + public String toString() { + return "MutableInstant[epochSecond=" + epochSecond + ", nano=" + nanoOfSecond + "]"; + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/PreciseClock.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/PreciseClock.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/PreciseClock.java new file mode 100644 index 0000000..9bd103b --- /dev/null +++ b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/time/PreciseClock.java @@ -0,0 +1,38 @@ +/* + * 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.time; + +// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} +// to compile. It will not be copied into the log4j-core module. + +import org.apache.logging.log4j.core.util.Clock; + +/** + * Extension of the {@link Clock} interface that is able to provide more accurate time information than milliseconds + * since the epoch. {@code PreciseClock} implementations are free to return millisecond-precision time + * if that is the most accurate time information available on this platform. + * @since 2.11 + */ +public interface PreciseClock extends Clock { + + /** + * Initializes the specified instant with time information as accurate as available on this platform. + * @param mutableInstant the container to be initialized with the accurate time information + * @since 2.11 + */ + void init(final MutableInstant mutableInstant); +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Instant.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Instant.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Instant.java deleted file mode 100644 index cd4ac9d..0000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/Instant.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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; - -// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} -// to compile. It will not be copied into the log4j-core module. - -/** - * Models a point in time, suitable for event timestamps. - * <p> - * Provides methods for obtaining high precision time information similar to the - * <a href="https://docs.oracle.com/javase/9/docs/api/java/time/Instant.html">Instant</a> class introduced in Java 8, - * while also supporting the legacy millisecond precision API. - * </p><p> - * Depending on the platform, time sources ({@link Clock} implementations) may produce high precision or millisecond - * precision time values. At the same time, some time value consumers (for example timestamp formatters) may only be - * able to consume time values of millisecond precision, while some others may require a high precision time value. - * </p><p> - * This class bridges these two time APIs. - * </p> - * @since 2.11 - */ -public interface Instant { - /** - * Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z. - * <p> - * The epoch second count is a simple incrementing count of seconds where second 0 is 1970-01-01T00:00:00Z. - * The nanosecond part of the day is returned by {@link #getNanoOfSecond()}. - * </p> - * @return the seconds from the epoch of 1970-01-01T00:00:00Z - */ - long getEpochSecond(); - - /** - * Gets the number of nanoseconds, later along the time-line, from the start of the second. - * <p> - * The nanosecond-of-second value measures the total number of nanoseconds from the second returned by {@link #getEpochSecond()}. - * </p> - * @return the nanoseconds within the second, always positive, never exceeds {@code 999,999,999} - */ - int getNanoOfSecond(); - - /** - * Gets the number of milliseconds from the Java epoch of 1970-01-01T00:00:00Z. - * <p> - * The epoch millisecond count is a simple incrementing count of milliseconds where millisecond 0 is 1970-01-01T00:00:00Z. - * The nanosecond part of the day is returned by {@link #getNanoOfMillisecond()}. - * </p> - * @return the milliseconds from the epoch of 1970-01-01T00:00:00Z - */ - long getEpochMillisecond(); - - /** - * Gets the number of nanoseconds, later along the time-line, from the start of the millisecond. - * <p> - * The nanosecond-of-millisecond value measures the total number of nanoseconds from the millisecond returned by {@link #getEpochMillisecond()}. - * </p> - * @return the nanoseconds within the millisecond, always positive, never exceeds {@code 999,999} - */ - int getNanoOfMillisecond(); -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/MutableInstant.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/MutableInstant.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/MutableInstant.java deleted file mode 100644 index 8960fc5..0000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/MutableInstant.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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 org.apache.logging.log4j.util.PerformanceSensitive; - -import java.io.Serializable; - -// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} -// to compile. It will not be copied into the log4j-core module. - -/** - * An instantaneous point on the time line, used for high-precision log event timestamps. - * Modelled on <a href="https://docs.oracle.com/javase/9/docs/api/index.html?java/time/class-use/Instant.html">java.time.Instant</a>, - * except that this version is mutable to prevent allocating temporary objects that need to be garbage-collected later. - * <p> - * Instances of this class are <em>not</em> thread-safe and should not be shared between threads. - * </p> - * - * @since 2.11 - */ -@PerformanceSensitive("allocation") -public class MutableInstant implements Instant, Serializable { - - private static final int MILLIS_PER_SECOND = 1000; - private static final int NANOS_PER_MILLI = 1000_000; - static final int NANOS_PER_SECOND = MILLIS_PER_SECOND * NANOS_PER_MILLI; - - private long epochSecond; - private int nanoOfSecond; - - @Override - public long getEpochSecond() { - return epochSecond; - } - - @Override - public int getNanoOfSecond() { - return nanoOfSecond; - } - - @Override - public long getEpochMillisecond() { - final int millis = nanoOfSecond / NANOS_PER_MILLI; - long epochMillisecond = epochSecond * MILLIS_PER_SECOND + millis; - return epochMillisecond; - } - - @Override - public int getNanoOfMillisecond() { - final int millis = nanoOfSecond / NANOS_PER_MILLI; - int nanoOfMillisecond = nanoOfSecond - (millis * NANOS_PER_MILLI); // cheaper than nanoOfSecond % NANOS_PER_MILLI - return nanoOfMillisecond; - } - - public void initFrom(final Instant other) { - this.epochSecond = other.getEpochSecond(); - this.nanoOfSecond = other.getNanoOfSecond(); - } - - /** - * Updates the fields of this {@code MutableInstant} from the specified epoch millis. - * @param epochMilli the number of milliseconds from the Java epoch of 1970-01-01T00:00:00Z - * @param nanoOfMillisecond the number of nanoseconds, later along the time-line, from the start of the millisecond - */ - public void initFromEpochMilli(final long epochMilli, final int nanoOfMillisecond) { - validateNanoOfMillisecond(nanoOfMillisecond); - this.epochSecond = epochMilli / MILLIS_PER_SECOND; - this.nanoOfSecond = (int) (epochMilli - (epochSecond * MILLIS_PER_SECOND)) * NANOS_PER_MILLI + nanoOfMillisecond; - } - - private void validateNanoOfMillisecond(final int nanoOfMillisecond) { - if (nanoOfMillisecond < 0 || nanoOfMillisecond >= NANOS_PER_MILLI) { - throw new IllegalArgumentException("Invalid nanoOfMillisecond " + nanoOfMillisecond); - } - } - - public void initFrom(final Clock clock) { - if (clock instanceof PreciseClock) { - ((PreciseClock) clock).init(this); - } else { - initFromEpochMilli(clock.currentTimeMillis(), 0); - } - } - - /** - * Updates the fields of this {@code MutableInstant} from the specified instant components. - * @param epochSecond the number of seconds from the Java epoch of 1970-01-01T00:00:00Z - * @param nano the number of nanoseconds, later along the time-line, from the start of the second - */ - public void initFromEpochSecond(final long epochSecond, final int nano) { - validateNanoOfSecond(nano); - this.epochSecond = epochSecond; - this.nanoOfSecond = nano; - } - - private void validateNanoOfSecond(final int nano) { - if (nano < 0 || nano >= NANOS_PER_SECOND) { - throw new IllegalArgumentException("Invalid nanoOfSecond " + nano); - } - } - - /** - * Updates the elements of the specified {@code long[]} result array from the specified instant components. - * @param epochSecond (input) the number of seconds from the Java epoch of 1970-01-01T00:00:00Z - * @param nano (input) the number of nanoseconds, later along the time-line, from the start of the second - * @param result (output) a two-element array to store the result: the first element is the number of milliseconds - * from the Java epoch of 1970-01-01T00:00:00Z, - * the second element is the number of nanoseconds, later along the time-line, from the start of the millisecond - */ - public static void instantToMillisAndNanos(final long epochSecond, final int nano, final long[] result) { - int millis = nano / NANOS_PER_MILLI; - result[0] = epochSecond * MILLIS_PER_SECOND + millis; - result[1] = nano - (millis * NANOS_PER_MILLI); // cheaper than nanoOfSecond % NANOS_PER_MILLI - } - - @Override - public boolean equals(final Object object) { - if (object == this) { - return true; - } - if (!(object instanceof MutableInstant)) { - return false; - } - MutableInstant other = (MutableInstant) object; - return epochSecond == other.epochSecond && nanoOfSecond == other.nanoOfSecond; - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + (int) (epochSecond ^ (epochSecond >>> 32)); - result = 31 * result + nanoOfSecond; - return result; - } - - @Override - public String toString() { - return "MutableInstant[epochSecond=" + epochSecond + ", nano=" + nanoOfSecond + "]"; - } -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/PreciseClock.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/PreciseClock.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/PreciseClock.java deleted file mode 100644 index 3d1f314..0000000 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/PreciseClock.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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; - -// This class is here to allow {@link SystemClock}, {@link SystemMillisClock} -// to compile. It will not be copied into the log4j-core module. - -/** - * Extension of the {@link Clock} interface that is able to provide more accurate time information than milliseconds - * since the epoch. {@code PreciseClock} implementations are free to return millisecond-precision time - * if that is the most accurate time information available on this platform. - * @since 2.11 - */ -public interface PreciseClock extends Clock { - - /** - * Initializes the specified instant with time information as accurate as available on this platform. - * @param mutableInstant the container to be initialized with the accurate time information - * @since 2.11 - */ - void init(final MutableInstant mutableInstant); -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java ---------------------------------------------------------------------- diff --git a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java index a74a1fd..3a6b5de 100644 --- a/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java +++ b/log4j-core-java9/src/main/java/org/apache/logging/log4j/core/util/SystemClock.java @@ -18,6 +18,9 @@ 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 http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ed9c83ed/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index fbefbe5..6081c7b 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -31,6 +31,9 @@ - "remove" - Removed --> <release version="2.11.0" date="2018-xx-xx" description="GA Release 2.11.0"> + <action issue="LOG4J@-2271" dev="rgoers" type="fix"> + Move module-info.class to META-INF/versions/9 directory. + </action> <action issue="LOG4J2-2254" dev="rgoers" type="fix"> Incorrect automatics module name header was being included in manifests. </action>
