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

RepositoryMetadata.getReturnedDomainClass(...) returns Object for suspended methods

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3 RC1 (Neumann)
    • Component/s: Query
    • Labels:
      None
    • Sprint:
      Neumann RC1

      Description

      Calling getReturnedDomainClass(…) for suspended Kotlin method returns Object.class instead of the actual type.

      Kotlin compiles the given interface:

      	interface MyCoRepository : CoroutineCrudRepository<User, String> {
      
      		suspend fun findOne(id: String): User
      
      		suspend fun findOneOptional(id: String): User?
      
      		fun findMultiple(id: String): Flow<User>
      
      		suspend fun findMultipleSuspended(id: String): Flow<User>
      	}
      

      into the following bytecode:

        @Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\000\032\n\002\030\002\n\002\030\002\n\002\030\002\n\002\020\016\n\000\n\002\030\002\n\002\b\006\bf\030\0002\016\022\004\022\0020\002\022\004\022\0020\0030\001J\026\020\004\032\b\022\004\022\0020\0020\0052\006\020\006\032\0020\003H&J\037\020\007\032\b\022\004\022\0020\0020\0052\006\020\006\032\0020\003H\001\000\006\002\020\bJ\031\020\t\032\0020\0022\006\020\006\032\0020\003H\001\000\006\002\020\bJ\033\020\n\032\004\030\0010\0022\006\020\006\032\0020\003H\001\000\006\002\020\b\002\004\n\002\b\031\006\013"}, d2 = {"Lorg/springframework/data/repository/kotlin/CoroutineRepositoryMetadataUnitTests$MyCoRepository;", "Lorg/springframework/data/repository/kotlin/CoroutineCrudRepository;", "Lorg/springframework/data/repository/sample/User;", "", "findMultiple", "Lkotlinx/coroutines/flow/Flow;", "id", "findMultiple1", "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "findOne", "findOneOptional", "spring-data-commons"})
        public static interface MyCoRepository extends CoroutineCrudRepository<User, String> {
          @Nullable
          Object findOne(@NotNull String param1String, @NotNull Continuation<? super User> param1Continuation);
          
          @Nullable
          Object findOneOptional(@NotNull String param1String, @NotNull Continuation<? super User> param1Continuation);
          
          @NotNull
          Flow<User> findMultiple(@NotNull String param1String);
          
          @Nullable
          Object findMultiple1(@NotNull String param1String, @NotNull Continuation<? super Flow<? extends User>> param1Continuation);
        }
      

      The compiled methods return Object in their return type. The actual type is preserved in the Continuation parameter.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              mp911de Mark Paluch
              Last updater:
              Mark Paluch
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: