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/12 23:04:27 UTC
[logging-log4j2] 03/05: Don't need to create arrays when calling a
vararg method.
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 fa94ba25d39d4e0494f8f33b59199d3894cda64d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Nov 12 16:41:48 2020 -0500
Don't need to create arrays when calling a vararg method.
---
.../src/main/java/org/apache/log4j/xml/XmlConfiguration.java | 2 +-
.../java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java | 2 +-
.../org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java | 4 ++--
.../apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java | 4 ++--
.../java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
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 4cb4d73..d95e185 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
@@ -631,7 +631,7 @@ public class XmlConfiguration extends Log4j1Configuration {
try {
Class<?> clazz = LoaderUtil.loadClass(className);
Method toLevelMethod = clazz.getMethod("toLevel", ONE_STRING_PARAM);
- Level pri = (Level) toLevelMethod.invoke(null, new Object[]{priStr});
+ Level pri = (Level) toLevelMethod.invoke(null, priStr);
logger.setLevel(OptionConverter.convertLevel(pri));
} catch (Exception oops) {
if (oops instanceof InterruptedException || oops instanceof InterruptedIOException) {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java
index f61d216..4b73257 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/tools/picocli/CommandLine.java
@@ -3126,7 +3126,7 @@ public class CommandLine {
// right-adjust the command name by length of synopsis heading
final Text PADDING = Ansi.OFF.new Text(stringOf('X', synopsisHeadingLength));
- textTable.addRowValues(new Text[] {PADDING.append(colorScheme.commandText(commandName)), optionText});
+ textTable.addRowValues(PADDING.append(colorScheme.commandText(commandName)), optionText);
return textTable.toString().substring(synopsisHeadingLength); // cut off leading synopsis heading spaces
}
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
index dd4f82a..e980a8f 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/SimplePerfTest.java
@@ -139,9 +139,9 @@ public class SimplePerfTest {
// use reflection so we can use the same test with older versions of log4j2
try {
final Method setUseThreadLocals =
- AsyncLoggerContext.class.getDeclaredMethod("setUseThreadLocals", new Class[]{boolean.class});
+ AsyncLoggerContext.class.getDeclaredMethod("setUseThreadLocals", boolean.class);
final LoggerContext context = LogManager.getContext(false);
- setUseThreadLocals.invoke(context, new Object[] {Boolean.TRUE});
+ setUseThreadLocals.invoke(context, Boolean.TRUE);
} catch (final Throwable ignored) {
}
}
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java
index 3caab80..dc53b9c 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FixedDateFormatTest.java
@@ -125,14 +125,14 @@ public class FixedDateFormatTest {
@Test
public void testCreateIfSupported_defaultTimeZoneIfOptionsArrayWithSecondNullElement() {
- final FixedDateFormat fmt = FixedDateFormat.createIfSupported(new String[] {DEFAULT.getPattern(), null, ""});
+ final FixedDateFormat fmt = FixedDateFormat.createIfSupported(DEFAULT.getPattern(), null, "");
assertEquals(DEFAULT.getPattern(), fmt.getFormat());
assertEquals(TimeZone.getDefault(), fmt.getTimeZone());
}
@Test
public void testCreateIfSupported_customTimeZoneIfOptionsArrayWithTimeZoneElement() {
- final FixedDateFormat fmt = FixedDateFormat.createIfSupported(new String[] {DEFAULT.getPattern(), "+08:00", ""});
+ final FixedDateFormat fmt = FixedDateFormat.createIfSupported(DEFAULT.getPattern(), "+08:00", "");
assertEquals(DEFAULT.getPattern(), fmt.getFormat());
assertEquals(TimeZone.getTimeZone("+08:00"), fmt.getTimeZone());
}
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java
index 99145f4..6ae0a8d 100644
--- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/TimeFormatBenchmark.java
@@ -56,7 +56,7 @@ public class TimeFormatBenchmark {
}
};
FastDateFormat fastDateFormat = FastDateFormat.getInstance("HH:mm:ss.SSS");
- FixedDateFormat fixedDateFormat = FixedDateFormat.createIfSupported(new String[]{"ABSOLUTE"});
+ FixedDateFormat fixedDateFormat = FixedDateFormat.createIfSupported("ABSOLUTE");
volatile long midnightToday;
volatile long midnightTomorrow;