refactor: cache protobuf parser method lookup

Motivation:
Address PR review feedback that repeatedly calling MethodHandles.publicLookup() has unnecessary overhead while keeping the MethodHandle-based parser resolution behavior.

Modification:
Store a shared public Lookup for Java protobuf parser discovery and cache parser MethodHandles with a ConcurrentHashMap putIfAbsent pattern to avoid non-atomic TrieMap getOrElseUpdate lookup races.

Result:
ProtoAnySerialization reuses the public lookup and aligns parser handle caching with the existing ConsumerFilterStore MethodHandle cache style.

Tests:
- scalafmt --mode diff-ref=origin/main
- scalafmt --list --mode diff-ref=origin/main
- sbt "grpc-test / Test / testOnly org.apache.pekko.projection.grpc.internal.ProtoAnySerializationSpec"
- sbt "jdbc / Test / testOnly org.apache.pekko.projection.jdbc.JdbcProjectionTest org.apache.pekko.projection.jdbc.JdbcOffsetStoreSpec"
- sbt "jdbc / Test / testOnly org.apache.pekko.projection.jdbc.H2JdbcOffsetStoreSpec"
- sbt "jdbc-int-test / Test / testOnly org.apache.pekko.projection.jdbc.JdbcProjectionSpec"
- sbt "examples / Test / compile"
- git diff --check
- qodercli stdout review: No must-fix findings (/tmp/project-qoder-review-2.log)

References:
Refs apache/pekko-projection#561
1 file changed
tree: d0a640a0f24876f92486b45204b1bdefac22f075
  1. .github/
  2. cassandra/
  3. cassandra-test/
  4. core/
  5. core-test/
  6. docker-files/
  7. docs/
  8. durable-state/
  9. eventsourced/
  10. examples/
  11. grpc/
  12. grpc-int-test/
  13. grpc-test/
  14. integration-examples/
  15. jdbc/
  16. jdbc-int-test/
  17. kafka/
  18. kafka-test/
  19. project/
  20. r2dbc/
  21. r2dbc-int-test/
  22. scripts/
  23. slick/
  24. slick-int-test/
  25. testkit/
  26. .asf.yaml
  27. .git-blame-ignore-revs
  28. .gitignore
  29. .sbtopts
  30. .scala-steward.conf
  31. .scalafmt.conf
  32. AGENTS.md
  33. build.sbt
  34. CHANGELOG.md
  35. CLAUDE.md
  36. container-license-acceptance.txt
  37. docker-compose.yml
  38. LICENSE
  39. NOTICE
  40. README.md
README.md

Apache Pekko Projections

Apache Pekko Projections provides an abstraction for consuming a stream of Envelope (where Envelope contains a payload and a trackable offset). This streams can originate from persisted events, Kafka topics, or other Apache Pekko connectors.

Apache Pekko Projections also provides tools to track, restart and distribute these projections.

Documentation

Apache Pekko Projections are documented at https://pekko.apache.org/docs/pekko-projection/current/.

To keep up with the latest releases check out Pekko Projections releases.

Community

You can join these forums and chats to discuss and ask Pekko and Pekko connector related questions:

  • GitHub discussions: for questions and general discussion.
  • Pekko users mailing list: for Pekko usage discussions.
  • Pekko dev mailing list: for Pekko development discussions.
  • GitHub issues: for bug reports and feature requests. Please search the existing issues before creating new ones. If you are unsure whether you have found a bug, consider asking in GitHub discussions or the mailing list first.

Contributing

Contributions are very welcome. If you have an idea on how to improve Pekko, don't hesitate to create an issue or submit a pull request.

License

Apache Pekko Projections is available under the Apache License, version 2.0. See LICENSE file for details.