You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/07/22 08:56:51 UTC

[GitHub] [servicecomb-java-chassis] ltp217 commented on a change in pull request #1275: [SCB-1388]test on "handler-loadbalance" project, cannot all success

ltp217 commented on a change in pull request #1275: [SCB-1388]test on "handler-loadbalance" project,cannot all success
URL: https://github.com/apache/servicecomb-java-chassis/pull/1275#discussion_r305738345
 
 

 ##########
 File path: handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
 ##########
 @@ -70,9 +72,21 @@
   @BeforeClass
   public static void beforeClass() {
     //prepare for defineEndpointAndHandle
-    ArchaiusUtils.setProperty("servicecomb.loadbalance.userDefinedEndpoint.enabled", "true");
+    try {
+    Field field = LoadbalanceHandler.class.getDeclaredField("supportDefinedEndpoint");
+    field.setAccessible(true);
+    Field modifiersField = Field.class.getDeclaredField("modifiers");
+    modifiersField.setAccessible(true);
+    int modifiers = modifiersField.getInt(field);
+    modifiers &= ~Modifier.FINAL;
+    modifiersField.setInt(field, modifiers);
+    field.set(null, true);
 
 Review comment:
   @yhs0092 yeah, int the master branch, it uses `ArchaiusUtils.setProperty("servicecomb.loadbalance.userDefinedEndpoint.enabled", "true")`.
   
   There are two test classes in the `handler-loadbalance` project, one is `TestLoadBalanceHandler`, the other is `TestLoadBalanceHandler2`.  
   
   when first execute `TestLoadBalanceHandler` , in this class, it will init the  `supportDefinedEndpoint` to `false`, after that when it execute `TestLoadBalanceHandler2`, it called `ArchaiusUtils.setProperty("servicecomb.loadbalance.userDefinedEndpoint.enabled", "true")`, however, **the `supportDefinedEndpoint` will never changed, it will be always `false`, because of this attribute is `final static`**, after that the test case in `TestLoadBalanceHandler2` may have some exceptions.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services