1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

better code

This commit is contained in:
赵禹光 2019-08-19 14:51:44 +08:00
parent c004b16ab4
commit e22179bb36

View File

@ -23,7 +23,6 @@ import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Optional;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -156,9 +155,9 @@ public class OssStorageResource implements Resource {
* @return the bucket if it exists, or null otherwise * @return the bucket if it exists, or null otherwise
*/ */
public Bucket getBucket() { public Bucket getBucket() {
Optional<Bucket> value = this.oss.listBuckets().stream() return this.oss.listBuckets().stream()
.filter(bucket -> bucket.getName().equals(this.bucketName)).findFirst(); .filter(bucket -> bucket.getName().equals(this.bucketName)).findFirst()
return value.orElse(null); .orElse(null);
} }
/** /**