Handle null images
This commit is contained in:
parent
b42951fcb5
commit
c026fc44b5
4 changed files with 17 additions and 4 deletions
|
|
@ -101,7 +101,8 @@ public class AWSS3MapStorage extends MapStorage {
|
||||||
GetObjectResponse rsp = obj.getResponse();
|
GetObjectResponse rsp = obj.getResponse();
|
||||||
TileRead tr = new TileRead();
|
TileRead tr = new TileRead();
|
||||||
byte[] buf = obj.getBytes();
|
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());
|
tr.format = ImageEncoding.fromContentType(rsp.getContentType());
|
||||||
Map<String, String> meta = rsp.getMetadata();
|
Map<String, String> meta = rsp.getMetadata();
|
||||||
String v = meta.get("x-dynmap-hash");
|
String v = meta.get("x-dynmap-hash");
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,11 @@ public class MicrosoftSQLMapStorage extends MapStorage {
|
||||||
rslt.lastModified = rs.getLong("LastUpdate");
|
rslt.lastModified = rs.getLong("LastUpdate");
|
||||||
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
|
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
|
||||||
byte[] img = rs.getBytes("Image");
|
byte[] img = rs.getBytes("Image");
|
||||||
rslt.image = new BufferInputStream(img);
|
if (img == null) {
|
||||||
|
rslt = null;
|
||||||
|
} else {
|
||||||
|
rslt.image = new BufferInputStream(img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,11 @@ public class PostgreSQLMapStorage extends MapStorage {
|
||||||
rslt.lastModified = rs.getLong("LastUpdate");
|
rslt.lastModified = rs.getLong("LastUpdate");
|
||||||
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
|
rslt.format = MapType.ImageEncoding.fromOrd(rs.getInt("Format"));
|
||||||
byte[] img = rs.getBytes("Image");
|
byte[] img = rs.getBytes("Image");
|
||||||
rslt.image = new BufferInputStream(img);
|
if (img == null) {
|
||||||
|
rslt = null;
|
||||||
|
} else {
|
||||||
|
rslt.image = new BufferInputStream(img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,11 @@ public class SQLiteMapStorage extends MapStorage {
|
||||||
// Trim trailing zeros from padding by BLOB field
|
// Trim trailing zeros from padding by BLOB field
|
||||||
while((len > 0) && (img[len-1] == '\0')) len--;
|
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();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue