You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2016/02/29 06:28:14 UTC

Fwd: [1/5] logging-log4j2 git commit: Remove unnecessary static.

Wait a sec, I do not like this change.

Why is this static "unnecessary"?

The class should be on the instance side ONLY if needs to access instance
information, which means it is slightly heavier because it needs to carry a
pointer to the instance. Otherwise, it should be static.

Gary
---------- Forwarded message ----------
From: <ma...@apache.org>
Date: Sun, Feb 28, 2016 at 7:25 PM
Subject: [1/5] logging-log4j2 git commit: Remove unnecessary static.
To: commits@logging.apache.org


Repository: logging-log4j2
Updated Branches:
  refs/heads/master 7e0392378 -> b7f6feaa5


Remove unnecessary static.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ec99de70
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ec99de70
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ec99de70

Branch: refs/heads/master
Commit: ec99de70694d5ec6cc5637c58ccfa446523a77a8
Parents: 7e03923
Author: Matt Sicker <bo...@gmail.com>
Authored: Sun Feb 28 20:52:04 2016 -0600
Committer: Matt Sicker <bo...@gmail.com>
Committed: Sun Feb 28 20:52:04 2016 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/logging/log4j/core/layout/GelfLayout.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ec99de70/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
----------------------------------------------------------------------
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
index a19af64..0b3effa 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
@@ -72,7 +72,7 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder;
 @Plugin(name = "GelfLayout", category = Node.CATEGORY, elementType =
Layout.ELEMENT_TYPE, printObject = true)
 public final class GelfLayout extends AbstractStringLayout {

-    public static enum CompressionType {
+    public enum CompressionType {

         GZIP {
             @Override




-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [1/5] logging-log4j2 git commit: Remove unnecessary static.

Posted by Matt Sicker <bo...@gmail.com>.
Yeah, basically they're already global singletons, so you can't make a
non-static enum anyway.

On 28 February 2016 at 23:34, Gary Gregory <ga...@gmail.com> wrote:

> Ah... so enums is a special case? Interesting... thank you for the
> clarification!
>
> Gary
>
> On Sun, Feb 28, 2016 at 9:32 PM, Matt Sicker <bo...@gmail.com> wrote:
>
>> An inner enum is inherently static because they're enums. Also, enum
>> constructors are by default private. At least that's what IntelliJ told me.
>>
>> On 28 February 2016 at 23:28, Gary Gregory <ga...@gmail.com>
>> wrote:
>>
>>> Wait a sec, I do not like this change.
>>>
>>> Why is this static "unnecessary"?
>>>
>>> The class should be on the instance side ONLY if needs to access
>>> instance information, which means it is slightly heavier because it needs
>>> to carry a pointer to the instance. Otherwise, it should be static.
>>>
>>> Gary
>>> ---------- Forwarded message ----------
>>> From: <ma...@apache.org>
>>> Date: Sun, Feb 28, 2016 at 7:25 PM
>>> Subject: [1/5] logging-log4j2 git commit: Remove unnecessary static.
>>> To: commits@logging.apache.org
>>>
>>>
>>> Repository: logging-log4j2
>>> Updated Branches:
>>>   refs/heads/master 7e0392378 -> b7f6feaa5
>>>
>>>
>>> Remove unnecessary static.
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ec99de70
>>> Tree:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ec99de70
>>> Diff:
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ec99de70
>>>
>>> Branch: refs/heads/master
>>> Commit: ec99de70694d5ec6cc5637c58ccfa446523a77a8
>>> Parents: 7e03923
>>> Author: Matt Sicker <bo...@gmail.com>
>>> Authored: Sun Feb 28 20:52:04 2016 -0600
>>> Committer: Matt Sicker <bo...@gmail.com>
>>> Committed: Sun Feb 28 20:52:04 2016 -0600
>>>
>>> ----------------------------------------------------------------------
>>>  .../main/java/org/apache/logging/log4j/core/layout/GelfLayout.java | 2
>>> +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ec99de70/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>>> index a19af64..0b3effa 100644
>>> ---
>>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>>> +++
>>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>>> @@ -72,7 +72,7 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder;
>>>  @Plugin(name = "GelfLayout", category = Node.CATEGORY, elementType =
>>> Layout.ELEMENT_TYPE, printObject = true)
>>>  public final class GelfLayout extends AbstractStringLayout {
>>>
>>> -    public static enum CompressionType {
>>> +    public enum CompressionType {
>>>
>>>          GZIP {
>>>              @Override
>>>
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition
>>> <http://www.manning.com/bauer3/>
>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>> Spring Batch in Action <http://www.manning.com/templier/>
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>>>
>>
>>
>>
>> --
>> Matt Sicker <bo...@gmail.com>
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <bo...@gmail.com>

Re: [1/5] logging-log4j2 git commit: Remove unnecessary static.

Posted by Gary Gregory <ga...@gmail.com>.
Ah... so enums is a special case? Interesting... thank you for the
clarification!

Gary

On Sun, Feb 28, 2016 at 9:32 PM, Matt Sicker <bo...@gmail.com> wrote:

> An inner enum is inherently static because they're enums. Also, enum
> constructors are by default private. At least that's what IntelliJ told me.
>
> On 28 February 2016 at 23:28, Gary Gregory <ga...@gmail.com> wrote:
>
>> Wait a sec, I do not like this change.
>>
>> Why is this static "unnecessary"?
>>
>> The class should be on the instance side ONLY if needs to access instance
>> information, which means it is slightly heavier because it needs to carry a
>> pointer to the instance. Otherwise, it should be static.
>>
>> Gary
>> ---------- Forwarded message ----------
>> From: <ma...@apache.org>
>> Date: Sun, Feb 28, 2016 at 7:25 PM
>> Subject: [1/5] logging-log4j2 git commit: Remove unnecessary static.
>> To: commits@logging.apache.org
>>
>>
>> Repository: logging-log4j2
>> Updated Branches:
>>   refs/heads/master 7e0392378 -> b7f6feaa5
>>
>>
>> Remove unnecessary static.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ec99de70
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ec99de70
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ec99de70
>>
>> Branch: refs/heads/master
>> Commit: ec99de70694d5ec6cc5637c58ccfa446523a77a8
>> Parents: 7e03923
>> Author: Matt Sicker <bo...@gmail.com>
>> Authored: Sun Feb 28 20:52:04 2016 -0600
>> Committer: Matt Sicker <bo...@gmail.com>
>> Committed: Sun Feb 28 20:52:04 2016 -0600
>>
>> ----------------------------------------------------------------------
>>  .../main/java/org/apache/logging/log4j/core/layout/GelfLayout.java | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ec99de70/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>> index a19af64..0b3effa 100644
>> ---
>> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>> +++
>> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
>> @@ -72,7 +72,7 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder;
>>  @Plugin(name = "GelfLayout", category = Node.CATEGORY, elementType =
>> Layout.ELEMENT_TYPE, printObject = true)
>>  public final class GelfLayout extends AbstractStringLayout {
>>
>> -    public static enum CompressionType {
>> +    public enum CompressionType {
>>
>>          GZIP {
>>              @Override
>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [1/5] logging-log4j2 git commit: Remove unnecessary static.

Posted by Matt Sicker <bo...@gmail.com>.
An inner enum is inherently static because they're enums. Also, enum
constructors are by default private. At least that's what IntelliJ told me.

On 28 February 2016 at 23:28, Gary Gregory <ga...@gmail.com> wrote:

> Wait a sec, I do not like this change.
>
> Why is this static "unnecessary"?
>
> The class should be on the instance side ONLY if needs to access instance
> information, which means it is slightly heavier because it needs to carry a
> pointer to the instance. Otherwise, it should be static.
>
> Gary
> ---------- Forwarded message ----------
> From: <ma...@apache.org>
> Date: Sun, Feb 28, 2016 at 7:25 PM
> Subject: [1/5] logging-log4j2 git commit: Remove unnecessary static.
> To: commits@logging.apache.org
>
>
> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master 7e0392378 -> b7f6feaa5
>
>
> Remove unnecessary static.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ec99de70
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ec99de70
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ec99de70
>
> Branch: refs/heads/master
> Commit: ec99de70694d5ec6cc5637c58ccfa446523a77a8
> Parents: 7e03923
> Author: Matt Sicker <bo...@gmail.com>
> Authored: Sun Feb 28 20:52:04 2016 -0600
> Committer: Matt Sicker <bo...@gmail.com>
> Committed: Sun Feb 28 20:52:04 2016 -0600
>
> ----------------------------------------------------------------------
>  .../main/java/org/apache/logging/log4j/core/layout/GelfLayout.java | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ec99de70/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
> index a19af64..0b3effa 100644
> ---
> a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
> +++
> b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
> @@ -72,7 +72,7 @@ import com.fasterxml.jackson.core.io.JsonStringEncoder;
>  @Plugin(name = "GelfLayout", category = Node.CATEGORY, elementType =
> Layout.ELEMENT_TYPE, printObject = true)
>  public final class GelfLayout extends AbstractStringLayout {
>
> -    public static enum CompressionType {
> +    public enum CompressionType {
>
>          GZIP {
>              @Override
>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <bo...@gmail.com>