Skip to content

refactor that decouples opa-evaluator from Jackson - #21

Merged
sspaink merged 3 commits into
open-policy-agent:mainfrom
sspaink:separatejackson
May 20, 2026
Merged

refactor that decouples opa-evaluator from Jackson#21
sspaink merged 3 commits into
open-policy-agent:mainfrom
sspaink:separatejackson

Conversation

@sspaink

@sspaink sspaink commented May 18, 2026

Copy link
Copy Markdown
Member

resolve: #11

@sspaink
sspaink marked this pull request as ready for review May 19, 2026 00:05

@johanfylling johanfylling left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not as horrible to review as the line-count would suggest 😅

Comment thread opa-evaluator/build.gradle.kts Outdated
Comment thread opa-evaluator/build.gradle.kts
}

@Override
public boolean isJsonCreator(Constructor<?> ctor) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if not some of these methods are very jackson-specific. We should add a opa-gson module to see if the interface needs generalization.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

cdd5567

Yes it does seem very Jackson specific... could make it more abstract

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

At least we got the dependency tree restructured. We can follow this up in a later PR. Don't need to be precious about breaking changes this early on.

implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
// RegoValueModule (auto-registered via Jackson SPI) provides (de)serializers for the AST
// types so they don't need to carry annotations.
runtimeOnly(project(":opa-jackson"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this?

JSON_MAPPER = new ObjectMapper();
// findAndRegisterModules picks up RegoValueModule (from opa-jackson) via SPI so
// RegoString/RegoArray/RegoObject etc. (de)serialize without annotations on the AST types.
JSON_MAPPER = new ObjectMapper().findAndRegisterModules();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if it'd be possible to add a simple serialize/deserialize SPI to cover all of the explicit jackson dependencies, or if there are things in here that need that strict coupling?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There does seem to be some strict coupling, so this won't be straight forward change. Maybe a separate PR?

private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
// Auto-register RegoValueModule (and any other Jackson modules on the classpath) via SPI so
// RegoObject (de)serialization works without the AST types carrying Jackson annotations.
private static final ObjectMapper JSON_MAPPER = new ObjectMapper().findAndRegisterModules();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be nice if we didn't have this explicit Jackson dependency here, and could just SPI-ify it.

@sspaink
sspaink force-pushed the separatejackson branch from a34407c to 5e0b6ca Compare May 19, 2026 18:07
sspaink added 2 commits May 19, 2026 13:08
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink force-pushed the separatejackson branch from 5e0b6ca to a70fb8c Compare May 19, 2026 18:08
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@sspaink
sspaink force-pushed the separatejackson branch from cdd5567 to 12cda24 Compare May 19, 2026 18:33
@sspaink
sspaink merged commit 8cab050 into open-policy-agent:main May 20, 2026
9 checks passed
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.

Remove Jackson dependency requirement from opa-evaluator lib

2 participants