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

Try to add an element to Arrays.ArrayList in convertProtocolIdsToProtocols method. #3841

Closed
GeekDaniel opened this issue Apr 10, 2019 · 4 comments
Labels
help wanted Everything needs help from contributors
Milestone

Comments

@GeekDaniel
Copy link

GeekDaniel commented Apr 10, 2019

Environment

  • Dubbo version: 2.7.0
  • Java version: 8
  • spring version :4.1.6.RELEASE
  • dependency details you might concern :
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ demo ---
[INFO] com.surpass:demo:jar:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-jdbc:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-tx:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.1.6.RELEASE:compile
[INFO] +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO] +- com.github.sgroschupf:zkclient:jar:0.9:compile
[INFO] |  \- org.apache.zookeeper:zookeeper:jar:3.4.8:compile
[INFO] |     +- jline:jline:jar:0.9.94:compile
[INFO] |     \- io.netty:netty:jar:3.7.0.Final:compile
[INFO] +- org.apache.dubbo:dubbo:jar:2.7.0:compile
[INFO] |  +- io.netty:netty-all:jar:4.1.25.Final:compile
[INFO] |  \- com.google.code.gson:gson:jar:2.8.5:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
[INFO] +- org.jboss.resteasy:resteasy-jaxrs:jar:3.0.7.Final:compile
[INFO] |  +- org.jboss.resteasy:jaxrs-api:jar:3.0.7.Final:compile
[INFO] |  +- org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] |  +- javax.activation:activation:jar:1.1:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.2.1:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  +- commons-io:commons-io:jar:2.1:compile
[INFO] |  \- net.jcip:jcip-annotations:jar:1.0:compile
[INFO] +- org.jboss.resteasy:resteasy-client:jar:3.0.7.Final:compile
[INFO] +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] |  \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.4:compile
[INFO] +- org.springframework:spring-context:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.1.6.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-beans:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-expression:jar:4.1.6.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.1.6.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- com.sun:tools:jar:1.8:system
[INFO] +- commons-net:commons-net:jar:3.3:compile
[INFO] +- com.opencsv:opencsv:jar:4.0:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.6:compile
[INFO] |  +- org.apache.commons:commons-text:jar:1.1:compile
[INFO] |  \- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |     \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] +- com.github.nintha:webp-imageio-core:jar:0.1.1:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] +- org.apache.curator:curator-framework:jar:4.0.0:compile
[INFO] +- org.apache.curator:curator-client:jar:4.0.0:compile
[INFO] |  \- com.google.guava:guava:jar:20.0:compile
[INFO] \- org.apache.curator:curator-recipes:jar:4.0.0:compile

reproduce demo address : https://github.com/GeekDaniel/issuedemo.git

core config about dubbo

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://code.alibabatech.com/schema/dubbo
       http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
       <dubbo:application name="demo" />

       <!--zookeeper注册中心 -->
       <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"/>

        <!-- 用于心跳配置 -->
       <dubbo:protocol name="rest" port="20881" />
       <dubbo:service interface="com.surpass.service.HeartBeat" ref="heartBeatImpl" protocol="rest"/>

       <!-- 具体服务配置 -->
       <dubbo:protocol name="dubbo" port="20880"/>
       <dubbo:provider filter="DoNoneFilter" protocol="dubbo" />

       <dubbo:service interface="com.surpass.service.CounterService" ref="counterServiceImpl" version="1.0.0"/>

</beans>

Expected Result

dubbo can do multi protocols service export

Actual Result

multi protocols service export failed when use Filter.

Exception track

Exception in thread "main" java.lang.UnsupportedOperationException
	at java.util.AbstractList.add(AbstractList.java:148)
	at java.util.AbstractList.add(AbstractList.java:108)
	at org.apache.dubbo.config.ServiceConfig.lambda$convertProtocolIdsToProtocols$4(ServiceConfig.java:839)
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at org.apache.dubbo.config.ServiceConfig.convertProtocolIdsToProtocols(ServiceConfig.java:837)
	at org.apache.dubbo.config.ServiceConfig.checkProtocol(ServiceConfig.java:808)
	at org.apache.dubbo.config.ServiceConfig.checkAndUpdateSubConfigs(ServiceConfig.java:271)
	at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:328)
	at org.apache.dubbo.config.spring.ServiceBean.export(ServiceBean.java:318)
	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:112)
	at org.apache.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:58)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
	at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
	at com.surpass.exec.Server.main(Server.java:29)
@carryxyh
Copy link
Member

Thx for your issue.
It will be fixed at next release.

@carryxyh carryxyh added this to the 2.7.2 milestone Apr 10, 2019
@carryxyh carryxyh added good first issue help wanted Everything needs help from contributors labels Apr 10, 2019
@carryxyh
Copy link
Member

We should avoid using Arrays.asList. It most like a unmodified list. So add operation will throw exception.

See java.util.Arrays.ArrayList for more details.

@Moriadry-zz
Copy link

Hi @carryxyh I would like to try this as my first PR, if it seems like a good starting point. Can I ?

@kezhenxu94
Copy link
Member

HI @moriadry , contributions are always welcome, and since this is not taken by (assigned to) any committer, feel free to send a pull request to fix it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Everything needs help from contributors
Projects
None yet
Development

No branches or pull requests

5 participants