Merge branch 'hotfix/printstack_to_log_error_1014' into 'master'

hotfix: (e.printStack优化成log.error)

See merge request universal/infrastructure/backend/oss!158
This commit is contained in:
徐大伟 2024-10-14 08:17:32 +00:00
commit 69420e7051
3 changed files with 9 additions and 7 deletions

View File

@ -211,7 +211,7 @@ public class WebFileController {
response.addHeader("Content-Disposition", "attachment;filename=" + result.getFileName() + "." + result.getFileFormat());
IOUtils.copy(inputStream, outputStream);
} catch (Exception e) {
e.printStackTrace();
log.error("WebFileController#download exception", e);
} finally {
inputStream.close();
outputStream.close();

View File

@ -181,7 +181,6 @@ public class AliOssServiceImpl implements AliOssService {
// 返回uploadId它是分片上传事件的唯一标识您可以根据这个uploadId发起相关的操作如取消分片上传查询分片上传等
return result.getUploadId();
} catch (Exception e) {
e.printStackTrace();
LogUtil.error("ali oss multipart upload init error = {}", e);
throw new BizException(MULTIPART_UPLOAD_INIT_ERROR);
}
@ -211,7 +210,7 @@ public class AliOssServiceImpl implements AliOssService {
// 每次上传分片之后OSS的返回结果包含PartETag
return uploadPartResult.getPartETag();
} catch (Exception e) {
e.printStackTrace();
log.error("AliOssService#multipartUpload exception", e);
throw new BizException(MULTIPART_UPLOAD_ERROR);
}
}
@ -266,7 +265,7 @@ public class AliOssServiceImpl implements AliOssService {
client.completeMultipartUpload(completeMultipartUploadRequest);
return getUrl(bucketName, tgtFileKey);
} catch (Exception e) {
e.printStackTrace();
log.error("AliOssService#multipartUploadFile exception", e);
throw new BizException(MULTIPART_UPLOAD_ERROR);
}
}
@ -280,7 +279,7 @@ public class AliOssServiceImpl implements AliOssService {
client.completeMultipartUpload(completeMultipartUploadRequest);
return getUrl(bucketName, tgtFileKey);
} catch (Exception e) {
e.printStackTrace();
log.error("AliOssService#multipartUploadComplete exception", e);
throw new BizException(MULTIPART_UPLOAD_COMPLETE_ERROR);
}
}

View File

@ -8,6 +8,8 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author: mr.jie
* @date: 2021-07-29 18:42
**/
@Slf4j
public class FileServiceTest extends SpringTestBase {
@Autowired
@ -44,9 +47,9 @@ public class FileServiceTest extends SpringTestBase {
try (FileInputStream fileInputStream = new FileInputStream(file)) {
fileInputStream.read(bytes);
} catch (FileNotFoundException e) {
e.printStackTrace();
log.error("upload FileNotFoundException", e);
} catch (IOException e) {
e.printStackTrace();
log.error("upload IOException", e);
}
// System.out.println(Arrays.toString(bytes));
dto.setFileContent(bytes);