You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2021/07/09 13:17:28 UTC
[logging-log4j2] 02/02: LOG4J2-3067 Rename "overflow" flag to
"overflowing" in CounterResolver.
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit fab9fac3f181536f46dbf50fb90ca746cc0585e8
Author: Volkan Yazici <vo...@gmail.com>
AuthorDate: Fri Jul 9 15:16:47 2021 +0200
LOG4J2-3067 Rename "overflow" flag to "overflowing" in CounterResolver.
---
.../template/json/resolver/CounterResolver.java | 24 +++++++++++-----------
.../json/resolver/CounterResolverTest.java | 12 +++++------
.../asciidoc/manual/json-template-layout.adoc.vm | 17 +++++++--------
3 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolver.java b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolver.java
index 6ad6b06..aa4a139 100644
--- a/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolver.java
+++ b/log4j-layout-template-json/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolver.java
@@ -32,19 +32,19 @@ import java.util.function.Consumer;
* <h3>Configuration</h3>
*
* <pre>
- * config = [ start ] , [ overflow ] , [ stringified ]
+ * config = [ start ] , [ overflowing ] , [ stringified ]
* start = "start" -> number
- * overflow = "overflow" -> boolean
+ * overflowing = "overflowing" -> boolean
* stringified = "stringified" -> boolean
* </pre>
*
- * Unless provided, <tt>start</tt> and <tt>overflow</tt> are respectively set to
- * zero and <tt>true</tt> by default.
+ * Unless provided, <tt>start</tt> and <tt>overflowing</tt> are respectively
+ * set to zero and <tt>true</tt> by default.
* <p>
- * When <tt>overflow</tt> is enabled, the internal counter is created using a
- * <tt>long</tt>, which is subject to overflow while incrementing, though
- * garbage-free. Otherwise, a {@link BigInteger} is used, which does not
- * overflow, but incurs allocation costs.
+ * When <tt>overflowing</tt> is set to <tt>true</tt>, the internal counter
+ * is created using a <tt>long</tt>, which is subject to overflow while
+ * incrementing, though garbage-free. Otherwise, a {@link BigInteger} is used,
+ * which does not overflow, but incurs allocation costs.
* <p>
* When <tt>stringified</tt> is enabled, which is set to <tt>false</tt> by
* default, the resolved number will be converted to a string.
@@ -76,7 +76,7 @@ import java.util.function.Consumer;
* <pre>
* {
* "$resolver": "counter",
- * "overflow": false
+ * "overflowing": false
* }
* </pre>
*/
@@ -94,16 +94,16 @@ public class CounterResolver implements EventResolver {
final EventResolverContext context,
final TemplateResolverConfig config) {
final BigInteger start = readStart(config);
- final boolean overflow = config.getBoolean("overflow", true);
+ final boolean overflowing = config.getBoolean("overflowing", true);
final boolean stringified = config.getBoolean("stringified", false);
if (stringified) {
final Recycler<StringBuilder> stringBuilderRecycler =
createStringBuilderRecycler(context);
- return overflow
+ return overflowing
? createStringifiedLongResolver(start, stringBuilderRecycler)
: createStringifiedBigIntegerResolver(start, stringBuilderRecycler);
} else {
- return overflow
+ return overflowing
? createLongResolver(start)
: createBigIntegerResolver(start);
}
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolverTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolverTest.java
index 29e1f28..d229fcf 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolverTest.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/CounterResolverTest.java
@@ -87,7 +87,7 @@ class CounterResolverTest {
}
@Test
- void max_long_should_work_when_overflow_enabled() {
+ void max_long_should_work_when_overflowing() {
final String eventTemplate = writeJson(asMap(
"$resolver", "counter",
"start", Long.MAX_VALUE));
@@ -95,7 +95,7 @@ class CounterResolverTest {
}
@Test
- void max_long_should_work_when_overflow_enabled_and_stringified() {
+ void max_long_should_work_when_overflowing_and_stringified() {
final String eventTemplate = writeJson(asMap(
"$resolver", "counter",
"start", Long.MAX_VALUE,
@@ -104,11 +104,11 @@ class CounterResolverTest {
}
@Test
- void max_long_should_work_when_overflow_disabled() {
+ void max_long_should_work_when_not_overflowing() {
final String eventTemplate = writeJson(asMap(
"$resolver", "counter",
"start", Long.MAX_VALUE,
- "overflow", false));
+ "overflowing", false));
verify(
eventTemplate,
Long.MAX_VALUE,
@@ -116,11 +116,11 @@ class CounterResolverTest {
}
@Test
- void max_long_should_work_when_overflow_disabled_and_stringified() {
+ void max_long_should_work_when_not_overflowing_and_stringified() {
final String eventTemplate = writeJson(asMap(
"$resolver", "counter",
"start", Long.MAX_VALUE,
- "overflow", false,
+ "overflowing", false,
"stringified", true));
verify(
eventTemplate,
diff --git a/src/site/asciidoc/manual/json-template-layout.adoc.vm b/src/site/asciidoc/manual/json-template-layout.adoc.vm
index b90d790..58754c7 100644
--- a/src/site/asciidoc/manual/json-template-layout.adoc.vm
+++ b/src/site/asciidoc/manual/json-template-layout.adoc.vm
@@ -459,25 +459,26 @@ detail.
[source]
----
-config = [ start ] , [ overflow ] , [ stringified ]
+config = [ start ] , [ overflowing ] , [ stringified ]
start = "start" -> number
-overflow = "overflow" -> boolean
+overflowing = "overflowing" -> boolean
stringified = "stringified" -> boolean
----
Resolves a number from an internal counter.
-Unless provided, `start` and `overflow` are respectively set to zero and `true`
-by default.
+Unless provided, `start` and `overflowing` are respectively set to zero and
+`true` by default.
When `stringified` is enabled, which is set to `false by default, the resolved
number will be converted to a string.
[WARNING]
====
-When `overflow` is enabled, the internal counter is created using a `long`,
-which is subject to overflow while incrementing, though garbage-free. Otherwise,
-a `BigInteger` is used, which does not overflow, but incurs allocation costs.
+When `overflowing` is set to `true`, the internal counter is created using a
+`long`, which is subject to overflow while incrementing, though garbage-free.
+Otherwise, a `BigInteger` is used, which does not overflow, but incurs
+allocation costs.
====
====== Examples
@@ -510,7 +511,7 @@ JVM heap allows.
----
{
"$resolver": "counter",
- "overflow": false
+ "overflowing": false
}
----