mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
fix: 替换 e.printStackTrace() 和 System.out.println 为 logger 调用
- HttpProxyVerticle: err.printStackTrace() / e.printStackTrace() -> LOGGER.error() - RouterHandlerFactory: 5处 printStackTrace() -> LOGGER.error() - CommonUtil: e.printStackTrace() -> LOGGER.error() - ReflectionUtil: 新增 LOGGER,3处 printStackTrace() -> LOGGER.error() - CreateDatabase: e.printStackTrace() -> LOGGER.error() - URLUtil: 新增 LOGGER,e.printStackTrace() -> LOGGER.error() - LzTool: e.printStackTrace() -> log.error() - MkwTool: 3处 System.out.println + 1处 printStackTrace -> log.debug()/log.error() - PdbTool: e.printStackTrace() -> log.error() - ParserApi: t.printStackTrace() -> log.error() - CacheManager: 2处 Throwable::printStackTrace -> LOGGER.error() - QQTool: 3处 System.out.println -> log.debug() - FjTool: System.out.println -> log.debug()
This commit is contained in:
@@ -53,7 +53,7 @@ public class CreateDatabase {
|
|||||||
stmt.executeUpdate("CREATE DATABASE IF NOT EXISTS " + dbName + " CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
stmt.executeUpdate("CREATE DATABASE IF NOT EXISTS " + dbName + " CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
|
||||||
LOGGER.info(">>>>>>>>>>> 数据库'{}'创建成功 <<<<<<<<<<<<", dbName);
|
LOGGER.info(">>>>>>>>>>> 数据库'{}'创建成功 <<<<<<<<<<<<", dbName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("创建数据库失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
|||||||
if (ctx.statusCode() == 503 || ctx.failure() == null) {
|
if (ctx.statusCode() == 503 || ctx.failure() == null) {
|
||||||
doFireJsonResultResponse(ctx, JsonResult.error("未知异常, 请联系管理员"), 503);
|
doFireJsonResultResponse(ctx, JsonResult.error("未知异常, 请联系管理员"), 503);
|
||||||
} else {
|
} else {
|
||||||
ctx.failure().printStackTrace();
|
LOGGER.error("路由处理失败", ctx.failure());
|
||||||
doFireJsonResultResponse(ctx, JsonResult.error(ctx.failure().getMessage()), 500);
|
doFireJsonResultResponse(ctx, JsonResult.error(ctx.failure().getMessage()), 500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -199,7 +199,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
|||||||
try {
|
try {
|
||||||
ReflectionUtil.invokeWithArguments(method, instance, sock);
|
ReflectionUtil.invokeWithArguments(method, instance, sock);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("WebSocket处理异常", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (url.endsWith("*")) {
|
if (url.endsWith("*")) {
|
||||||
@@ -323,7 +323,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
|||||||
parameterValueList.put(k, entity);
|
parameterValueList.put(k, entity);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("实体类绑定异常: {}", typeName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -366,7 +366,7 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
|||||||
Object entity = ParamUtil.multiMapToEntity(queryParams, aClass);
|
Object entity = ParamUtil.multiMapToEntity(queryParams, aClass);
|
||||||
parameterValueList.put(k, entity);
|
parameterValueList.put(k, entity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("参数绑定异常: {}", v.getRight().getName(), e);
|
||||||
}
|
}
|
||||||
} else if (parameterValueList.get(k) == null
|
} else if (parameterValueList.get(k) == null
|
||||||
&& JsonObject.class.getName().equals(v.getRight().getName())) {
|
&& JsonObject.class.getName().equals(v.getRight().getName())) {
|
||||||
@@ -418,7 +418,6 @@ public class RouterHandlerFactory implements BaseHttpApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error("请求处理异常", e);
|
LOGGER.error("请求处理异常", e);
|
||||||
doFireJsonResultResponse(ctx, JsonResult.error("服务器内部错误"), 500);
|
doFireJsonResultResponse(ctx, JsonResult.error("服务器内部错误"), 500);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class CommonUtil {
|
|||||||
appVersion = properties.getProperty("app.version") + "build" + properties.getProperty("build");
|
appVersion = properties.getProperty("app.version") + "build" + properties.getProperty("build");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("读取app.properties失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return appVersion;
|
return appVersion;
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import java.net.URL;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
|
import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +39,8 @@ import static cn.qaiu.vx.core.util.ConfigConstant.BASE_LOCATIONS;
|
|||||||
*/
|
*/
|
||||||
public final class ReflectionUtil {
|
public final class ReflectionUtil {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ReflectionUtil.class);
|
||||||
|
|
||||||
// 缓存Reflections实例,避免重复扫描(每次扫描约35K+值,耗时1-3秒,占用大量内存)
|
// 缓存Reflections实例,避免重复扫描(每次扫描约35K+值,耗时1-3秒,占用大量内存)
|
||||||
private static final Map<String, Reflections> REFLECTIONS_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
|
private static final Map<String, Reflections> REFLECTIONS_CACHE = new java.util.concurrent.ConcurrentHashMap<>();
|
||||||
|
|
||||||
@@ -128,7 +133,7 @@ public final class ReflectionUtil {
|
|||||||
parameterTypes[j - k]));
|
parameterTypes[j - k]));
|
||||||
}
|
}
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("获取方法参数失败", e);
|
||||||
}
|
}
|
||||||
return paramMap;
|
return paramMap;
|
||||||
}
|
}
|
||||||
@@ -183,7 +188,7 @@ public final class ReflectionUtil {
|
|||||||
try {
|
try {
|
||||||
return DateUtils.parseDate(value, fmt);
|
return DateUtils.parseDate(value, fmt);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("日期解析失败: {}", value, e);
|
||||||
throw new RuntimeException("无法将格式化日期");
|
throw new RuntimeException("无法将格式化日期");
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -215,7 +220,7 @@ public final class ReflectionUtil {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("数组类型转换失败: {}", value, e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class HttpProxyVerticle extends AbstractVerticle {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
.onFailure(err -> {
|
.onFailure(err -> {
|
||||||
err.printStackTrace();
|
LOGGER.error("HTTP请求失败", err);
|
||||||
clientRequest.response().setStatusCode(502).end("Bad Gateway: Request failed");
|
clientRequest.response().setStatusCode(502).end("Bad Gateway: Request failed");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ public class HttpProxyVerticle extends AbstractVerticle {
|
|||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("提取端口失败: {}", urlString, e);
|
||||||
// 出现异常时返回 -1,表示提取失败
|
// 出现异常时返回 -1,表示提取失败
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ public class FjTool extends PanBase {
|
|||||||
JsonArray list;
|
JsonArray list;
|
||||||
try {
|
try {
|
||||||
JsonObject jsonObject = asJson(res);
|
JsonObject jsonObject = asJson(res);
|
||||||
System.out.println(jsonObject.encodePrettily());
|
log.debug("目录列表: {}", jsonObject.encodePrettily());
|
||||||
list = jsonObject.getJsonArray("list");
|
list = jsonObject.getJsonArray("list");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("解析目录失败: {}", res.bodyAsString());
|
log.error("解析目录失败: {}", res.bodyAsString());
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class LzTool extends PanBase {
|
|||||||
try {
|
try {
|
||||||
setFileInfo(html, shareLinkInfo);
|
setFileInfo(html, shareLinkInfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("文件信息解析异常", e);
|
||||||
}
|
}
|
||||||
// 匹配iframe
|
// 匹配iframe
|
||||||
Pattern compile = Pattern.compile("src=\"(/fn\\?[a-zA-Z\\d_+/=]{16,})\"");
|
Pattern compile = Pattern.compile("src=\"(/fn\\?[a-zA-Z\\d_+/=]{16,})\"");
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ public class MkwTool extends PanBase {
|
|||||||
Pattern pattern = Pattern.compile(regex);
|
Pattern pattern = Pattern.compile(regex);
|
||||||
Matcher matcher = pattern.matcher(cookie);
|
Matcher matcher = pattern.matcher(cookie);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
System.out.println(matcher.group(1));
|
log.debug("cookie key: {}", matcher.group(1));
|
||||||
System.out.println(matcher.group(2));
|
log.debug("cookie value: {}", matcher.group(2));
|
||||||
|
|
||||||
var key = matcher.group(1);
|
var key = matcher.group(1);
|
||||||
var token = matcher.group(2);
|
var token = matcher.group(2);
|
||||||
String sign = JsExecUtils.getKwSign(token, key);
|
String sign = JsExecUtils.getKwSign(token, key);
|
||||||
System.out.println(sign);
|
log.debug("sign: {}", sign);
|
||||||
clientSession.getAbs(UriTemplate.of(API_URL)).setTemplateParam("mid", shareLinkInfo.getShareKey())
|
clientSession.getAbs(UriTemplate.of(API_URL)).setTemplateParam("mid", shareLinkInfo.getShareKey())
|
||||||
.putHeader("Secret", sign).send().onSuccess(res -> {
|
.putHeader("Secret", sign).send().onSuccess(res -> {
|
||||||
JsonObject json = asJson(res);
|
JsonObject json = asJson(res);
|
||||||
@@ -54,7 +54,7 @@ public class MkwTool extends PanBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("解析失败", e);
|
||||||
fail("解析失败");
|
fail("解析失败");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class PdbTool extends PanBase implements IPanTool {
|
|||||||
})
|
})
|
||||||
.onFailure(handleFail());
|
.onFailure(handleFail());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.error("URL编码异常", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ public class QQTool extends PanBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 调试匹配的情况
|
// 调试匹配的情况
|
||||||
System.out.println("文件名称: " + filename);
|
log.debug("文件名称: {}", filename);
|
||||||
System.out.println("文件大小: " + filesize);
|
log.debug("文件大小: {}", filesize);
|
||||||
System.out.println("文件直链: " + fileurl);
|
log.debug("文件直链: {}", fileurl);
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
promise.complete(fileurl.replace("\\x26", "&"));
|
promise.complete(fileurl.replace("\\x26", "&"));
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package cn.qaiu.util;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -10,6 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class URLUtil {
|
public class URLUtil {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(URLUtil.class);
|
||||||
|
|
||||||
private final Map<String, String> queryParams = new HashMap<>();
|
private final Map<String, String> queryParams = new HashMap<>();
|
||||||
|
|
||||||
// 构造函数,传入URL并解析参数
|
// 构造函数,传入URL并解析参数
|
||||||
@@ -31,7 +36,7 @@ public class URLUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
LOGGER.error("URL解析失败: {}", url, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class CacheManager {
|
|||||||
} else {
|
} else {
|
||||||
LOGGER.warn("No rows affected when updating cache link info for shareKey: {}", cacheLinkInfo.getShareKey());
|
LOGGER.warn("No rows affected when updating cache link info for shareKey: {}", cacheLinkInfo.getShareKey());
|
||||||
}
|
}
|
||||||
}).onFailure(Throwable::printStackTrace);
|
}).onFailure(e -> LOGGER.error("缓存链接更新失败", e));
|
||||||
|
|
||||||
if (cacheLinkInfo.getFileInfo() != null) {
|
if (cacheLinkInfo.getFileInfo() != null) {
|
||||||
String sql2 = """
|
String sql2 = """
|
||||||
@@ -123,7 +123,7 @@ public class CacheManager {
|
|||||||
} else {
|
} else {
|
||||||
LOGGER.warn("No rows affected when inserting pan file info for shareKey: {}", cacheLinkInfo.getShareKey());
|
LOGGER.warn("No rows affected when inserting pan file info for shareKey: {}", cacheLinkInfo.getShareKey());
|
||||||
}
|
}
|
||||||
}).onFailure(Throwable::printStackTrace);
|
}).onFailure(e -> LOGGER.error("文件信息插入失败", e));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class ParserApi {
|
|||||||
}
|
}
|
||||||
promise.complete(build);
|
promise.complete(build);
|
||||||
}).onFailure(t->{
|
}).onFailure(t->{
|
||||||
t.printStackTrace();
|
log.error("获取统计信息失败", t);
|
||||||
promise.complete(build);
|
promise.complete(build);
|
||||||
});
|
});
|
||||||
return promise.future();
|
return promise.future();
|
||||||
|
|||||||
Reference in New Issue
Block a user