File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
main/java/com/tencent/trpc/core/common/config
test/java/com/tencent/trpc/core/common/config Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ public class ProtocolConfig extends BaseProtocolConfig implements Cloneable {
4848 protected volatile boolean setDefault = false ;
4949 protected volatile boolean inited = false ;
5050
51+ protected ServiceConfig serviceConfig ;
52+
5153 public static ProtocolConfig newInstance () {
5254 return new ProtocolConfig ();
5355 }
@@ -244,4 +246,13 @@ public boolean isInited() {
244246 return inited ;
245247 }
246248
249+ public ServiceConfig getServiceConfig () {
250+ return serviceConfig ;
251+ }
252+
253+ public void setServiceConfig (ServiceConfig serviceConfig ) {
254+ checkFiledModifyPrivilege ();
255+ this .serviceConfig = serviceConfig ;
256+ }
257+
247258}
Original file line number Diff line number Diff line change @@ -402,6 +402,7 @@ protected ProtocolConfig buildProtocolConfig() {
402402 tempProtocolConfig .setReusePort (this .getReusePort ());
403403 tempProtocolConfig .setSign (this .getSign ());
404404 tempProtocolConfig .setDefault ();
405+ tempProtocolConfig .setServiceConfig (this );
405406 return tempProtocolConfig ;
406407 }
407408
Original file line number Diff line number Diff line change 1414import static org .junit .Assert .assertEquals ;
1515import static org .junit .Assert .assertFalse ;
1616import static org .junit .Assert .assertNotNull ;
17+ import static org .junit .Assert .assertSame ;
1718import static org .junit .Assert .assertTrue ;
1819
1920import com .google .common .collect .ImmutableMap ;
@@ -90,6 +91,8 @@ public void testConfig() {
9091 config .setExplicitFlushAfterFlushes (1024 );
9192 config .setCompressMinBytes (10 );
9293 config .setDefault ();
94+ ServiceConfig serviceConfig = new ServiceConfig ();
95+ config .setServiceConfig (serviceConfig );
9396 assertEquals ("127.1.1.1" , config .getIp ());
9497 assertEquals ("" , config .getName ());
9598 assertEquals (8080 , config .getPort ());
@@ -124,5 +127,6 @@ public void testConfig() {
124127 assertFalse (config .useEpoll ());
125128 assertEquals (10 , config .getCompressMinBytes ());
126129 assertTrue (config .isSetDefault ());
130+ assertSame (serviceConfig , config .getServiceConfig ());
127131 }
128132}
You can’t perform that action at this time.
0 commit comments