Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义responseMapperFactory启动发生强转异常 #4374

Open
lingxiaod opened this issue Jun 18, 2024 · 3 comments
Open

自定义responseMapperFactory启动发生强转异常 #4374

lingxiaod opened this issue Jun 18, 2024 · 3 comments

Comments

@lingxiaod
Copy link

java.lang.IllegalStateException: ServiceComb init failed.
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType

@liubao68
Copy link
Contributor

Can you show your example code to reproduce the problem?

@lingxiaod
Copy link
Author

public class ClassA implements ProducerResponseMapperFactory {
@OverRide
public int getOrder() {
return 5000;
}

@Override
public boolean isMatch(Type producerType) {
    return true;
}

@Override
public ProducerResponseMapper createResponseMapper(ResponseMapperFactorys<ProducerResponseMapper> factorys,
    Type producerType) {
    Type type = ((ParameterizedType) producerType).getActualTypeArguments()[0];
    ProducerResponseMapper responseMapper = factorys.createResponseMapper(type);
    return new ClassB(responseMapper);
}

}

@liubao68
Copy link
Contributor

建议可以调试下 Type type = ((ParameterizedType) producerType).getActualTypeArguments()[0]; 这行代码看看 producerType , 貌似在response不是泛型的情况下,这段代码始终有问题的样子。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants