Handle null images

This commit is contained in:
Mike Primm 2022-07-30 18:04:28 -05:00
parent bf8d5eb6cf
commit 082878aade
4 changed files with 17 additions and 4 deletions

View File

@ -101,7 +101,8 @@ public class AWSS3MapStorage extends MapStorage {
GetObjectResponse rsp = obj.getResponse();
TileRead tr = new TileRead();
byte[] buf = obj.getBytes();
tr.image = new BufferInputStream(buf);
if (buf == null) { return null; }
tr.image = new BufferInputStream(buf);
tr.format = ImageEncoding.fromContentType(rsp.getContentType());
Map<String, String> meta = rsp.getMetadata();
String v = meta.get("x-dynmap-hash");

View File

@ -132,7 +132,11 @@ public class MicrosoftSQLMapStorage extends MapStorage {
rslt.lastModified = rs.getLong("LastUpdate");
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
byte[] img = rs.getBytes("Image");
rslt.image = new BufferInputStream(img);
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img);
}
}
rs.close();
stmt.close();

View File

@ -138,7 +138,11 @@ public class PostgreSQLMapStorage extends MapStorage {
rslt.lastModified = rs.getLong("LastUpdate");
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
byte[] img = rs.getBytes("Image");
rslt.image = new BufferInputStream(img);
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img);
}
}
rs.close();
stmt.close();

View File

@ -129,7 +129,11 @@ public class SQLiteMapStorage extends MapStorage {
// Trim trailing zeros from padding by BLOB field
while((len > 0) && (img[len-1] == '\0')) len--;
}
rslt.image = new BufferInputStream(img, len);
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img, len);
}
}
rs.close();
stmt.close();