(improvement)(code) Replace e.printStackTrace() with logger.error. (#1156)

This commit is contained in:
lexluo09
2024-06-15 18:26:52 +08:00
committed by GitHub
parent b5cc450758
commit f2a12e56b7
9 changed files with 39 additions and 36 deletions

View File

@@ -59,16 +59,16 @@ public class SqlQueryApiController {
chatQueryService.correct(querySqlReq, user);
return querySqlReq;
}).collect(Collectors.toList());
List<CompletableFuture<SemanticQueryResp>> futures = semanticQueryReqs.stream()
.map(querySqlReq -> CompletableFuture.supplyAsync(() -> {
try {
return queryService.queryByReq(querySqlReq, user);
} catch (Exception e) {
e.printStackTrace();
log.error("querySqlReq:{},queryByReq error:", querySqlReq, e);
return new SemanticQueryResp();
}
}))
.collect(Collectors.toList());
})).collect(Collectors.toList());
return futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
}

View File

@@ -1,5 +1,11 @@
package com.tencent.supersonic.headless.server.utils;
import static com.tencent.supersonic.common.pojo.Constants.AND_UPPER;
import static com.tencent.supersonic.common.pojo.Constants.APOSTROPHE;
import static com.tencent.supersonic.common.pojo.Constants.COMMA;
import static com.tencent.supersonic.common.pojo.Constants.POUND;
import static com.tencent.supersonic.common.pojo.Constants.SPACE;
import com.google.common.base.Strings;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.common.pojo.Aggregator;
@@ -34,13 +40,6 @@ import com.tencent.supersonic.headless.server.service.MetricService;
import com.tencent.supersonic.headless.server.service.ModelService;
import com.tencent.supersonic.headless.server.service.QueryService;
import com.tencent.supersonic.headless.server.service.TagMetaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -53,12 +52,12 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.StringJoiner;
import static com.tencent.supersonic.common.pojo.Constants.AND_UPPER;
import static com.tencent.supersonic.common.pojo.Constants.APOSTROPHE;
import static com.tencent.supersonic.common.pojo.Constants.COMMA;
import static com.tencent.supersonic.common.pojo.Constants.POUND;
import static com.tencent.supersonic.common.pojo.Constants.SPACE;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Slf4j
@Component
@@ -87,10 +86,10 @@ public class DictUtils {
private final TagMetaService tagMetaService;
public DictUtils(DimensionService dimensionService,
MetricService metricService,
QueryService queryService,
ModelService modelService,
@Lazy TagMetaService tagMetaService) {
MetricService metricService,
QueryService queryService,
ModelService modelService,
@Lazy TagMetaService tagMetaService) {
this.dimensionService = dimensionService;
this.metricService = metricService;
this.queryService = queryService;
@@ -190,7 +189,7 @@ public class DictUtils {
constructDictLines(valueAndFrequencyPair, lines, nature);
addWhiteValueLines(dictItemResp, lines, nature);
} catch (Exception e) {
e.printStackTrace();
log.error("dictItemResp:{},fetchItemValue error:", dictItemResp, e);
}
return lines;
}

View File

@@ -130,7 +130,7 @@ public class StatUtils {
queryStatInfo.setModelId(queryTagReq.getModelIds().get(0));
}
} catch (JsonProcessingException e) {
e.printStackTrace();
log.error("", e);
}
StatUtils.set(queryStatInfo);
@@ -198,7 +198,7 @@ public class StatUtils {
queryStatInfo.setModelId(queryStructReq.getModelIds().get(0));
}
} catch (JsonProcessingException e) {
e.printStackTrace();
log.error("", e);
}
StatUtils.set(queryStatInfo);