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 06:49:03 UTC

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

yhs0092 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_r305693536
 
 

 ##########
 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:
   Hello, maybe it's better to set field `supportDefinedEndpoint` by `ArchaiusUtils.setProperty("servicecomb.loadbalance.userDefinedEndpoint.enabled", "true")` instead of reflection, since changing field by reflection makes the UT cannot cover the related configuration, and may cause other side effect.

----------------------------------------------------------------
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