Re: logging-log4j2 git commit: [LOG4J2-2351] Added AbstractLogEvent.getMutableInstant

2018-06-13 Thread Carter Kozak
Hi,

You are correct that it is initialized lazily (or not at all if
getInstant is overridden
and not delegated to), However constructing a new MutableInstant instance
does not initialize it from a clock, the value in both cases is {epochSecond=0,
nanoOfSecond=0}, similarl to the default implementation of
AbstractLogEvent.getTimeMillis which always returns zero.

Apologies for the confusion!

Best,
-ck

On Wed, Jun 13, 2018 at 10:01 AM, Gary Gregory  wrote:
> Hi,
>
> The semantics are quite different now, right? Before, the instant ivar was
> initialized on object instantiation, 'my instant is when I was created.'
> Now, it's value is a random amount of time after instantiation. How can
> that be right?
>
> Gary
>
> On Wed, Jun 13, 2018 at 6:14 AM  wrote:
>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 1ce2dec9b -> b54045f77
>>
>>
>> [LOG4J2-2351] Added AbstractLogEvent.getMutableInstant
>>
>> The MutableInstant may be modified by classes extending
>> AbstractLogEvent.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b54045f7
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b54045f7
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b54045f7
>>
>> Branch: refs/heads/master
>> Commit: b54045f77663aac71a9464c5568a38536f43614a
>> Parents: 1ce2dec
>> Author: Carter Kozak 
>> Authored: Tue Jun 12 10:35:20 2018 -0400
>> Committer: Carter Kozak 
>> Committed: Wed Jun 13 08:14:11 2018 -0400
>>
>> --
>>  .../org/apache/logging/log4j/core/AbstractLogEvent.java | 9 -
>>  src/changes/changes.xml | 6 ++
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>> --
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b54045f7/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
>> --
>> diff --git
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
>> index b9dd2bb..f1e6aed 100644
>> ---
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
>> +++
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
>> @@ -37,7 +37,7 @@ public abstract class AbstractLogEvent implements
>> LogEvent {
>>
>>  private static final long serialVersionUID = 1L;
>>
>> -private MutableInstant instant = new MutableInstant();
>> +private volatile MutableInstant instant;
>>
>>  /**
>>   * Subclasses should implement this method to provide an immutable
>> version.
>> @@ -127,6 +127,13 @@ public abstract class AbstractLogEvent implements
>> LogEvent {
>>
>>  @Override
>>  public Instant getInstant() {
>> +return getMutableInstant();
>> +}
>> +
>> +protected final MutableInstant getMutableInstant() {
>> +if (instant == null) {
>> +instant = new MutableInstant();
>> +}
>>  return instant;
>>  }
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b54045f7/src/changes/changes.xml
>> --
>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>> index d777072..e823ca5 100644
>> --- a/src/changes/changes.xml
>> +++ b/src/changes/changes.xml
>> @@ -180,6 +180,9 @@
>>
>>  Update Apache Commons Compress from 1.16.1 to 1.17.
>>
>> +  
>> +Added AbstractLogEvent.getMutableInstant to allow the
>> MutableInstant instance to be modified by classes extending
>> AbstractLogEvent.
>> +  
>>  
>>  
>>
>> @@ -253,6 +256,9 @@
>>
>>  Update Apache Commons Compress from 1.16.1 to 1.17.
>>
>> +  
>> +Added AbstractLogEvent.getMutableInstant to allow the
>> MutableInstant instance to be modified by classes extending
>> AbstractLogEvent.
>> +  
>>  
>>  
>>
>>
>>


Re: logging-log4j2 git commit: [LOG4J2-2351] Added AbstractLogEvent.getMutableInstant

2018-06-13 Thread Gary Gregory
Hi,

The semantics are quite different now, right? Before, the instant ivar was
initialized on object instantiation, 'my instant is when I was created.'
Now, it's value is a random amount of time after instantiation. How can
that be right?

Gary

On Wed, Jun 13, 2018 at 6:14 AM  wrote:

> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 1ce2dec9b -> b54045f77
>
>
> [LOG4J2-2351] Added AbstractLogEvent.getMutableInstant
>
> The MutableInstant may be modified by classes extending
> AbstractLogEvent.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b54045f7
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b54045f7
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b54045f7
>
> Branch: refs/heads/master
> Commit: b54045f77663aac71a9464c5568a38536f43614a
> Parents: 1ce2dec
> Author: Carter Kozak 
> Authored: Tue Jun 12 10:35:20 2018 -0400
> Committer: Carter Kozak 
> Committed: Wed Jun 13 08:14:11 2018 -0400
>
> --
>  .../org/apache/logging/log4j/core/AbstractLogEvent.java | 9 -
>  src/changes/changes.xml | 6 ++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> --
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b54045f7/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
> --
> diff --git
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
> index b9dd2bb..f1e6aed 100644
> ---
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
> +++
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLogEvent.java
> @@ -37,7 +37,7 @@ public abstract class AbstractLogEvent implements
> LogEvent {
>
>  private static final long serialVersionUID = 1L;
>
> -private MutableInstant instant = new MutableInstant();
> +private volatile MutableInstant instant;
>
>  /**
>   * Subclasses should implement this method to provide an immutable
> version.
> @@ -127,6 +127,13 @@ public abstract class AbstractLogEvent implements
> LogEvent {
>
>  @Override
>  public Instant getInstant() {
> +return getMutableInstant();
> +}
> +
> +protected final MutableInstant getMutableInstant() {
> +if (instant == null) {
> +instant = new MutableInstant();
> +}
>  return instant;
>  }
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b54045f7/src/changes/changes.xml
> --
> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> index d777072..e823ca5 100644
> --- a/src/changes/changes.xml
> +++ b/src/changes/changes.xml
> @@ -180,6 +180,9 @@
>
>  Update Apache Commons Compress from 1.16.1 to 1.17.
>
> +  
> +Added AbstractLogEvent.getMutableInstant to allow the
> MutableInstant instance to be modified by classes extending
> AbstractLogEvent.
> +  
>  
>  
>
> @@ -253,6 +256,9 @@
>
>  Update Apache Commons Compress from 1.16.1 to 1.17.
>
> +  
> +Added AbstractLogEvent.getMutableInstant to allow the
> MutableInstant instance to be modified by classes extending
> AbstractLogEvent.
> +  
>  
>  
>
>
>