This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-projection.git
The following commit(s) were added to refs/heads/main by this push:
new a35e7d64 use lazy slf4j placeholders instead of string interpolation
(#624)
a35e7d64 is described below
commit a35e7d642a5326070aa7e2559b5667c1da2b9663
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Sep 11 22:06:29 2026 +0100
use lazy slf4j placeholders instead of string interpolation (#624)
Motivation:
Several slf4j call sites in main sources used the `s` string interpolator.
In most of them the interpolator was inert - the only braces in the message
were slf4j `{}` placeholders - so the prefix did nothing but mislead readers
into thinking the arguments were already substituted. In ReplicationImpl the
message was genuinely interpolated, so the string was built on every failed
replication ask even when WARN was disabled.
Modification:
Dropped the pointless `s` prefix in EventProducerServiceImpl,
JdbcOffsetStore
and R2dbcOffsetStore. Converted the interpolated warn in ReplicationImpl to
`log.warnN` with `{}` placeholders; `error` stays the trailing argument,
which
slf4j still resolves as the throwable because there are more arguments than
placeholders.
Result:
Message arguments are only rendered when the level is enabled, and the call
sites no longer mix interpolation with placeholder syntax. Rendered log
output
is unchanged.
Tests:
- sbt "grpc/compile" "jdbc/compile" "r2dbc/compile" / success
- sbt "grpc/scalafmt" "jdbc/scalafmt" "r2dbc/scalafmt" / success
- No new test: behaviour-preserving logging refactor with identical rendered
output and no signature changes
References:
None - drive-by cleanup of slf4j call sites in main sources
---
.../projection/grpc/internal/EventProducerServiceImpl.scala | 2 +-
.../projection/grpc/replication/internal/ReplicationImpl.scala | 9 +++++++--
.../apache/pekko/projection/jdbc/internal/JdbcOffsetStore.scala | 4 ++--
.../pekko/projection/r2dbc/internal/R2dbcOffsetStore.scala | 4 ++--
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git
a/grpc/src/main/scala/org/apache/pekko/projection/grpc/internal/EventProducerServiceImpl.scala
b/grpc/src/main/scala/org/apache/pekko/projection/grpc/internal/EventProducerServiceImpl.scala
index d0ff66fe..ab841b59 100644
---
a/grpc/src/main/scala/org/apache/pekko/projection/grpc/internal/EventProducerServiceImpl.scala
+++
b/grpc/src/main/scala/org/apache/pekko/projection/grpc/internal/EventProducerServiceImpl.scala
@@ -95,7 +95,7 @@ import scala.util.Success
sources.map(s => s.streamId -> s).toMap
log.info(
- s"Event producer gRPC service created with available sources [{}]",
+ "Event producer gRPC service created with available sources [{}]",
sources
.map(s => s"(stream id: [${s.streamId}], entity type:
[${s.entityType}])")
.mkString(", "))
diff --git
a/grpc/src/main/scala/org/apache/pekko/projection/grpc/replication/internal/ReplicationImpl.scala
b/grpc/src/main/scala/org/apache/pekko/projection/grpc/replication/internal/ReplicationImpl.scala
index 58591a32..bdf3b266 100644
---
a/grpc/src/main/scala/org/apache/pekko/projection/grpc/replication/internal/ReplicationImpl.scala
+++
b/grpc/src/main/scala/org/apache/pekko/projection/grpc/replication/internal/ReplicationImpl.scala
@@ -207,8 +207,13 @@ private[pekko] object ReplicationImpl {
replicatedEventMetadata.version)),
Some(replyTo)))
askResult.failed.foreach(error =>
- log.warn(
- s"Failing replication stream
[$projectionName/$projectionKey] from [${remoteReplica.replicaId.id}], event
pid [${envelope.persistenceId}], seq_nr [${envelope.sequenceNr}]",
+ log.warnN(
+ "Failing replication stream [{}/{}] from [{}], event
pid [{}], seq_nr [{}]",
+ projectionName,
+ projectionKey,
+ remoteReplica.replicaId.id,
+ envelope.persistenceId,
+ envelope.sequenceNr,
error))
askResult
diff --git
a/jdbc/src/main/scala/org/apache/pekko/projection/jdbc/internal/JdbcOffsetStore.scala
b/jdbc/src/main/scala/org/apache/pekko/projection/jdbc/internal/JdbcOffsetStore.scala
index e14d7fc7..bb5324d6 100644
---
a/jdbc/src/main/scala/org/apache/pekko/projection/jdbc/internal/JdbcOffsetStore.scala
+++
b/jdbc/src/main/scala/org/apache/pekko/projection/jdbc/internal/JdbcOffsetStore.scala
@@ -99,7 +99,7 @@ class JdbcOffsetStore[S <: JdbcSession](
stmt.setString(1, projectionId.name)
stmt.setString(2, projectionId.key)
val i = stmt.executeUpdate()
- logger.debug(s"clearing offset for [{}] - executed statement returned
[{}]", projectionId, i)
+ logger.debug("clearing offset for [{}] - executed statement returned
[{}]", projectionId, i)
Done
}
}
@@ -291,7 +291,7 @@ class JdbcOffsetStore[S <: JdbcSession](
if (verboseLogging) {
logger.debugN(
- s"tried to update paused [{}] for [{}], statement result [{}]",
+ "tried to update paused [{}] for [{}], statement result [{}]",
paused,
projectionId,
tryUpdateResult)
diff --git
a/r2dbc/src/main/scala/org/apache/pekko/projection/r2dbc/internal/R2dbcOffsetStore.scala
b/r2dbc/src/main/scala/org/apache/pekko/projection/r2dbc/internal/R2dbcOffsetStore.scala
index c4c767a2..da9c426c 100644
---
a/r2dbc/src/main/scala/org/apache/pekko/projection/r2dbc/internal/R2dbcOffsetStore.scala
+++
b/r2dbc/src/main/scala/org/apache/pekko/projection/r2dbc/internal/R2dbcOffsetStore.scala
@@ -1042,7 +1042,7 @@ private[projection] class R2dbcOffsetStore(
.bind(2, projectionId.name)
}
.map { n =>
- logger.debug(s"clearing timestamp offset for [{}] - executed
statement returned [{}]", projectionId, n)
+ logger.debug("clearing timestamp offset for [{}] - executed
statement returned [{}]", projectionId, n)
Done
}
case None =>
@@ -1061,7 +1061,7 @@ private[projection] class R2dbcOffsetStore(
.bind(1, projectionId.key)
}
.map { n =>
- logger.debug(s"clearing offset for [{}] - executed statement
returned [{}]", projectionId, n)
+ logger.debug("clearing offset for [{}] - executed statement returned
[{}]", projectionId, n)
Done
}
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]