Skip to content

Commit

Permalink
to #77,support throw mock exception
Browse files Browse the repository at this point in the history
  • Loading branch information
flystar32 committed Mar 11, 2022
1 parent 9b3ce5c commit fa839d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
Expand Down Expand Up @@ -55,8 +56,14 @@ class AController {
@Autowired
InetUtils inetUtils;

@Value("${throwException:false}")
boolean throwException;

@GetMapping("/c")
public String c(HttpServletRequest request) {
if (throwException) {
throw new RuntimeException();
}
return "C" + SERVICE_TAG + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ public class HelloServiceCImpl implements HelloServiceC {
@Value("${rocketmq.consumer.topic}")
private String topic;


@Value("${throwException:false}")
boolean throwException;

@Override
public String hello(String name) {

if (throwException) {
throw new RuntimeException();
}

String value = "C" + SERVICE_TAG + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]";
String invokerTag="";
String userData = RpcContext.getContext().getAttachment("__microservice_tag__");
Expand Down

0 comments on commit fa839d5

Please sign in to comment.