inconsistent stack height -1 错误解决方案

异常如下:
java.lang.RuntimeException: [source error] getPropertyValue (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object; in org.apache.dubbo.common.bytecode.Wrapper0: inconsistent stack height -1
at org.apache.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:348) ~[dubbo-2.7.6.jar:2.7.6]
at org.apache.dubbo.common.bytecode.ClassGenerator.toClass(ClassGenerator.java:287) ~[dubbo-2.7.6.jar:2.7.6]
at org.apache.dubbo.common.bytecode.Wrapper.makeWrapper(Wrapper.java:256) ~[dubbo-2.7.6.jar:2.7.6]
at org.apache.dubbo.common.bytecode.Wrapper.lambda$getWrapper 0 ( W r a p p e r . j a v a : 116 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t j a v a . u t i l . c o n c u r r e n t . C o n c u r r e n t H a s h M a p . c o m p u t e I f A b s e n t ( C o n c u r r e n t H a s h M a p . j a v a : 1660 )   [ n a : 1.8. 0 9 2 ] a t o r g . a p a c h e . d u b b o . c o m m o n . b y t e c o d e . W r a p p e r . g e t W r a p p e r ( W r a p p e r . j a v a : 116 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t o r g . a p a c h e . d u b b o . c o n f i g . S e r v i c e C o n f i g . d o E x p o r t U r l s F o r 1 P r o t o c o l ( S e r v i c e C o n f i g . j a v a : 416 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t o r g . a p a c h e . d u b b o . c o n f i g . S e r v i c e C o n f i g . d o E x p o r t U r l s ( S e r v i c e C o n f i g . j a v a : 325 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t o r g . a p a c h e . d u b b o . c o n f i g . S e r v i c e C o n f i g . d o E x p o r t ( S e r v i c e C o n f i g . j a v a : 300 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t o r g . a p a c h e . d u b b o . c o n f i g . S e r v i c e C o n f i g . e x p o r t ( S e r v i c e C o n f i g . j a v a : 206 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t o r g . a p a c h e . d u b b o . c o n f i g . b o o t s t r a p . D u b b o B o o t s t r a p . l a m b d a 0(Wrapper.java:116) ~[dubbo-2.7.6.jar:2.7.6] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_92] at org.apache.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:116) ~[dubbo-2.7.6.jar:2.7.6] at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:416) ~[dubbo-2.7.6.jar:2.7.6] at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325) ~[dubbo-2.7.6.jar:2.7.6] at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300) ~[dubbo-2.7.6.jar:2.7.6] at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206) ~[dubbo-2.7.6.jar:2.7.6] at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda 0(Wrapper.java:116) [dubbo2.7.6.jar:2.7.6]atjava.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) [na:1.8.092]atorg.apache.dubbo.common.bytecode.Wrapper.getWrapper(Wrapper.java:116) [dubbo2.7.6.jar:2.7.6]atorg.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:416) [dubbo2.7.6.jar:2.7.6]atorg.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325) [dubbo2.7.6.jar:2.7.6]atorg.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300) [dubbo2.7.6.jar:2.7.6]atorg.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206) [dubbo2.7.6.jar:2.7.6]atorg.apache.dubbo.config.bootstrap.DubboBootstrap.lambdaexportServices 15 ( D u b b o B o o t s t r a p . j a v a : 917 )   [ d u b b o − 2.7.6. j a r : 2.7.6 ] a t j a v a . u t i l . H a s h M a p 15(DubboBootstrap.java:917) ~[dubbo-2.7.6.jar:2.7.6] at java.util.HashMap 15(DubboBootstrap.java:917) [dubbo2.7.6.jar:2.7.6]atjava.util.HashMapValues.forEach(HashMap.java:980) ~[na:1.8.0_92]

由于在添加接口之前,一切都是正常的,因此可以排除 dubbo 版本问题,在网上查找资料说可能是由于提供的接口以 getXXX 开头,而且接口没有返回值,从而出现此种异常。因此试着先把问题给解决了,就按文章说的,把接口名称给改了,不以 get 开头,经验证,确实是此原因。那么为什么会有这么奇怪的现象出现呢?查看了下 dubbo 源码,dubbo 动态生成代码

 return ($w) w.getFilterRuleToRedis()

出现了问题。这是因为这样的方法,dubbo 暴露服务的时候把它当成获取属性方法来编译,然后出现类型转化报错。
参考链接:https://blog.csdn.net/henlf/article/details/81674517

你可能感兴趣的:(Java)