Skip to content

[improve] PIP-467: Convert remaining modules logging from SLF4J to slog - #25511

Merged
merlimat merged 9 commits into
apache:masterfrom
merlimat:slog-rest
Apr 15, 2026
Merged

merlimat merged 9 commits into
apache:masterfrom
merlimat:slog-rest

Conversation

@merlimat

Copy link
Copy Markdown
Contributor

Summary

  • Convert 338 source and test files across all remaining modules (except pulsar-broker) from SLF4J to slog structured logging
  • Modules: pulsar-proxy, pulsar-broker-common, pulsar-common, pulsar-websocket, pulsar-testclient, pulsar-client-tools, pulsar-client-admin, tiered-storage, buildtools, pulsar-io, pulsar-transaction, pulsar-package-management, testmocks, bouncy-castle, jetty-upgrade, jclouds-shaded, tests/integration, and various auth/crypto modules
  • Use log.infof() with Java format specifiers for performance tool stats output
  • Use .exceptionMessage(e) consistently for logging exception messages without stack traces

Test plan

  • compileJava passes for all modules
  • CI passes

Motivation

PIP-467

Note

Please label this PR with ready-to-test

Convert remaining SLF4J-style log calls in PulsarSaslServer and
AuthenticationProviderSasl to slog format. Fix .exception() calls
where a String was passed instead of a Throwable.
The slog Logger has no isDebugEnabled() method. The fluent debug() API
is cheap enough to not need guards, so remove them to fix compilation.
- MiniKdc: convert the loop's log.info("{}: {}", ...) to slog fluent
- ProxySaslAuthenticationTest, SaslAuthenticateTest: replace misused
  .exception(stringArg) with .attr(). .exception() takes Throwable only.
The PR appended lombok.CustomLog to the end of the lombok import group
in many files and into the wrong group in a few others, breaking
checkstyle's ImportOrder rule. Re-sort the lombok imports so CustomLog
sits in alphabetical order.

Also wrap two 124-char lambda lines in PulsarWorkerRebalanceDrainTest
to stay under the 120-char limit.
- ProducerHandler: guard wrap two debug calls with Consumer form so
  getRemote().getRemoteAddress() is only evaluated when debug is
  enabled. The old SLF4J code had isDebugEnabled() guards for the
  same reason; removing them made ProducerHandlerTest NPE because
  getRemote() is null in the test mock.
- CmdProduce: use infof so the emitted text is "N messages
  successfully produced", which is what CLITest asserts on stdout.
- LoggingBrokerInterceptor: use infof so the emitted text is
  "initialize: OK" / "beforeSendMessage: OK", matching the
  TestBrokerInterceptors log-grep assertions.
@merlimat
merlimat merged commit 40edde7 into apache:master Apr 15, 2026
43 checks passed
@merlimat
merlimat deleted the slog-rest branch April 15, 2026 15:13
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 2026
lhotari added a commit to lhotari/pulsar that referenced this pull request Sep 7, 2026
…mmands

Follow-up to the review on apache#26480, pulsar-client half.

- `ProducerSocket.onMessage` had lost the `if (this.result != null)` guard, so a
  text frame arriving outside a pending send would NPE on the Jetty callback
  thread where it used to be ignored. Restores the guard and the pre-split log
  text ("Received ack" with attr `ack`); the version in the split was a
  hand-rendering of the pre-apache#25511 slf4j format string. Also drops the dead
  `throws InterruptedException` on `onConnect`, and comments the two deliberate
  changes in the same class: `send()` installs the completion future before
  `sendText(...)` (the old order let an ack complete the previous future and
  hang the caller for the full 30s), and `close()` null-checks the session that
  `onClose` clears.

- `consume-v4`'s `--start-timestamp` seek and `--end-timestamp` filter were only
  covered by their rejection messages: deleting either line left every test
  passing, though timestamp seek is the stated reason the command exists. Adds
  `PulsarClientToolTest.testConsumeV4StartAndEndTimestamp`, which pins both
  against a real observed publish time. Mutation checked: deleting either line
  fails it.

- `CmdProduceV4.nativeAvroSchemaOrNull` returned null for an Avro schema with no
  native definition, which would ship the raw JSON text as the payload; the
  pre-apache#25917 command threw. Throws again. Not reachable from any current CLI
  invocation, but the invariant is worth keeping explicit.

- `PulsarClientTool.buildV4ClientBuilder`: removes the unreachable
  "proxy-protocol must be provided with proxy-url" throw — `updateConfig()` is
  the `preRun()` hook and already returns 1 for that case before the supplier
  that reaches this method is even created, and `ClientBuilderImpl` re-checks it.
  Keeps the outer `isNotBlank` guard, which unlike the V5 path is load-bearing
  here because this builder uses `loadConf()`. Documents why `serviceUrl` and
  `tlsTrustCertsFilePath` are applied unconditionally.

- Deletes `AbstractCmdReadCommand.startMessageId()` and both overrides: never
  called, `webSocketStartMessageId()` is the one in use.

- `TestCmdConsume` sets `subscriptionName` directly instead of reflecting into
  it; the field is protected and the test is in the same package.

- `CmdV4CommandsTest` imports the `java.util` types its helper used inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants