Skip to content

Interceptors without a tag intercept classes with tags. #752

Description

@jukmacbook

Kora version:

  • 1.2.18

Java or Kotlin and KSP version:

  • Java 17

Lombok usage:

  • Yes/No

Описание проблемы / Describe the bug:

Interceptors without a tag intercept classes with tags.

When connecting two PostgreSQL databases, issues arise when writing a custom Flyway module for migrations. Repositories without a tag use the Flyway instance without a tag as interceptors. However, repositories with a tag pick up both Flyway instances - the one with a tag and the one without.

Текущее поведение / Current behavior:

Flyway module

interface FlywayModule {
  fun flywayUntagged(config: Config, extractor: ConfigValueExtractor<FlywayConfig?>): FlywayConfig {
    val value = config.get("flyway")
    return extractor.extract(value)!!
  }

  fun flywayUntaggedInterceptor(flywayConfig: FlywayConfig?): FlywayJdbcDatabaseInterceptor {
    return FlywayJdbcDatabaseInterceptor(flywayConfig)
  }

  @Tag(SomeTag::class)
  fun flywayTaggedConfig(config: Config, extractor: ConfigValueExtractor<FlywayConfig?>): FlywayConfig {
    val value = config.get("migration-flyway")
    return extractor.extract(value)!!
  }

  @Tag(SomeTag::class)
  fun flywayTaggedInterceptor(
    @Tag(SomeTag::class) flywayConfig: FlywayConfig?
  ): FlywayJdbcDatabaseInterceptor {
    return FlywayJdbcDatabaseInterceptor(flywayConfig)
  }
}

Repository with tag

@Repository(executorTag = Tag(SomeTag::class))
interface TaggedRepository : JdbcRepository

Graph:

component284 = graphDraw.addNode0(map["component284"], 
        arrayOf(SomeTag::class.java,
            ),
        { impl.jdbcTaggedDataBase(
          it.get(holder0.component283),
          it.get(holder0.component87),
          null as Executor?
        ) },
        listOf(component127, component129), //component127 - flywayUntaggedInterceptor, component129 - flywayTaggedInterceptor
        component283, component87
      )

Ожидаемое поведение / Expected behavior:

Tagged components must contain only tagged interceptors with the same tag as the component.

Graph:

component284 = graphDraw.addNode0(map["component284"], 
        arrayOf(SomeTag::class.java,
            ),
        { impl.jdbcTaggedDataBase(
          it.get(holder0.component283),
          it.get(holder0.component87),
          null as Executor?
        ) },
        listOf(component129), //component129 - flywayTaggedInterceptor only
        component283, component87
      )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodule: coreCore framework modules

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions