dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhangfei9734 (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] zhangfei9734 opened issue #3587: Not compatible with Kotlin's unchecked exception?
Date Fri, 01 Mar 2019 12:23:43 GMT
### 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](https://user-images.githubusercontent.com/16345433/53637218-8d31ff80-3c5d-11e9-8005-1151c3b4cde1.png)
2. 由于Kotlin中没有受检的异常

```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
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.


[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3587 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
Mime
View raw message