diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/S3Config.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/S3Config.java index ad4b4340..cefdfa4f 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/S3Config.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/S3Config.java @@ -8,15 +8,14 @@ import java.util.Optional; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable public class S3Config extends StorageConfig implements S3StorageSettings { - private String endpoint = null; - private String region = ""; - private String accessKey = ""; + @DebugDump private String endpoint = null; + @DebugDump private String region = ""; + @DebugDump private String accessKey = ""; private String secretKey = ""; - private String bucket = ""; - private Compression compression = Compression.GZIP; + @DebugDump private String bucket = ""; + @DebugDump private Compression compression = Compression.GZIP; @Override public Optional getEndpoint() { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/s3/S3Storage.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/s3/S3Storage.java index e1f4cbf8..c4bc294b 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/s3/S3Storage.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/s3/S3Storage.java @@ -5,6 +5,7 @@ import de.bluecolored.bluemap.core.util.OnCloseOutputStream; import software.amazon.awssdk.auth.credentials.AwsSessionCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.core.exception.SdkException; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3Client; @@ -62,10 +63,9 @@ public Optional readMapTile(String mapId, int lod, Vector .build() ); return Optional.of(new CompressedInputStream(is, compression)); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return Optional.empty(); - } + } catch (NoSuchKeyException e) { + return Optional.empty(); + } catch (SdkException e) { throw new IOException(e); } } @@ -104,10 +104,9 @@ public long getLastModified() { return info.lastModified().getEpochSecond(); } }); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return Optional.empty(); - } + } catch (NoSuchKeyException e) { + return Optional.empty(); + } catch (SdkException e) { throw new IOException(e); } } @@ -123,10 +122,8 @@ public void deleteMapTile(String mapId, int lod, Vector2i tile) throws IOExcepti .key(path) .build() ); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return; - } + } catch (NoSuchKeyException ignored) { + } catch (SdkException e) { throw new IOException(e); } } @@ -166,10 +163,9 @@ public Optional readMeta(String mapId, String name) throws IOExcept .build() ); return Optional.of(is); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return Optional.empty(); - } + } catch (NoSuchKeyException e) { + return Optional.empty(); + } catch (SdkException e) { throw new IOException(e); } } @@ -197,10 +193,9 @@ public long getSize() { return info.contentLength(); } }); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return Optional.empty(); - } + } catch (NoSuchKeyException e) { + return Optional.empty(); + } catch (SdkException e) { throw new IOException(e); } } @@ -216,10 +211,8 @@ public void deleteMeta(String mapId, String name) throws IOException { .key(path) .build() ); - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return; - } + } catch (NoSuchKeyException ignored) { + } catch (SdkException e) { throw new IOException(e); } } @@ -238,22 +231,21 @@ public void purgeMap(String mapId, Function onProgress) t var filesList = files.contents().stream().collect(Collectors.toList()); for (int i = 0; i < filesList.size(); i++) { var file = filesList.get(i); - client.deleteObject( - DeleteObjectRequest - .builder() - .bucket(bucket) - .key(file.key()) - .build() - ); + try { + client.deleteObject( + DeleteObjectRequest + .builder() + .bucket(bucket) + .key(file.key()) + .build() + ); + } catch (NoSuchKeyException ignored) {} if (!onProgress.apply( new ProgressInfo((double) (i + 1) / filesList.size()) )) return; } - } catch (Exception e) { - if (e instanceof NoSuchKeyException) { - return; - } + } catch (SdkException e) { throw new IOException(e); } }