use of org.apache.logging.log4j.layout.template.json.util.Recycler in project logging-log4j2 by apache.
the class CounterResolver method createStringifiedLongResolver.
private static Consumer<JsonWriter> createStringifiedLongResolver(final BigInteger start, final Recycler<StringBuilder> stringBuilderRecycler) {
final long effectiveStart = start.longValue();
final AtomicLong counter = new AtomicLong(effectiveStart);
return (jsonWriter) -> {
final long number = counter.getAndIncrement();
final StringBuilder stringBuilder = stringBuilderRecycler.acquire();
try {
stringBuilder.append(number);
jsonWriter.writeString(stringBuilder);
} finally {
stringBuilderRecycler.release(stringBuilder);
}
};
}
Aggregations