diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 8d315fef1b..d63f3cc4ba 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -238,18 +238,23 @@ public class MsTCPSampler extends MsTestElement { this.parameters.forEach(item -> { names.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), item.getName())); String value = item.getValue(); - value = this.formatMockValue(value); - if(StringUtils.isNotEmpty(this.getConnectEncoding())){ - if(StringUtils.equalsIgnoreCase("utf-8",this.getConnectEncoding())){ - value = new String(value.getBytes(),StandardCharsets.UTF_8); - }else if(StringUtils.equalsIgnoreCase("gbk",this.getConnectEncoding())){ - try { - value = new String(value.getBytes(),"GBK"); - }catch (Exception e){ + if(StringUtils.isNotEmpty(value)){ + value = this.formatMockValue(value); + if(StringUtils.isNotEmpty(this.getConnectEncoding())){ + if(StringUtils.equalsIgnoreCase("utf-8",this.getConnectEncoding())){ + try { + value = new String(value.getBytes(),StandardCharsets.UTF_8); + }catch (Exception e){ + } + }else if(StringUtils.equalsIgnoreCase("gbk",this.getConnectEncoding())){ + try { + value = new String(value.getBytes(),"GBK"); + }catch (Exception e){ + } } } + threadValues.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), value)); } - threadValues.add(new StringProperty(new Integer(new Random().nextInt(1000000)).toString(), value)); }); } userParameters.setNames(new CollectionProperty(UserParameters.NAMES, names)); diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 5b89ab2aca..575338e855 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -31,25 +31,33 @@