dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Not compatible with Kotlin's unchecked exception?

Open feixz opened this issue 7 years ago • 1 comments

Environment

  • Dubbo version: xxx
  • Operating System version: Mac OS X 10.14.3
  • Java version: 1.8.0_202

Steps to reproduce this issue

  1. Kotlin integrated dubbo provider throws custom exceptions image
  2. 由于Kotlin中没有受检的异常
// provider impl
fun createUser(user: User):User {
  // ...
  if(user.exited) {
    throws CustomException("user exited")
  }
  // ...
}

// consumer
try {
   userService.createUser(user)
} catch (ex: Exception) {
  logger.debug(ex) { "${ex.javaClass}" } // expected CustomException,actual UndeclaredThrowableException
}
java.lang.reflect.UndeclaredThrowableException: null
	at com.sun.proxy.$Proxy120.signup(Unknown Source) ~[na:na]

Since I am using kotlin, all can't declare an exception on the interface method like java. I tried kotlin to call java method and declare @Thtows(CustomException::class), this can't solve my problem.

feixz avatar Mar 01 '19 12:03 feixz

It's an issue on Dubbo 2.6.5, please wait for 2.6.6 release to resolve this problem.

mercyblitz avatar Mar 04 '19 03:03 mercyblitz