Skip to content

Support recursive types in parameterized records #1007

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

Merged
merged 12 commits into from
Oct 15, 2022
Prev Previous commit
Next Next commit
Fix NPE
  • Loading branch information
jyemin committed Oct 15, 2022
commit 3303b8bb1cec385550cd995e35c4ad4499c479e3
2 changes: 1 addition & 1 deletion bson/src/main/org/bson/internal/ChildCodecRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public <U> Codec<U> get(final Class<U> clazz) {
if (hasCycles(clazz)) {
return new LazyCodec<U>(registry, clazz, types);
} else {
return registry.get(new ChildCodecRegistry<>(this, clazz, null));
return registry.get(new ChildCodecRegistry<>(this, clazz, Collections.emptyList()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public <T> Codec<T> get(final ChildCodecRegistry<T> context) {
for (CodecProvider provider : codecProviders) {
Codec<T> codec = provider.get(context.getCodecClass(), context);
if (codec != null) {
if (codec instanceof Parameterizable && context.getTypes() != null) {
if (codec instanceof Parameterizable && !context.getTypes().isEmpty()) {
codec = (Codec<T>) ((Parameterizable) codec).parameterize(context, context.getTypes());
}
return codecCache.putIfMissing(codecCacheKey, codec);
Expand Down