Handle null images

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

View file

@ -101,6 +101,7 @@ 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();
if (buf == null) { return null; }
tr.image = new BufferInputStream(buf); 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();

View file

@ -132,8 +132,12 @@ 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");
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img); rslt.image = new BufferInputStream(img);
} }
}
rs.close(); rs.close();
stmt.close(); stmt.close();
} catch (SQLException x) { } catch (SQLException x) {

View file

@ -138,8 +138,12 @@ 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");
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img); rslt.image = new BufferInputStream(img);
} }
}
rs.close(); rs.close();
stmt.close(); stmt.close();
} catch (SQLException x) { } catch (SQLException x) {

View file

@ -129,8 +129,12 @@ 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--;
} }
if (img == null) {
rslt = null;
} else {
rslt.image = new BufferInputStream(img, len); rslt.image = new BufferInputStream(img, len);
} }
}
rs.close(); rs.close();
stmt.close(); stmt.close();
} catch (SQLException x) { } catch (SQLException x) {