OpenRTB: Allow model inheritance from external packages - #4627
Open
pavel-ptashyts wants to merge 1 commit into
Open
OpenRTB: Allow model inheritance from external packages#4627pavel-ptashyts wants to merge 1 commit into
pavel-ptashyts wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
When using Prebid Server Java as a JAR dependency, an application may reuse bidder adapters while keeping its own request and response representation. The adapter APIs accept concrete OpenRTB classes, so an unrelated wrapper cannot be passed to them. Most of these models are final and have package-private or private constructors, which prevents application-defined subclasses outside the model package.
This change allows those applications to extend the request and response models, including their nested OpenRTB and Native Ads objects, without maintaining a fork just to change class and constructor visibility. For example, an integration can attach local context to a response or define application-specific behavior in a subtype accepted by the existing APIs.
🧠 Rationale behind the change
Use
@NonFinalon value classes and protected all-arguments constructors where constructors were inaccessible to external subclasses. Existing fields, builders and wire properties are retained. TheSupplyChain,SupplyChainNodeandLinkfactories remain available as explicitof(...)methods;BrandVersionkeeps its existing public constructor.Nativeis already extensible and does not need a change.This is a limited first step toward supporting external integrations. It does not implement lazy conversion, change tracking or builder inheritance, and does not claim an allocation reduction on its own. The developer note describes the boundaries around
toBuilder(), equality and serialization. Inherited value fields remain private and final; applications are responsible for the behavior and state ownership of their subclasses. Subclass constructors may need updating as model fields evolve.An alternative would be to migrate the other models to
@SuperBuilder, following the existingNativeimplementation. That could provide a more complete foundation for inheritance with builders, but it is a broader change that needs additional implementation time and compatibility testing of the generated builder API. If maintainers prefer that direction, I am happy to follow up with a@SuperBuildermigration.🧪 Test plan
mvn -B -Dtest=OpenRtbModelInheritanceTest testpasses on JDK 25, including Checkstyle and compilation of production and test sources. The seven tests cover external-package request/response subclasses, equality, JSON round trips,toBuilder(), mutable native response models, retained factories and the publicBrandVersionconstructor.mvn -B testrun: 8,785 tests, three failures inUidsCookieServiceTest(the same three tests also fail on the unchanged baseline), two skipped, and one environment-relatedSanityTesterror because/var/tmp/vendor2was not writable.SanityTestpasses when rerun with vendor cache paths undertargetvia system properties.🏎 Quality check
The project's JaCoCo configuration excludes
com/iab/openrtb/**, so no coverage percentage is claimed for these models. The retained explicit factory methods are exercised by the regression tests.