fix file ClientAbortException

This commit is contained in:
ran.shang
2025-08-27 10:45:29 +08:00
parent 1b056e51d2
commit cb83b3a0ca

View File

@@ -28,13 +28,13 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public class AliFileStorage implements IFileStorage { public class AliFileStorage implements IFileStorage {
private FileProperties fileProperties; private FileProperties fileProperties;
private OSS ossClient; private OSS ossClient;
private String bucketName; private String bucketName;
public AliFileStorage(FileProperties fileProperties) { public AliFileStorage(FileProperties fileProperties) {
this.fileProperties = fileProperties; this.fileProperties = fileProperties;
AliStorage aliStorage = fileProperties.getStorage().getAli(); AliStorage aliStorage = fileProperties.getStorage().getAli();
@@ -70,14 +70,14 @@ public class AliFileStorage implements IFileStorage {
try { try {
IOUtils.copy(is, os); IOUtils.copy(is, os);
} catch (ClientAbortException e) { } catch (ClientAbortException e) {
throw new BusinessException("下载客户端异常:" + e.getMessage()); log.warn("客户端主动断开连接: {}", e.getMessage());
} }
} catch (IOException ie) { } catch (IOException ie) {
log.info("Caught an IOException", ie); log.info("Caught an IOException", ie);
throw new DevopsException("oss流处理异常" + ie.getMessage()); throw new DevopsException("oss流处理异常" + ie.getMessage());
} }
} }
private String dealPath(String path) { private String dealPath(String path) {
Assert.isTrue(StringUtils.isNotBlank(path), "文件地址不能为空"); Assert.isTrue(StringUtils.isNotBlank(path), "文件地址不能为空");
String seperate = String.valueOf(File.separatorChar); String seperate = String.valueOf(File.separatorChar);
@@ -115,9 +115,9 @@ public class AliFileStorage implements IFileStorage {
log.info("Caught an ClientException, which means the client encountered " log.info("Caught an ClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with OSS, " + "a serious internal problem while trying to communicate with OSS, "
+ "such as not being able to access the network."); + "such as not being able to access the network.");
log.info("Error Message:" + ce.getMessage()); log.info("Error Message:{}-{}", bucketName, ce.getMessage());
throw new DevopsException("oss客户端异常" + ce.getMessage()); throw new DevopsException("oss客户端异常" + ce.getMessage());
} }
} }
} }