解决oom的问题

This commit is contained in:
liuyazhou 2022-07-26 13:49:36 +08:00
parent 6f83ed3285
commit 3b679c4e79

View File

@ -97,6 +97,11 @@ public class OssClient {
client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata)); client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata));
} catch (Exception e) { } catch (Exception e) {
throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]"); throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]");
}finally {
//如果是阿里云时必须关闭数据量大时否则会出现oom的情况
if (client != null) {
client.shutdown();
}
} }
return UploadResult.builder().url(getUrl() + "/" + path).filename(path).build(); return UploadResult.builder().url(getUrl() + "/" + path).filename(path).build();
} }
@ -107,6 +112,10 @@ public class OssClient {
client.deleteObject(properties.getBucketName(), path); client.deleteObject(properties.getBucketName(), path);
} catch (Exception e) { } catch (Exception e) {
throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]"); throw new OssException("上传文件失败,请检查配置信息:[" + e.getMessage() + "]");
}finally {
if (client != null) {
client.shutdown();
}
} }
} }