@@ -109,13 +109,15 @@ public Object execute(String id, List<DatasetParamDTO> paramList) {
109109 */
110110 private Object getData (DatasetEntity entity , List <DatasetParamDTO > finalParamList ) {
111111 HttpDataSetConfig config = (HttpDataSetConfig ) entity .getConfig ();
112+ // NOTE 复制一份config,避免直接修改缓存
113+ HttpDataSetConfig configCopy = BeanConvertUtils .convert (config , HttpDataSetConfig .class );
112114 List <DatasetParamDTO > params = paramsClient .handleParams (finalParamList );
113- config = this .handleParams (config , params );
114- if (config .getRequestType ().equals (FRONTEND )) {
115- log .info ("执行【{}】数据集(类型:【HTTP】,ID:【{}】), 方式:【前端代理】, 类型:【{}】, URL:【{}】" , entity .getName (), entity .getId (), config .getMethod (), config .getUrl ());
115+ configCopy = this .handleParams (configCopy , params );
116+ if (configCopy .getRequestType ().equals (FRONTEND )) {
117+ log .info ("执行【{}】数据集(类型:【HTTP】,ID:【{}】), 方式:【前端代理】, 类型:【{}】, URL:【{}】" , entity .getName (), entity .getId (), configCopy .getMethod (), configCopy .getUrl ());
116118 // 将params替换掉config中的值
117119 if (params !=null && !params .isEmpty ()) {
118- List <DatasetParamDTO > configParams = config .getParamsList ();
120+ List <DatasetParamDTO > configParams = configCopy .getParamsList ();
119121 for (DatasetParamDTO param : params ) {
120122 // 如果有name相同的,替换掉
121123 for (DatasetParamDTO configParam : configParams ) {
@@ -126,9 +128,9 @@ private Object getData(DatasetEntity entity, List<DatasetParamDTO> finalParamLis
126128 }
127129 }
128130 }
129- return config ;
131+ return configCopy ;
130132 }
131- return this .getBackendData (config , entity );
133+ return this .getBackendData (configCopy , entity );
132134 }
133135
134136
@@ -347,17 +349,19 @@ private Object getBackendData(HttpDataSetConfig config, DatasetEntity entity) {
347349 }
348350 Object returnResult = responseBody ;
349351 // 如果有响应后脚本,则执行响应后脚本
350- if (StringUtils .isNotBlank (config .getResponseScript ())) {
352+ boolean runResponseScript = StringUtils .isNotBlank (config .getResponseScript ());
353+ if (runResponseScript ) {
351354 Map <String , Object > responseScriptMap = Maps .newHashMap ();
352355 // 取name和value
353356 responseScriptMap .put ("responseString" , responseBody );
354357 returnResult = GroovyUtils .run (config .getResponseScript (), responseScriptMap );
355- }
356- if (responseBody .startsWith ("{" )) {
357- returnResult = JSON .parseObject (responseBody );
358- }
359- if (responseBody .startsWith ("[" )) {
360- returnResult = JSON .parseArray (responseBody );
358+ } else {
359+ if (responseBody .startsWith ("{" )) {
360+ returnResult = JSON .parseObject (responseBody );
361+ }
362+ if (responseBody .startsWith ("[" )) {
363+ returnResult = JSON .parseArray (responseBody );
364+ }
361365 }
362366 long endTime = System .currentTimeMillis ();
363367 if (entity == null ) {
0 commit comments