Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support decoding base64 to byte[] #524

Merged
merged 3 commits into from
Jul 20, 2023
Merged

Support decoding base64 to byte[] #524

merged 3 commits into from
Jul 20, 2023

Conversation

yawkat
Copy link
Member

@yawkat yawkat commented Jul 19, 2023

jackson-databind writes byte[] as base64 and supports reading from base64 or array. Serde 2 writes byte[] as array, but does not support reading from base64, so prior to this change we are only compatible with jackson in one direction (serde encoder -> jackson decoder).

This patch adds decode support for base64, and for the bson binary type. For oracle jdbc json, a decodeBinary method already exists.

On the encode side, there is now a config flag to use format-specific byte array encoding, which is base64 for json. The default remains to write an array of numbers.

Fixes #520

jackson-databind writes byte[] as base64 and supports reading from base64 or array. Serde 2 writes byte[] as array, but does not support reading from base64, so prior to this change we are only compatible with jackson in one direction (serde encoder -> jackson decoder).

This patch adds decode support for base64, and for the bson binary type. For oracle jdbc json, a decodeBinary method already exists.

On the encode side, there is now a config flag to use format-specific byte array encoding, which is base64 for json. The default remains to write an array of numbers.

Fixes #520
@sonarcloud
Copy link

sonarcloud bot commented Jul 19, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

60.7% 60.7% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Member

@alvarosanchez alvarosanchez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to handle empty strings as empty arrays

@yawkat yawkat merged commit 2c878ff into master Jul 20, 2023
6 of 7 checks passed
@yawkat yawkat deleted the base64-decode branch July 20, 2023 07:25
@yawkat yawkat added the type: improvement A minor improvement to an existing feature label Jul 20, 2023
yawkat added a commit to micronaut-projects/micronaut-oracle-cloud that referenced this pull request Sep 26, 2023
This enables the config option defined in micronaut-projects/micronaut-serialization#524 for the netty client.

This test case still has SerdeImports that shouldn't be necessary. This seems to be an issue with the serde upgrade, I'm looking at it.
graemerocher added a commit to micronaut-projects/micronaut-oracle-cloud that referenced this pull request Sep 28, 2023
* Use base64 for encoding byte arrays

This enables the config option defined in micronaut-projects/micronaut-serialization#524 for the netty client.

This test case still has SerdeImports that shouldn't be necessary. This seems to be an issue with the serde upgrade, I'm looking at it.

* fix serialization inclusion too

* fix broken serialization/deserialization

---------

Co-authored-by: Graeme Rocher <graeme.rocher@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deserialization of Base 64-encoded strings into byte arrays is not working
3 participants