[sonar] code bug

This commit is contained in:
zhongchao
2023-10-19 16:28:13 +08:00
parent 195f971425
commit 2a3e01f66e
44 changed files with 392 additions and 2756 deletions

View File

@@ -3,7 +3,6 @@ package com.zhidaoauto.map.sdk.inner.byteh;
import com.autonavi.nge.map.LonLat;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -14,7 +13,7 @@ public class PayloadEncoder {
public static <T extends Codecable> byte[] getPayload(T command) {
List<FieldWrapper> fieldWrapperList = command.getFieldWrapperList();
ByteBuf buffer = Unpooled.buffer();
for(FieldWrapper fieldWrapper :fieldWrapperList){
for (FieldWrapper fieldWrapper : fieldWrapperList) {
write2ByteBuf(fieldWrapper, command, buffer);
}
return buffer.array();
@@ -37,6 +36,9 @@ public class PayloadEncoder {
} catch (IllegalAccessException e) {
new RuntimeException("反射获取值失败filed:" + field.getName(), e);
}
if (value == null) {
return;
}
switch (typeName) {
case "com.autonavi.nge.map.LonLat":
LonLat lonLat = (LonLat) value;
@@ -51,6 +53,8 @@ public class PayloadEncoder {
case "java.lang.Character":
case "kotlin.Character":
case "char":
case "java.lang.String":
case "kotlin.String":
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
break;
case "java.lang.Byte":
@@ -83,10 +87,6 @@ public class PayloadEncoder {
case "double":
buffer.writeDouble((double) value);
break;
case "java.lang.String":
case "kotlin.String":
buffer.writeCharSequence((CharSequence) value, StandardCharsets.UTF_8);
break;
default:
throw new RuntimeException(typeName + "不支持bug");
}

View File

@@ -38,8 +38,8 @@ class Clerk(private val mMapController: IMapController?) {
}
job?.cancel()
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
var className: String = ""
var methodName: String = ""
var className = ""
var methodName = ""
try {
className = Thread.currentThread().stackTrace[3].className
methodName = Thread.currentThread().stackTrace[3].methodName
@@ -56,8 +56,8 @@ class Clerk(private val mMapController: IMapController?) {
}
job?.cancel()
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
var className: String = ""
var methodName: String = ""
var className = ""
var methodName = ""
try {
className = Thread.currentThread().stackTrace[3].className
methodName = Thread.currentThread().stackTrace[3].methodName
@@ -79,7 +79,7 @@ class Clerk(private val mMapController: IMapController?) {
if(CompileConfig.DEBUG){
Log.i(TAG, "add: ${System.currentTimeMillis()}-$key")
}
var stringBuffer = cacheMap.get(key)
var stringBuffer = cacheMap[key]
if(stringBuffer == null){
stringBuffer = StringBuffer()
}
@@ -155,29 +155,34 @@ class Clerk(private val mMapController: IMapController?) {
uploadJob?.cancel()
uploadJob = scope?.launch(Dispatchers.IO) {
val path = Recorder.getLogDirectory(TAG)
val file = File(path)
if(!file.isDirectory){
return@launch
}
val firstlist = file.list()
for(p in firstlist){
val f = File(p)
if(!f.isDirectory){
break
path?.let {
val file = File(it)
if(!file.isDirectory){
return@launch
}
val secondlist = f.list()
for(child in secondlist){
val childFile = File(child)
upload(childFile)
val firstList = file.list()
firstList?.let {
for(p in firstList){
val f = File(p)
if(!f.isDirectory){
break
}
val secondList = f.list()
secondList?.let {
for(child in secondList){
val childFile = File(child)
upload(childFile)
}
}
}
}
}
}
}
private suspend fun upload(file:File){
return
val content = file.readText()
// return
// val content = file.readText()
// repository.uploadLogInfo(content)
}