TileDataSource: catch unexpected errors (#943)
This commit is contained in:
parent
d89a402375
commit
e86bf54d8a
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
* Copyright 2022 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@ -27,7 +28,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -134,7 +134,8 @@ public class MBTilesMvtTileDataSource extends MBTilesTileDataSource {
|
||||
responseDataSink.completed(success ? QueryResult.SUCCESS : QueryResult.FAILED);
|
||||
} else
|
||||
responseDataSink.completed(QueryResult.TILE_NOT_FOUND);
|
||||
} catch (IOException e) {
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
responseDataSink.completed(QueryResult.FAILED);
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2019 Andrea Antonello
|
||||
* Copyright 2019 devemux86
|
||||
* Copyright 2019-2022 devemux86
|
||||
* Copyright 2019 Kostas Tzounopoulos
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
@ -124,8 +124,8 @@ public class MBTilesBitmapTileDataSource extends MBTilesTileDataSource {
|
||||
Bitmap bitmap = CanvasAdapter.decodeBitmap(new ByteArrayInputStream(bytes));
|
||||
sink.setTileImage(bitmap);
|
||||
res = QueryResult.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
log.debug("{} invalid bitmap", tile);
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
} finally {
|
||||
sink.completed(res);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2022 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -64,8 +65,8 @@ public abstract class TileLoader extends PausableThread implements ITileDataSink
|
||||
|
||||
try {
|
||||
loadTile(mTile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
completed(FAILED);
|
||||
}
|
||||
}
|
||||
|
@ -121,9 +121,9 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
|
||||
} catch (NullPointerException e) {
|
||||
log.debug("NPE {} {}", tile, e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
log.debug("{} {}", tile, e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Throwable t) {
|
||||
log.debug("{} {}", tile, t.getMessage());
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 devemux86
|
||||
* Copyright 2018-2022 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@ -15,9 +15,13 @@
|
||||
package org.oscim.tiling;
|
||||
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OverzoomTileDataSource implements ITileDataSource {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OverzoomTileDataSource.class);
|
||||
|
||||
private final ITileDataSource tileDataSource;
|
||||
private final int overZoom;
|
||||
|
||||
@ -32,6 +36,7 @@ public class OverzoomTileDataSource implements ITileDataSource {
|
||||
|
||||
@Override
|
||||
public void query(MapTile tile, ITileDataSink sink) {
|
||||
try {
|
||||
MapTile mapTile = tile;
|
||||
ITileDataSink dataSink = sink;
|
||||
int diff = tile.zoomLevel - overZoom;
|
||||
@ -40,6 +45,9 @@ public class OverzoomTileDataSource implements ITileDataSource {
|
||||
dataSink = new OverzoomDataSink(sink, mapTile, tile);
|
||||
}
|
||||
tileDataSource.query(mapTile, dataSink);
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2017 devemux86
|
||||
* Copyright 2017-2022 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@ -34,12 +34,9 @@ import java.net.SocketException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.oscim.tiling.QueryResult.DELAYED;
|
||||
import static org.oscim.tiling.QueryResult.FAILED;
|
||||
import static org.oscim.tiling.QueryResult.SUCCESS;
|
||||
|
||||
public class UrlTileDataSource implements ITileDataSource {
|
||||
static final Logger log = LoggerFactory.getLogger(UrlTileDataSource.class);
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UrlTileDataSource.class);
|
||||
|
||||
protected final HttpEngine mConn;
|
||||
protected final ITileDecoder mTileDecoder;
|
||||
@ -57,13 +54,17 @@ public class UrlTileDataSource implements ITileDataSource {
|
||||
public void query(MapTile tile, ITileDataSink sink) {
|
||||
ITileCache cache = mTileSource.tileCache;
|
||||
|
||||
QueryResult res = QueryResult.FAILED;
|
||||
|
||||
TileWriter cacheWriter = null;
|
||||
try {
|
||||
if (mUseCache) {
|
||||
TileReader c = cache.getTile(tile);
|
||||
if (c != null) {
|
||||
InputStream is = c.getInputStream();
|
||||
try {
|
||||
if (mTileDecoder.decode(tile, sink, is)) {
|
||||
sink.completed(SUCCESS);
|
||||
sink.completed(QueryResult.SUCCESS);
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@ -74,10 +75,6 @@ public class UrlTileDataSource implements ITileDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
QueryResult res = FAILED;
|
||||
|
||||
TileWriter cacheWriter = null;
|
||||
try {
|
||||
mConn.sendRequest(tile);
|
||||
InputStream is = mConn.read();
|
||||
if (mUseCache) {
|
||||
@ -85,23 +82,25 @@ public class UrlTileDataSource implements ITileDataSource {
|
||||
mConn.setCache(cacheWriter.getOutputStream());
|
||||
}
|
||||
if (mTileDecoder.decode(tile, sink, is))
|
||||
res = SUCCESS;
|
||||
res = QueryResult.SUCCESS;
|
||||
} catch (SocketException e) {
|
||||
log.debug("{} Socket Error: {}", tile, e.getMessage());
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.debug("{} Socket Timeout", tile);
|
||||
res = DELAYED;
|
||||
res = QueryResult.DELAYED;
|
||||
} catch (UnknownHostException e) {
|
||||
log.debug("{} Unknown host: {}", tile, e.getMessage());
|
||||
} catch (IOException e) {
|
||||
log.debug("{} Network Error: {}", tile, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.debug("{} Error: {}", tile, e.getMessage());
|
||||
} catch (Throwable t) {
|
||||
log.error(t.getMessage(), t);
|
||||
} finally {
|
||||
boolean ok = (res == SUCCESS);
|
||||
boolean ok = (res == QueryResult.SUCCESS);
|
||||
|
||||
if (!mConn.requestCompleted(ok) && ok)
|
||||
res = FAILED;
|
||||
res = QueryResult.FAILED;
|
||||
|
||||
if (cacheWriter != null)
|
||||
cacheWriter.complete(ok);
|
||||
|
Loading…
x
Reference in New Issue
Block a user