Poison


  • 首页

  • 归档

  • 标签

  • 搜索
close
Poison

Recv-Q

发表于 2022-03-25

在一次帮同事排查问题的过程中,我发现当派发请求的线程因 OOM 终止后,netstat 命令显示的 Recv-Q 与设置的 backlog 并不完全相同,而是存在 Recv-Q = backlog + 1 的关系,比如执行 netstat -tulnp 命令输出如下:

1
2
3
4
5
6
7
8
9
10
11
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.11:43043 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1/java
tcp 0 0 0.0.0.0:2021 0.0.0.0:* LISTEN 1/java
tcp 0 0 0.0.0.0:22222 0.0.0.0:* LISTEN 1/java
tcp 0 0 0.0.0.0:8719 0.0.0.0:* LISTEN 1/java
tcp 101 0 0.0.0.0:80 0.0.0.0:* LISTEN 1/java
tcp 51 0 0.0.0.0:1234 0.0.0.0:* LISTEN 1/java
tcp 0 0 0.0.0.0:20891 0.0.0.0:* LISTEN 1/java
udp 0 0 127.0.0.11:55285 0.0.0.0:* -
阅读全文 »
Poison

Fastjson Generic Deserialization Error

发表于 2022-03-07

今天帮同事查了个关于 fastjson 反序列化的问题,现象是一处反序列化的代码在发布至测试环境一段时间后反序列化的结果不正确,且该问题在本地无法复现。经过排查,确认与泛型的反序列化有关,该组应用的 fastjson 版本为 1.2.29,简化相关代码后有如下类:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package me.tianshuang;

public class ApiResult<T> {
private T data;

public T getData() {
return data;
}

public void setData(T data) {
this.data = data;
}

@Override
public String toString() {
return "ApiResult{" +
"data=" + data +
'}';
}
}
阅读全文 »
Poison

LineNumberTable

发表于 2022-03-04

今天在调试时又遇到行号无法对齐的问题,因为之前开发 Java Agent 时遇到过,常见于源码 jar 与运行时 jar 不一致导致,本文简要记录。

阅读全文 »
Poison

OmitStackTraceInFastThrow

发表于 2022-03-02

今天有一台服务器频繁打印 java.lang.NullPointerException,但是不包含栈帧信息,起初我以为是应用层代码使用 log4j2 打印时直接调用了 log.error(e) 进行打印,因为该方法最终会调用异常对象的 toString() 方法然后打印出异常信息,对于 java.lang.NullPointerException 实例,最终调用的 java.lang.Throwable#toString 获取到需要打印的字符串:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Returns a short description of this throwable.
* The result is the concatenation of:
* <ul>
* <li> the {@linkplain Class#getName() name} of the class of this object
* <li> ": " (a colon and a space)
* <li> the result of invoking this object's {@link #getLocalizedMessage}
* method
* </ul>
* If {@code getLocalizedMessage} returns {@code null}, then just
* the class name is returned.
*
* @return a string representation of this throwable.
*/
public String toString() {
String s = getClass().getName();
String message = getLocalizedMessage();
return (message != null) ? (s + ": " + message) : s;
}
阅读全文 »
Poison

rangeCheck

发表于 2022-03-01

如果看过 JDK 8 中 ArrayList 的源码,你会发现存在如下代码 ArrayList.java at jdk8-b120:

1
2
3
4
5
6
7
8
9
10
/**
* Checks if the given index is in range. If not, throws an appropriate
* runtime exception. This method does *not* check if the index is
* negative: It is always used immediately prior to an array access,
* which throws an ArrayIndexOutOfBoundsException if index is negative.
*/
private void rangeCheck(int index) {
if (index >= size)
throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
}
阅读全文 »
12…23

115 日志
128 标签
GitHub
© 2016 - 2022 Poison 蜀ICP备16000644号
由 Hexo 强力驱动
主题 - NexT.Mist