Skip to content

Conversation

piotrp
Copy link
Member

@piotrp piotrp commented Aug 4, 2025

Describe your changes

TODO: solve Jackson incompatibility by removing changes from #7066. To sum up Slack discussion:

If it's unused let's remove it

Checklist before merge

  • Related issue ID is placed at the beginning of PR title in [brackets] (can be GH issue or Nu Jira issue)
  • Code is cleaned from temporary changes and commented out lines
  • Parts of the code that are not easy to understand are documented in the code
  • Changes are covered by automated tests
  • Showcase in dev-application.conf added to demonstrate the feature
  • Documentation added or updated
  • Added entry in Changelog.md describing the change from the perspective of a public distribution user
  • Added MigrationGuide.md entry in the appropriate subcategory if introducing a breaking change
  • Verify that PR will be squashed during merge

@github-actions github-actions bot added the docs label Aug 4, 2025
@piotrp piotrp marked this pull request as ready for review August 4, 2025 12:07
// note: "" deserializes to com.fasterxml.jackson.databind.node.MissingNode,
// which causes NPE when using Jackson 2.18.3+, because from this version on it decodes to null
val schemaForPlain: OpenAPIJsonSchema = OpenAPIJsonSchema("")
val schemaForJson: OpenAPIJsonSchema = OpenAPIJsonSchema("{}")
Copy link
Contributor

@lciolecki lciolecki Aug 4, 2025

Choose a reason for hiding this comment

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

Hmm, do we even need these two schemas?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, yes:

class UniversalSchemaSupportDispatcher private (kafkaConfig: KafkaConfig) {
...
  def forParsedSchema(parsedSchema: ParsedSchema): UniversalSchemaSupport = parsedSchema match {
    // For ad hoc tests we want to present the user with json editor when topic has no schema and content type Json was selected
    case ContentTypesSchemas.schemaForJson => NoSchemaJsonSupport
    case _                                 => forSchemaType(parsedSchema.schemaType())
  }

// which causes NPE when using Jackson 2.18.3+, because from this version on it decodes to null
val schemaForPlain: OpenAPIJsonSchema = OpenAPIJsonSchema("")
val schemaForJson: OpenAPIJsonSchema = OpenAPIJsonSchema("{}")
val schemaForPlain: OpenAPIJsonSchema = OpenAPIJsonSchema("true")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure about this? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's that or some heavier refactoring. true after parsing results in the same schema: {}. An alternative would be to use {} ({} with some whitespace around) with custom equals method for OpenAPIJsonSchema.

I mention custom equals because OpenAPIJsonSchema is a fake case class - default Scala's equals for case classes doesn't work there, it's implemented like this:

  test("boxes are equal") {
    class BoxParent {
      override def equals(obj: Any): Boolean = true
      override def hashCode(): Int = 0
    }

    case class Box(v: String) extends BoxParent

    // this equality is true in Scala, but not in real world
    Box("socks") shouldBe Box("gold")
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants