[kotlin-client] Fix string comparison in discriminator post-processing (#21881)

We encountered occassional build failures with the logic introduced in #21531 due to discriminator properties still being generated in rare cases.
Not sure why it didn't happen consistently, may be related to Gradle caching or parallel builds or whatever.
Since patching these string comparisons, this has no longer occurred.
This commit is contained in:
Jens Fischer 2025-09-06 03:46:37 +02:00 committed by GitHub
parent 3029ac62f7
commit 29a817afdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -976,7 +976,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
continue;
}
// Remove discriminator property from the base class, it is not needed in the generated code
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name == discriminator.getPropertyName()));
getAllVarProperties(cm).forEach(list -> list.removeIf(var -> var.name.equals(discriminator.getPropertyName())));
for (CodegenDiscriminator.MappedModel mappedModel : discriminator.getMappedModels()) {
// Add the mapping name to additionalProperties.disciminatorValue
@ -989,7 +989,7 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
}
additionalProperties.discriminatorValue = mappedModel.getMappingName();
// Remove the discriminator property from the derived class, it is not needed in the generated code
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name == discriminator.getPropertyName()));
getAllVarProperties(mappedModel.getModel()).forEach(list -> list.removeIf(prop -> prop.name.equals(discriminator.getPropertyName())));
}
}