今天有同事搭建项目的冒烟环境,搭建了快一天一直没搭建成功。后来,晚上我帮忙查看的时候,发现系统在启动的时候大部分的service都启动失败,这些service都在通过log4j打log的时候就开始抛出异常,异常信息如下:
Caused by: java.lang.NullPointerException: null buffer || null address
at java.net.PlainDatagramSocketImpl.send(Native Method)
at java.net.DatagramSocket.send(DatagramSocket.java:612)
at org.apache.log4j.helpers.SyslogWriter.write(SyslogWriter.java:69)
at org.apache.log4j.helpers.QuietWriter.write(QuietWriter.java:39)
at org.apache.log4j.helpers.SyslogQuietWriter.write(SyslogQuietWriter.java:45)
第一反应是不可思议,竟然通过log4j写日志出现异常了。后来发现当我们通过一个不可解析的SocketAddress来发送DatagramPacket信息时会抛出上诉的异常,这个异常信息太烂了,这是jdk的一个bug。查出这个问题之后就好办了,在对应的log4j.xml配置文件里面有配置了一个Appender来将日志写到一台远程机器上;而对应的机器名并没有加入DNS解析中,导致对应的主机找不到,抛出上述异常;后添加DNS解析后,应用恢复正常。
怕日后忘记,在此做个小记~~
分享到:
相关推荐
if (status == ERROR_BUFFER_OVERFLOW) { adapterInfo = (struct适应器信息结构体*)malloc(bufLen); if (adapterInfo == NULL) { // 内存分配失败 } status = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_...
==539==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff3a152c9c at pc 0x4009b6 bp 0x7fff3a152c60 sp 0x7fff3a152c58 WRITE of size 4 at 0x7fff3a152c9c thread T0 #0 0x4009b5 in main /home...
handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); } catch (Exception e) { // 处理异常 } } public static void ReadCallback(IAsyncResult ...
WriteLog(string.Format("接收消息 {0}:{1,-5} 发送消息 {2}", remote.Address, remote.Port, msg)); EvtReceiveData(msg); } } catch (Exception exception) { WriteLog("接收消息" + exception.Message); ...
在这个例子中,它将`buffer`指向的前`count`个字节设置为`c`的值。 6. **字符查找** - `strchr` ```c char* strchr(char *str, int c) { assert(str != NULL); for (; *str != (char)c; ++str) if (*str == '\...
HWND progressBar = CreateWindowEx(NULL, PROGRESS_CLASS, NULL, WS_CHILD | PBS_MARQUEE, 0, 0, 0, 0, hWnd, NULL, hInstance, NULL); SetWindowLong(progressBar, GWL_STYLE, PBS_SMOOTH | PBS_MARQUEE); ...
SOCKET clientSocket = accept(serverSocket, NULL, NULL); ``` 之后,服务端和客户端就可以通过这两个套接字进行数据交换,例如使用`send`和`recv`函数: ```cpp char buffer[1024]; int bytesReceived = recv...
DeviceIoControl(hDevice, IOCTL_NDIS_QUERY_GLOBAL_STATS, &OID_802_3_CURRENT_ADDRESS, sizeof(OID_802_3_CURRENT_ADDRESS), &adapterInfo, sizeof(adapterInfo), &bytesReturned, NULL)) { CloseHandle(hDevice)...
首先,IP地址(Internet Protocol Address)是互联网上的设备独一无二的标识符,它分为IPv4和IPv6两种类型。IPv4由32位二进制数组成,通常以点分十进制的形式表示,如192.168.1.1;而IPv6则是128位二进制,以冒号...
for (PIP_ADAPTER_UNICAST_ADDRESS address = adapter->FirstUnicastAddress; address; address = address->Next) { if (address->Address.lpSockaddr->sa_family == AF_INET) { sockaddr_in* sin = (sockaddr_in...
代码中定义了一个结构体`ASTAT`,包含`ADAPTER_STATUS`结构和`NAME_BUFFER`数组,`ADAPTER_STATUS`用于存储网卡的状态信息,包括MAC地址。`getmac_one`函数是获取MAC地址的主要逻辑。 1. 首先,使用`NCBRESET`命令...
if (GetLastError() == ERROR_BUFFER_OVERFLOW) { adapters = (PIP_ADAPTER_ADDRESSES)malloc(len); GetAdaptersAddresses(AF_UNSPEC, flags, NULL, &adapters, &len); } if (adapters != NULL) { PIP_...
例如,如果遇到连接问题,可能需要检查其中的“bind-address”参数,确保服务器监听正确的IP地址;如果性能问题,可能需要调整“innodb_buffer_pool_size”以优化内存使用。 对于初学者,理解my.ini文件的结构和...
SOCKET clientSocket = accept(listenSocket, NULL, NULL); // 接收客户端数据 char recvBuffer[1024]; int recvResult = recv(clientSocket, recvBuffer, 1024, 0); // 发送响应数据 char sendBuffer[] = "Hello,...
inet_ntop(sa->sa_family, &((struct sockaddr_in6*)sa)->sin6_addr, buffer, bufferLength); break; default: break; } } ``` 在这个例子中,`GetAdaptersAddresses()`返回所有网络接口的详细信息,包括IP...
factory.setAddress("http://localhost:8080/MyService"); Server server = factory.create(); // 注册自定义拦截器 server.getInInterceptors().add(new InInterceptor()); server.start(); } } ``` ####...
if (status == ERROR_BUFFER_OVERFLOW) { pAddresses = (IP_ADAPTER_ADDRESSES*)malloc(outBufLen); status = GetAdapterAddresses(AF_UNSPEC, 0, NULL, pAddresses, &outBufLen); } if (status == NO_ERROR) ...
GetAdaptersAddresses(AF_UNSPEC, flags, NULL, NULL, &bufferLen); PIP_ADAPTER_ADDRESSES addresses = new ULONG[bufferLen]; if (GetAdaptersAddresses(AF_UNSPEC, flags, NULL, addresses, &bufferLen) == NO...
SOCKET clientSocket = accept(serverSocket, NULL, NULL); char buffer[1024]; recv(clientSocket, buffer, 1024, 0); printf("Received: %s\n", buffer); send(clientSocket, "Hello, Client!", strlen("Hello, ...