You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2020/11/21 22:24:56 UTC

[logging-log4j2] 09/12: Use blocks.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 42b5a378ca77867d2a965dae34ba8f076a62ce88
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 21 16:45:19 2020 -0500

    Use blocks.
---
 .../log4j/util/SystemPropertiesPropertySourceTest.java   |  3 ++-
 .../org/apache/logging/log4j/core/util/FileUtils.java    | 12 +++++++-----
 .../RollingAppenderDirectWriteWithHtmlLayoutTest.java    |  3 ++-
 .../log4j/layout/template/json/JsonTemplateLayout.java   |  8 ++++++--
 .../log4j/layout/template/json/util/MapAccessor.java     |  8 ++++++--
 .../layout/template/json/util/StringParameterParser.java | 16 ++++++++++++----
 6 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceTest.java
index fb5d383..0eb711f 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceTest.java
@@ -59,10 +59,11 @@ public class SystemPropertiesPropertySourceTest {
                     properties.setProperty("FOO_" + i, "BAR");
                 }
             });
-            for (int i = 0; i < ITERATIONS; i++)
+            for (int i = 0; i < ITERATIONS; i++) {
                 new SystemPropertiesPropertySource().forEach((key, value) -> {
                     // nothing
                 });
+            }
             future.get();
         } finally {
             threadPool.shutdown();
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
index a50a20d..e8d45fc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/FileUtils.java
@@ -61,11 +61,13 @@ public final class FileUtils {
             return null;
         }
         if (uri.isAbsolute()) {
-            if (JBOSS_FILE.equals(uri.getScheme())) try {
-                // patch the scheme
-                uri = new URI(PROTOCOL_FILE, uri.getSchemeSpecificPart(), uri.getFragment());
-            } catch (URISyntaxException use) {
-                // should not happen, ignore
+            if (JBOSS_FILE.equals(uri.getScheme())) {
+                try {
+                    // patch the scheme
+                    uri = new URI(PROTOCOL_FILE, uri.getSchemeSpecificPart(), uri.getFragment());
+                } catch (URISyntaxException use) {
+                    // should not happen, ignore
+                }
             }
             try {
                 if (PROTOCOL_FILE.equals(uri.getScheme())) {
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
index e0d2dce..f50e9e2 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderDirectWriteWithHtmlLayoutTest.java
@@ -94,8 +94,9 @@ public class RollingAppenderDirectWriteWithHtmlLayoutTest {
             int foundEvents = 0;
             final Pattern eventMatcher = Pattern.compile("title=\"Message\"");
             for (File file : files) {
-                if (!file.getName().startsWith(prefix))
+                if (!file.getName().startsWith(prefix)) {
                     continue;
+                }
                 try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
                     String data = IOUtils.toString(reader).trim();
                     // check that every file starts with the header
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
index 33c73ef..ebc5a80 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayout.java
@@ -544,8 +544,12 @@ public class JsonTemplateLayout implements StringLayout {
 
         @Override
         public boolean equals(Object object) {
-            if (this == object) return true;
-            if (object == null || getClass() != object.getClass()) return false;
+            if (this == object) {
+                return true;
+            }
+            if (object == null || getClass() != object.getClass()) {
+                return false;
+            }
             EventTemplateAdditionalField that = (EventTemplateAdditionalField) object;
             return key.equals(that.key) &&
                     value.equals(that.value) &&
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/MapAccessor.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/MapAccessor.java
index cc3ef76..39cae10 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/MapAccessor.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/MapAccessor.java
@@ -120,8 +120,12 @@ public class MapAccessor {
 
     @Override
     public boolean equals(final Object instance) {
-        if (this == instance) return true;
-        if (instance == null || getClass() != instance.getClass()) return false;
+        if (this == instance) {
+            return true;
+        }
+        if (instance == null || getClass() != instance.getClass()) {
+            return false;
+        }
         final MapAccessor that = (MapAccessor) instance;
         return map.equals(that.map);
     }
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
index 041f2e3..be58534 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/util/StringParameterParser.java
@@ -77,8 +77,12 @@ public final class StringParameterParser {
 
         @Override
         public boolean equals(Object object) {
-            if (this == object) return true;
-            if (object == null || getClass() != object.getClass()) return false;
+            if (this == object) {
+                return true;
+            }
+            if (object == null || getClass() != object.getClass()) {
+                return false;
+            }
             StringValue that = (StringValue) object;
             return string.equals(that.string);
         }
@@ -109,8 +113,12 @@ public final class StringParameterParser {
 
         @Override
         public boolean equals(Object object) {
-            if (this == object) return true;
-            if (object == null || getClass() != object.getClass()) return false;
+            if (this == object) {
+                return true;
+            }
+            if (object == null || getClass() != object.getClass()) {
+                return false;
+            }
             DoubleQuotedStringValue that = (DoubleQuotedStringValue) object;
             return doubleQuotedString.equals(that.doubleQuotedString);
         }