Skip to content

PHOENIX-8072 Do not relocate or bundle org.bson in the shaded client jars - #2701

Open
apurtell wants to merge 1 commit into
apache:masterfrom
apurtell:PHOENIX-8072
Open

apurtell wants to merge 1 commit into
apache:masterfrom
apurtell:PHOENIX-8072

Conversation

@apurtell

@apurtell apurtell commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

BSON columns expose org.bson types directly through the JDBC API, whereas phoenix-client-embedded and phoenix-client-lite relocate the org.bson package into the shaded Phoenix namespace. This package relocation breaks class identity across the JDBC boundary, preventing applications from binding or reading BSON documents as typed objects. To preserve type compatibility between application code and the JDBC driver, org.bson must remain unrelocated and unbundled in the shaded client artifacts, following the same packaging model established for io.opentelemetry in the PHOENIX-5215 addendum.

Packaging changes:

  • Exclude org/bson/** from package relocation in phoenix-client-parent so phoenix-client-embedded and phoenix-client-lite reference canonical org.bson classes.
  • Exclude org.mongodb:bson from shading in phoenix-client-embedded and phoenix-client-lite so it is exposed as a transitive compile dependency and shared with the application classpath. Include the bson jar in the assembly lib directory and add it to the runtime classpath in the bin scripts.
  • Retain org.bson relocation and bundling in phoenix-server, which operates purely on serialized BSON byte payloads over RPC, and in phoenix-mapreduce-byo-shaded-hbase, where hbase mapredcp does not supply org.mongodb:bson.

…jars

BSON columns exchange org.bson types directly through the JDBC API:
PreparedStatement.setObject accepts org.bson.BsonDocument and
ResultSet.getObject returns org.bson.RawBsonDocument. Because the shaded
client jars relocated org.bson under org.apache.phoenix.shaded.org,
application BsonDocument instances failed driver type checks and returned
documents could not be cast to org.bson types by calling code, leaving
only string-based JSON access via setString and getString functional.

Packaging changes:
- Exclude org/bson/** from package relocation in phoenix-client-parent so
  phoenix-client-embedded and phoenix-client-lite reference canonical
  org.bson classes.
- Exclude org.mongodb:bson from shading in phoenix-client-embedded and
  phoenix-client-lite so it is exposed as a transitive compile dependency
  and shared with the application classpath. Include the bson jar in the
  assembly lib directory and add it to the runtime classpath in the bin
  scripts.
- Retain org.bson relocation and bundling in phoenix-server, which
  operates purely on serialized BSON byte payloads over RPC, and in
  phoenix-mapreduce-byo-shaded-hbase, where hbase mapredcp does not
  supply org.mongodb:bson.
@apurtell
apurtell requested a review from virajjasani November 22, 2026 06:25
@apurtell

apurtell commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@virajjasani Please review this when you have some time.

BSON types returned by the JDBC API when someone consumes the shaded clients do not work as expected. It is basically not possible to shade org.bson.* so an alternative means of integrating this support on the client side is required. I propose to do it like we are currently integrating opentelemetry (only on master, only after PHOENIX-5215, so subject to revision)

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.

2 participants