Poison


  • 首页

  • 归档

  • 标签

  • 搜索
close
Poison

java.lang.NoSuchFieldError: Companion

发表于 2022-09-13

今天查了个与 OkHttp Maven 依赖相关的问题,本文做简单记录。起因是我们遇到一个 OkHttp 3.14.2 中存在的 bug,且此 bug 在新版本中已得到修复,于是我们将 OkHttp 升级到了最新的稳定版 4.10.0。且升级前还确认了 Upgrading to OkHttp 4 - OkHttp 中提到的不兼容的改动与该工程无关。升级后 CI 各个环境发布均正常,直到同事反馈本地工程启动报错:

1
2
3
4
5
Caused by: java.lang.NoSuchFieldError: Companion
at okhttp3.internal.Util.<clinit>(Util.kt:70) ~[okhttp-4.10.0.jar:?]
at okhttp3.internal.concurrent.TaskRunner.<clinit>(TaskRunner.kt:309) ~[okhttp-4.10.0.jar:?]
at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:41) ~[okhttp-4.10.0.jar:?]
at okhttp3.ConnectionPool.<init>(ConnectionPool.kt:47) ~[okhttp-4.10.0.jar:?]
阅读全文 »
Poison

RestartClassLoader

发表于 2022-09-05

今天帮同事查了个问题,在此简单记录。起因是同事在本地开发一段时间后会触发这样的异常:

1
2
3
4
5
2022-09-05 18:10:28.172 ERROR - [nio-8079-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet]:175 - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: me.tianshuang.dto.BizDTO cannot be cast to me.tianshuang.dto.BizDTO] with root cause

java.lang.ClassCastException: me.tianshuang.dto.BizDTO cannot be cast to me.tianshuang.dto.BizDTO
at net.sf.cglib.empty.Object$$BeanCopierByCGLIB$$ac6a32c6.copy(<generated>) ~[na:na]
at me.tianshuang.bean.BeanCopy.copy(BeanCopy.java:51) ~[commons-tool-1.0-SNAPSHOT.jar:na]
阅读全文 »
Poison

Allocation Rate

发表于 2022-08-29

今天排查了个内存申请率较高的问题,单个节点上 Allocation Rate 为 700MB/s,Promoted Rate 仅 300KB/s,而通过查看该组应用的历史监控,发现 Allocation Rate 之前从未超过 200MB/s。自最近一个版本发布后,Allocation Rate 翻了几倍,通过 async-profiler 对内存申请进行分析发现为业务中一段类型转换的代码导致,即 String.valueOf(long l) 方法,最后通过优化业务代码实现解决该问题。

2022-09-20

类似地,今天查了个由业务中滥用 RequestMapping 中的正则匹配导致内存申请率高的问题,此时不能直接通过请求的 URL 直接查询出关联的 HandlerMethod,而需要遍历所有的 mapping 去尝试正则匹配,导致内存申请率高,相关源码位于 AbstractHandlerMethodMapping.java at v3.2.18:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Look up the best-matching handler method for the current request.
* If multiple matches are found, the best match is selected.
* @param lookupPath mapping lookup path within the current servlet mapping
* @param request the current request
* @return the best-matching handler method, or {@code null} if no match
* @see #handleMatch(Object, String, HttpServletRequest)
* @see #handleNoMatch(Set, String, HttpServletRequest)
*/
protected HandlerMethod lookupHandlerMethod(String lookupPath, HttpServletRequest request) throws Exception {
List<Match> matches = new ArrayList<Match>();
List<T> directPathMatches = this.urlMap.get(lookupPath);
if (directPathMatches != null) {
addMatchingMappings(directPathMatches, matches, request);
}
if (matches.isEmpty()) {
// No choice but to go through all mappings...
addMatchingMappings(this.handlerMethods.keySet(), matches, request);
}

if (!matches.isEmpty()) {
// ...
return bestMatch.handlerMethod;
}
else {
return handleNoMatch(handlerMethods.keySet(), lookupPath, request);
}
}

private void addMatchingMappings(Collection<T> mappings, List<Match> matches, HttpServletRequest request) {
for (T mapping : mappings) {
T match = getMatchingMapping(mapping, request);
if (match != null) {
matches.add(new Match(match, this.handlerMethods.get(mapping)));
}
}
}
阅读全文 »
Poison

String Concatenation

发表于 2022-08-26

今天看了个因字符串拼接导致的 CPU 高的问题,首先是监控 Agent 持续对一个实例进行告警,并抓取到了 CPU 高的相关 Java 线程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
lwpId: 17, CPU usage: 52.9
"G1 Concurrent Refinement Thread#0" os_prio=0 tid=0x00007fa73002e000 nid=0x11 runnable

lwpId: 198, CPU usage: 47.1
"http-nio-80-exec-42" #188 daemon prio=5 os_prio=0 tid=0x00007fa71409e800 nid=0xc6 runnable [0x00007fa6c942b000]
java.lang.Thread.State: RUNNABLE
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at me.tianshuang.tool.StringUtil.listToString(StringUtil.java:433)
at sun.reflect.GeneratedMethodAccessor1008.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
阅读全文 »
Poison

FailedRequestFilter

发表于 2022-08-24

今天帮同事查了个参数丢失的问题,确认是由参数大小超过 Tomcat 默认限制引起,源码位于 tomcat/Request.java:

1
2
3
4
5
6
7
8
9
10
if ((maxPostSize >= 0) && (len > maxPostSize)) {
Context context = getContext();
if (context != null && context.getLogger().isDebugEnabled()) {
context.getLogger().debug(
sm.getString("coyoteRequest.postTooLarge"));
}
checkSwallowInput();
parameters.setParseFailedReason(FailReason.POST_TOO_LARGE);
return;
}
阅读全文 »
1…456…28

138 日志
126 标签
GitHub LeetCode
© 2026 Poison 蜀ICP备16000644号
由 Hexo 强力驱动
主题 - NexT.Mist