# blade create jvm return

## 介绍

指定类方法的返回值，仅支持基本类型、null 和 String 类型的返回值。

## 参数

以下是此场景特有参数，通用参数详见：\[blade create jvm]\(blade create jvm.md)

```
--effect-count string     影响的请求条数
--effect-percent string   影响的请求百分比
--value string     返回指定值，仅支持基本类型和字符串类型，如果想返回 null，可以设置为 --value null 。必选项
```

## 案例

指定com.example.controller.DubboController类，下面业务方法返回 "hello-chaosblade"

```
@RequestMapping(value = "hello")
@ResponseBody
public String hello(String name, int code) {
    if (name == null) {
        name = "friend";
    }
    StringBuilder result = null;
    try {
        result = new StringBuilder(sayHello(name));
    } catch (Exception e) {
        return e.getMessage() + "\n";
    }
    return result.toString() + "\n";
}
```

故障注入命令如下：

```
blade c jvm return --value hello-chaosblade --classname com.example.controller.DubboController --methodname hello --process tomcat
```

故障注入之前： ![](/files/YfIcHIHDI1CdUs4DU727)

故障注入之后： ![](/files/IZToaFP62ADQ8O7xd3Iu)

停止实验：

```
blade d d31e24dea782a275
```

上述代码调用 sayHello 方法，我们对 sayHello 方法注入返回 null 故障，sayHello 方法如下：

```
private String sayHello(String name) throws BeansException {
    demoService = (DemoService)SpringContextUtil.getBean("demoService");
    StringBuilder result = new StringBuilder();
    result.append(demoService.sayHello(name));
    return result.toString();
}
```

执行以下命令：

```
blade c jvm return --value null --classname com.example.controller.DubboController --methodname sayHello --process tomcat
```

故障注入之后： ![](/files/5O7Zs8MnsBmNeh9PvDsK)

## 常见问题


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade-create-jvm/blade-create-jvm-return.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
