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 2023/11/28 17:21:12 UTC

(logging-log4j2) branch main updated: Use String#isEmpty()

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

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


The following commit(s) were added to refs/heads/main by this push:
     new cf2ccc5149 Use String#isEmpty()
cf2ccc5149 is described below

commit cf2ccc51494b0c93ee770c0eed5b445daa61a675
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 28 12:21:07 2023 -0500

    Use String#isEmpty()
---
 .../src/main/java/org/apache/log4j/PropertyConfigurator.java          | 4 ++--
 .../main/java/org/apache/log4j/config/PropertiesConfiguration.java    | 4 ++--
 .../src/main/java/org/apache/log4j/xml/XmlConfiguration.java          | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java
index 428ddbbe19..5d1e63ccdb 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java
@@ -426,7 +426,7 @@ public class PropertyConfigurator implements Configurator {
         final String value = OptionConverter.findAndSubst(ADDITIVITY_PREFIX + loggerName, properties);
         LogLog.debug("Handling " + ADDITIVITY_PREFIX + loggerName + "=[" + value + "]");
         // touch additivity only if necessary
-        if ((value != null) && (!value.equals(""))) {
+        if (value != null && !value.isEmpty()) {
             final boolean additivity = OptionConverter.toBoolean(value, true);
             LogLog.debug("Setting additivity for \"" + loggerName + "\" to " + additivity);
             logger.setAdditivity(additivity);
@@ -581,7 +581,7 @@ public class PropertyConfigurator implements Configurator {
         // If value is not in the form ", appender.." or "", then we should set
         // the level of the loggeregory.
 
-        if (!(value.startsWith(",") || value.equals(""))) {
+        if (!(value.startsWith(",") || value.isEmpty())) {
 
             // just to be on the safe side...
             if (!st.hasMoreTokens()) {
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java
index 264f6fdf12..f3ed60377b 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java
@@ -389,7 +389,7 @@ public class PropertiesConfiguration extends Log4j1Configuration {
         final String value = OptionConverter.findAndSubst(key, props);
         LOGGER.debug("Handling {}=[{}]", key, value);
         // touch additivity only if necessary
-        if ((value != null) && (!value.equals(""))) {
+        if (value != null && !value.isEmpty()) {
             additivity = OptionConverter.toBoolean(value, true);
         }
         return additivity;
@@ -411,7 +411,7 @@ public class PropertiesConfiguration extends Log4j1Configuration {
 
         // If value is not in the form ", appender.." or "", then we should set the level of the logger.
 
-        if (!(value.startsWith(",") || value.equals(""))) {
+        if (!(value.startsWith(",") || value.isEmpty())) {
 
             // just to be on the safe side...
             if (!st.hasMoreTokens()) {
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java
index 8519d8fcd3..25f81f01db 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java
@@ -725,14 +725,14 @@ public class XmlConfiguration extends Log4j1Configuration {
         // if the log4j.dtd is not specified in the XML file, then the
         // "debug" attribute is returned as the empty string.
         String status = "error";
-        if (!debugAttrib.equals("") && !debugAttrib.equals("null")) {
+        if (!debugAttrib.isEmpty() && !debugAttrib.equals("null")) {
             status = OptionConverter.toBoolean(debugAttrib, true) ? "debug" : "error";
         } else {
             LOGGER.debug("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
         }
 
         final String confDebug = subst(element.getAttribute(CONFIG_DEBUG_ATTR));
-        if (!confDebug.equals("") && !confDebug.equals("null")) {
+        if (!confDebug.isEmpty() && !confDebug.equals("null")) {
             LOGGER.warn("The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
             LOGGER.warn("Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
             status = OptionConverter.toBoolean(confDebug, true) ? "debug" : "error";