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

make protocols a mutable list (a concrete ArrayList) #3869

Merged
merged 2 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.rpc.ExporterListener;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -210,7 +211,7 @@ public ProtocolConfig getProtocol() {
}

public void setProtocol(ProtocolConfig protocol) {
setProtocols(Arrays.asList(protocol));
setProtocols(new ArrayList<>(Arrays.asList(protocol)));
}

@Parameter(excluded = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.dubbo.remoting.exchange.Exchanger;
import org.apache.dubbo.remoting.telnet.TelnetHandler;

import java.util.ArrayList;
import java.util.Arrays;

/**
Expand Down Expand Up @@ -157,7 +158,7 @@ public class ProviderConfig extends AbstractServiceConfig {

@Deprecated
public void setProtocol(String protocol) {
this.protocols = Arrays.asList(new ProtocolConfig[]{new ProtocolConfig(protocol)});
this.protocols = new ArrayList<>(Arrays.asList(new ProtocolConfig(protocol)));
}

@Parameter(excluded = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ private void convertProtocolIdsToProtocols() {
.orElseGet(() -> {
ProtocolConfig protocolConfig = new ProtocolConfig();
protocolConfig.refresh();
return Arrays.asList(protocolConfig);
return new ArrayList<>(Arrays.asList(protocolConfig));
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -110,7 +111,7 @@ public void testProtocol() throws Exception {
assertThat(serviceConfig.getProtocol(), nullValue());
serviceConfig.setProtocol(new ProtocolConfig());
assertThat(serviceConfig.getProtocol(), notNullValue());
serviceConfig.setProtocols(Collections.singletonList(new ProtocolConfig()));
serviceConfig.setProtocols(new ArrayList<>(Collections.singletonList(new ProtocolConfig())));
assertThat(serviceConfig.getProtocols(), hasSize(1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.dubbo.config.api.DemoService;
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;

import java.util.ArrayList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.fail;
Expand Down Expand Up @@ -154,8 +155,8 @@ protected void initServConf() {
provConf.setRegistry(regConfForProvider);
servConf.setRegistry(regConfForService);

provConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForProvider}));
servConf.setProtocols(Arrays.asList(new ProtocolConfig[]{protoConfForService}));
provConf.setProtocols(new ArrayList<>(Arrays.asList(protoConfForProvider)));
servConf.setProtocols(new ArrayList<>(Arrays.asList(protoConfForService)));

servConf.setMethods(Arrays.asList(new MethodConfig[]{methodConfForService}));
servConf.setProvider(provConf);
Expand Down