[CrashFix]修正UploadDataService#ConcurrentModificationException

This commit is contained in:
renwj
2022-09-05 15:16:13 +08:00
parent 093e5100a5
commit 69e4282da7
3 changed files with 38 additions and 26 deletions

View File

@@ -5,6 +5,9 @@ buildscript {
ext.kotlin_version = "1.4.31"
repositories {
maven {
url 'http://127.0.0.1:9921/nexus/content/repositories/maven_host/'
}
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
@@ -31,7 +34,9 @@ buildscript {
allprojects {
repositories {
maven {
url 'http://127.0.0.1:9921/nexus/content/repositories/maven_host/'
}
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}

View File

@@ -107,9 +107,11 @@ public class UploadDataService extends Service {
}
private void publishData() {
final MogoPayload.MogoCoornateReq coordinateReq = SocketRequestUtil.getCoordinateReq(coordinates);
if (coordinateReq != null) {
SocketRequestUtil.sendCoordinateReqBySocket(coordinateReq, true, System.currentTimeMillis());
synchronized (coordinates) {
final MogoPayload.MogoCoornateReq coordinateReq = SocketRequestUtil.getCoordinateReq(coordinates);
if (coordinateReq != null) {
SocketRequestUtil.sendCoordinateReqBySocket(coordinateReq, true, System.currentTimeMillis());
}
}
}
@@ -130,26 +132,31 @@ public class UploadDataService extends Service {
private void buildCoordinates(Location location) {
MogoPayload.Coordinate coordinate = SocketRequestUtil.buildBCoordinate(location);
if (coordinate.getLat() != 0 && coordinate.getLon() != 0) {
if (LocationConfig.isPrintLog) {
Logger.d(TAG, "socket-location is " + location.toString());
Logger.d(TAG, "socket-coordinates.size()" + coordinates.size());
// if (LocationConfig.isPrintLog) {
// Logger.d(TAG, "socket-location is " + location.toString());
// Logger.d(TAG, "socket-coordinates.size()" + coordinates.size());
// }
synchronized (coordinates) {
coordinates.offer(coordinate);
}
coordinates.offer(coordinate);
} else {
if (LocationConfig.isPrintLog) {
Logger.d(TAG, "coordinates size is 0, give up uploading for Socket");
}
}
while (coordinates.size() > MAX_LOCATION_CACHE_SIZE) {
if (LocationConfig.isPrintLog) {
Logger.d(TAG, "socket-coordinates number is " + coordinates.size());
synchronized (coordinates) {
while (coordinates.size() > MAX_LOCATION_CACHE_SIZE) {
if (LocationConfig.isPrintLog) {
Logger.d(TAG, "socket-coordinates number is " + coordinates.size());
}
coordinates.pop();
}
coordinates.pop();
}
}
private void clearLocationCache() {
coordinates.clear();
synchronized (coordinates) {
coordinates.clear();
}
}
}

View File

@@ -36,26 +36,26 @@ PASSWORD=xintai2018
RELEASE=true
# AI CLOUD 云平台
# 工具类
MOGO_UTILS_VERSION=1.4.3.25
MOGO_UTILS_VERSION=1.4.3.26
# 网络请求
MOGO_NETWORK_VERSION=1.4.3.25
MOGO_NETWORK_VERSION=1.4.3.26
# 网络DNS
MOGO_HTTPDNS_VERSION=1.4.3.25
MOGO_HTTPDNS_VERSION=1.4.3.26
# 鉴权
MOGO_PASSPORT_VERSION=1.4.3.25
MOGO_PASSPORT_VERSION=1.4.3.26
# 常链接
MOGO_SOCKET_VERSION=1.4.3.25
MOGO_SOCKET_VERSION=1.4.3.26
# 数据采集
MOGO_REALTIME_VERSION=1.4.3.25
MOGO_REALTIME_VERSION=1.4.3.26
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.4.3.25
MOGO_TANLU_VERSION=1.4.3.26
# 直播推流
MOGO_LIVE_VERSION=1.4.3.25
MOGO_LIVE_VERSION=1.4.3.26
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.4.3.25
MOGO_TRAFFICLIVE_VERSION=1.4.3.26
# 定位服务
MOGO_LOCATION_VERSION=1.4.3.25
MOGO_LOCATION_VERSION=1.4.3.26
# 远程通讯模块
MOGO_TELEMATIC_VERSION=1.4.3.25
MOGO_TELEMATIC_VERSION=1.4.3.26
# v2x
MOGO_V2X_VERSION=1.4.3.25
MOGO_V2X_VERSION=1.4.3.26