He-Pin opened a new issue, #3257:
URL: https://github.com/apache/pekko/issues/3257
### Motivation
`MarkerLoggingAdapter.format1` calls `format(t, a.toIndexedSeq)` without
varargs expansion (`: _*`), causing Array arguments to be treated as a single
template argument instead of being expanded into individual placeholders.
### Current Behavior
`actor/src/main/scala/org/apache/pekko/event/Logging.scala:2004-2008`:
```scala
private def format1(t: String, arg: Any): String = arg match {
case a: Array[?] if !a.getClass.getComponentType.isPrimitive =>
format(t, a.toIndexedSeq)
case a: Array[?] =>
format(t, a.toIndexedSeq.asInstanceOf[IndexedSeq[AnyRef]])
case x =>
format(t, x)
}
```
This calls the varargs `format(t: String, arg: Any*)` (line 1538), which
wraps the `IndexedSeq` as a **single element**: `arg =
Seq(IndexedSeq("a","b","c"))`.
**Comparison with base class** (`LoggingAdapter.format1`, line 1532-1536):
```scala
private def format1(t: String, arg: Any): String = arg match {
case a: Array[?] if !a.getClass.getComponentType.isPrimitive =>
formatImpl(t, a.toSeq)
case a: Array[?] =>
formatImpl(t, a.toSeq.asInstanceOf[Seq[AnyRef]])
case x =>
format(t, x)
}
```
The base class calls `formatImpl` directly (not through varargs), so each
array element becomes a separate placeholder.
### Concrete Example
For `markerLog.info(marker, "{} {} {}", Array("a", "b", "c"))`:
| | Base LoggingAdapter | MarkerLoggingAdapter |
|---|---|---|
| Output | `"a b c"` | `"Vector(a, b, c) {} {}"` |
### Root Cause
Line 2003 comments: *"Copy of LoggingAdapter.format1 due to binary
compatibility restrictions"*. The base class's `formatImpl` is `private` to the
trait, so `MarkerLoggingAdapter` substituted `format(t, ...)` but forgot `: _*`
for varargs expansion.
### Fix
```scala
case a: Array[?] if !a.getClass.getComponentType.isPrimitive => format(t,
a.toIndexedSeq: _*)
case a: Array[?] => format(t,
a.toIndexedSeq.asInstanceOf[IndexedSeq[AnyRef]]: _*)
```
### Scope
All 8 one-argument template methods in `MarkerLoggingAdapter` are affected
(each log level × with-cause and without-cause variants).
`DiagnosticMarkerBusLoggingAdapter` inherits the same bug. No test covers Array
argument handling.
### Environment
- Pekko Actor (any version)
- `Logging.scala:2004-2008`
### References
None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]