Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1391

Generated Kotlin PropertyAccessor uses wrong copy method

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1 RC2 (Lovelace)
    • Fix Version/s: 2.1 GA (Lovelace)
    • Component/s: Mapping / Conversion
    • Labels:
      None
    • Environment:
      jdk 1.8.0_144
      kotlin 1.2.0

      Description

      Given (in kotlin):

      @Document(collection = "catalogue.CatalogueTags")
      data class CatalogueTags internal constructor(
              @Id val id: ObjectId = ObjectId.get(),
              @Version val version: Int? = null,
              val shop: Shop,
      ...
             val activeInCatalogue: DateTimeRange = DateTimeRange()
      ) : CatalogueData<CatalogueTags>() {
          override fun copy(newActiveInCatalogue: DateTimeRange) = copy(activeInCatalogue = newActiveInCatalogue)
      }
      
      @Repository
      interface CatalogueTagsRepository : RxJava2CrudRepository<CatalogueTags, ObjectId>  

      When:

      class MyTest : CatalogueBaseComponentTest() {
      
          @Autowired
          lateinit var repo: CatalogueTagsRepository
      
          @Test
          fun save() {
              val some = some<CatalogueTags>()
              val saved = repo.save(some).blockingGet()
          }
      } 

      Then:

      java.lang.ClassCastException: java.lang.Integer cannot be cast to com.ocado.gembus.hub.commons.vos.DateTimeRange
      
      at com.ocado.gembus.hub.catalogue.test.CatalogueTags_Accessor_jcjqjz.setProperty(Unknown Source)
      at org.springframework.data.mapping.model.ConvertingPropertyAccessor.setProperty(ConvertingPropertyAccessor.java:61)
      at org.springframework.data.mongodb.core.EntityOperations$AdaptibleMappedEntity.incrementVersion(EntityOperations.java:650)
      at org.springframework.data.mongodb.core.ReactiveMongoTemplate.lambda$doSaveVersioned${color:#6897bb}33(ReactiveMongoTemplate.java:1407)
      at org.springframework.data.mongodb.core.ReactiveMongoTemplate.lambda$createMono${color:#6897bb}8(ReactiveMongoTemplate.java:599)
      at reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:141)
      at reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:53)
      at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
      at reactor.core.publisher.Mono.subscribe(Mono.java:3080)
      at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
      at io.reactivex.Flowable.subscribe(Flowable.java:12995)
      at io.reactivex.Flowable.subscribe(Flowable.java:12941)
      at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
      at io.reactivex.Observable.subscribe(Observable.java:10903)
      at io.reactivex.internal.operators.observable.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:30)
      at io.reactivex.Maybe.subscribe(Maybe.java:3730)
      at io.reactivex.internal.operators.maybe.MaybeToSingle.subscribeActual(MaybeToSingle.java:46)
      at io.reactivex.Single.subscribe(Single.java:2700)
      at io.reactivex.Single.blockingGet(Single.java:2153)
      at com.ocado.gembus.hub.catalogue.test.MyTest.save(CatalogueTags.kt:54)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.junit.runners.model.FrameworkMethod${color:#6897bb}1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      

        Attachments

          Activity

            People

            • Assignee:
              mp911de Mark Paluch
              Reporter:
              marianjureczko Marian Jureczko
              Last updater:
              Mark Paluch
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: