Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15055

AutoProxyRegistrar throws NullPointer on @kotlin.Metadata Annotation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.3.5, 5.0 M3
    • Fix Version/s: 4.3.6, 5.0 M4
    • Component/s: None
    • Labels:

      Description

      When using a simple spring boot application with both mixed Java And Kotlin files
      The Kotlin Plugin seems to introduce a new Annotation for some classes. "@kotlin.Metadata"

      When starting the Spring Boot Project the AutoProxyRegistrar.java#L63 is not able to resolve the
      annotation metadata and will throw a NullPointerException.
      In my case, this only happens when i use the @EnableCaching Annotation (i think when not using it, the AutoProxyRegistrar class is not invoked)

      1. Repository For This is here
        https://github.com/spring-projects/spring-framework-issues/pull/145

      Only those two classes and a single dependency is needed to reproduce this issue

      CacheConfiguration.kt

      @EnableCaching
      @Configuration
      open class CacheConfiguration {
          //this can be empty. when removing the @EnableCaching Annotation everything works
      }
      

      Application.java

      @SpringBootApplication
      public class Application {
       
          public static void main(String[] args) {
              SpringApplication.run(Application.class, args);
          }
      }
      

      build.gradle

      group = 'org.springframework.issues'
      version = '1.0.0.SNAPSHOT'
       
      buildscript {
          ext {
              kotlin_version = '1.0.5-2'
              springBootVersion = '1.4.3.RELEASE'
          }
          repositories {
              jcenter()
              mavenCentral()
          }
          dependencies {
              classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
              classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
          }
      }
       
      apply plugin: 'java'
      apply plugin: 'eclipse'
      apply plugin: 'kotlin'
      apply plugin: 'org.springframework.boot'
      apply plugin: 'idea'
       
      repositories {
          maven { url 'http://repo.spring.io/snapshot' }
          mavenCentral()
      }
       
      dependencies {
          compile(group: 'org.springframework.boot', name: 'spring-boot-starter')
      }
       
      [compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all']
       
      sourceCompatibility = 1.8
      targetCompatibility = 1.8
      

      P.S. I am sorry if this is more are Spring-Boot and not Spring Framework issue. It was not clear for me where I should report this issue.

        Activity

        Hide
        sdeleuze Sébastien Deleuze added a comment -

        Good catch, fixed on master and 4.3.x branches via this change.

        Show
        sdeleuze Sébastien Deleuze added a comment - Good catch, fixed on master and 4.3.x branches via this change .
        Hide
        MarvinSchramm Marvin Schramm added a comment -

        Nice! Thank you!

        Show
        MarvinSchramm Marvin Schramm added a comment - Nice! Thank you!

          People

          • Assignee:
            sdeleuze Sébastien Deleuze
            Reporter:
            MarvinSchramm Marvin Schramm
            Last updater:
            Stéphane Nicoll
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              47 weeks, 1 day ago