Skip to content

Kafka: SASL (PLAIN, SCRAM, MSK IAM), snappy/lz4/zstd, read_committed - #6336

Open
shai-almog wants to merge 12 commits into
masterfrom
kafka-sasl-compression
Open

shai-almog wants to merge 12 commits into
masterfrom
kafka-sasl-compression

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Closes the gaps that kept the backend's Kafka transport out of production: it had no SASL, so it could not reach Confluent Cloud, Amazon MSK or Azure Event Hubs, and a consumer failed on any topic written with snappy, lz4 or zstd.

What changed

  • SASL: PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 and AWS_MSK_IAM (new KafkaSasl). Configured through Spring Boot's keys (spring.kafka.security.protocol, spring.kafka.properties.sasl.mechanism, spring.kafka.properties.sasl.jaas.config), cn1.messaging.kafka.sasl.*, or credentials in the URL. SASL_SSL/SSL turn TLS on. Re-authenticates before connections.max.reauth.ms ends the session (KIP-368). Refused credentials fail at once with the broker's reason, instead of being retried and reported as "no partitions".
  • Compression: pure-Java snappy (raw and snappy-java framing), lz4 (frame format) and zstd (RFC 8878, no dictionaries) decoders. Every bound is checked explicitly for ParparVM, and decompression is capped per batch (64 MiB) and per fetch (128 MiB).
  • read_committed: spring.kafka.consumer.isolation-level=read_committed drops the records of aborted transactions. Control batches are skipped in both isolation levels, and the offset always moves past them.
  • Docs: Backend-Messaging.asciidoc and the KafkaTransport class docs.

Not included: sending inside a Kafka transaction. The transactional outbox already covers the database-plus-message case.

Testing

  • New unit tests: each decoder is checked against the reference compressors (zstd-jni, lz4-java, snappy-java, test scope only) across sizes and levels, plus corrupt-input fuzzing. Also covered: the RFC 7677 SCRAM vector, JAAS/URL parsing, the MSK IAM payload shape, read_committed, and offset advancement.
  • Against a real Kafka 3.9 broker in a container, on the JVM and as a native ParparVM binary:
    • Every mechanism read 20,000 records in each codec.
    • With aborted transactions in every codec, read_committed returned exactly the committed records.
    • One connection stayed up for 25 s across an 8 s session limit. With re-auth disabled, the broker drops that connection, so the check is real.
    • Bad credentials failed in about 0.3 s.
    • SASL_SSL was tested on the JVM only. Natively, the system trust store correctly rejects the test's self-signed certificate.
  • AWS_MSK_IAM has not been run against a live MSK cluster.
  • SpotBugs and PMD are at zero. Checkstyle and doclint are clean. The change compiles against vm/JavaAPI, and Vale is clean on the doc.

🤖 Generated with Claude Code

shai-almog and others added 3 commits November 26, 2026 03:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Credentials come only from the URL authority, not a path holding @. A
SCRAM JAAS line without a mechanism is refused rather than sent as PLAIN.
JAAS options are tokenized. SCRAM refuses mandatory extensions. One fetch
shares a 128 MiB inflation budget and a batch is capped at 64 MiB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Any whitespace separates JAAS tokens, so a SCRAM module followed by a tab
or line break is still recognised and never falls back to PLAIN. A session
under 2 s re-authenticates at half its life. The aborted-transaction count
a broker sends is checked against the bytes that follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ✅ ByteCodeTranslator: 0 findings (no issues)
    • ✅ android: 0 findings (no issues)
    • ✅ android-compat: 0 findings (no issues)
    • ✅ android-res-compiler: 0 findings (no issues)
    • ✅ backend: 0 findings (no issues)
    • ✅ backend-test: 0 findings (no issues)
    • ✅ build-engine: 0 findings (no issues)
    • ✅ build-hint-catalog: 0 findings (no issues)
    • ✅ build-hint-tools: 0 findings (no issues)
    • ✅ codenameone-gradle-plugin: 0 findings (no issues)
    • ✅ codenameone-maven-plugin: 0 findings (no issues)
    • ✅ compose-compat: 0 findings (no issues)
    • ✅ core-unittests: 0 findings (no issues)
    • ✅ desktop-compat-runtime: 0 findings (no issues)
    • ✅ fxml-compiler: 0 findings (no issues)
    • ✅ ios: 0 findings (no issues)
    • ✅ javac: 0 findings (no issues)
    • ✅ javafx-compat: 0 findings (no issues)
    • ✅ project-model: 0 findings (no issues)
    • ✅ python-runtime: 0 findings (no issues)
    • ✅ python-transpiler: 0 findings (no issues)
    • ✅ rive-runtime: 0 findings (no issues)
    • ✅ swing-compat: 0 findings (no issues)
  • ✅ PMD: 0 findings (no issues) [Report archive]
  • ✅ Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

shai-almog and others added 4 commits November 26, 2026 07:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Kafka decompressors carried their own ByteSink beside
com.codename1.backend.ByteSink. They now write into the shared one, and
what they need on top of it -- the 64 MiB ceiling, the LZ77 back-reference
copy and the bounds-checked little-endian reads -- is a static helper,
Inflate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ackend

The presentation readers brought a Snappy block decoder into core
(com.codename1.impl.office.Snappy). It is now @SharedWithBackend, and the
Kafka decoder keeps only what is Kafka's: the xerial stream framing and a
ceiling that counts the batch's earlier blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shai-almog

shai-almog commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 301 screenshots: 301 matched.
Native Windows port, REAL shipping pipeline: the hellocodenameone screenshot suite rendered by a binary CROSS-COMPILED on Linux (clang-cl + xwin, WebView2 linked) and RUN on a Windows x64 runner. Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 43ms / native 2ms = 21.5x speedup
SIMD float-mul (64K x300) java 56ms / native 3ms = 18.6x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 64.000 ms
Base64 CN1 decode 83.000 ms
Base64 SIMD encode 86.000 ms
Base64 encode ratio (SIMD/CN1) 1.344x (34.4% slower)
Base64 SIMD decode 77.000 ms
Base64 decode ratio (SIMD/CN1) 0.928x (7.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 8.000 ms
Image createMask (SIMD on) 4.000 ms
Image createMask ratio (SIMD on/off) 0.500x (50.0% faster)
Image applyMask (SIMD off) 20.000 ms
Image applyMask (SIMD on) 19.000 ms
Image applyMask ratio (SIMD on/off) 0.950x (5.0% faster)
Image modifyAlpha (SIMD off) 24.000 ms
Image modifyAlpha (SIMD on) 14.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.583x (41.7% faster)
Image modifyAlpha removeColor (SIMD off) 24.000 ms
Image modifyAlpha removeColor (SIMD on) 17.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.708x (29.2% faster)

@shai-almog

shai-almog commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Compared 368 screenshots: 368 matched.
✅ JavaScript-port screenshot tests passed.

shai-almog and others added 5 commits November 26, 2026 12:36
…droid currency

Every guide and javadoc example compiles on its own, live charts scale their text with
the slide like the painted chart, words wider than their measured box are fitted,
the presentation package gets its package-info, and the currency test asks Android
for a malformed code, since ICU accepts any well-formed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oes not decide it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from its own, current base

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In BorderLayout.CENTER the show stretched to the whole phone and centred the slide,
while the figure is cropped to the show's preferred height from its top: the three
slide figures were identical black rectangles. NORTH sizes the show to the slide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… strip's font

The renderer leaves the graphics on the last scaled slide font, so the number after a
slide of small table text was drawn a pixel high.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant