Merge remote-tracking branch 'origin/1.2.0-beta1' into 1.2.0-beta1

This commit is contained in:
srzou 2024-07-30 16:29:51 +08:00
commit 685d430e96
2 changed files with 11 additions and 10 deletions

View File

@ -228,7 +228,7 @@ public class JsonUtil {
try {
return objectMapper.readValue(jsonString, clazz);
} catch (Exception e) {
throw new SnailJobCommonException("Json转对象失败", jsonString, e);
throw new SnailJobCommonException("Json转对象失败 参数:{}", jsonString, e);
}
}
@ -243,7 +243,7 @@ public class JsonUtil {
try {
return objectMapper.readValue(jsonString, typeReference);
} catch (Exception e) {
throw new SnailJobCommonException("Json转对象失败", e);
throw new SnailJobCommonException("Json转对象失败 参数:{}", jsonString, e);
}
}
@ -258,7 +258,7 @@ public class JsonUtil {
try {
return objectMapper.readValue(jsonString, javaType);
} catch (Exception e) {
throw new SnailJobCommonException("Json转对象失败", e);
throw new SnailJobCommonException("Json转对象失败 参数:{}", jsonString, e);
}
}
@ -272,7 +272,7 @@ public class JsonUtil {
try {
return objectMapper.readTree(jsonString);
} catch (Exception e) {
throw new SnailJobCommonException("Json转对象失败", e);
throw new SnailJobCommonException("Json转对象失败 参数:{}", jsonString, e);
}
}

View File

@ -23,12 +23,10 @@ import java.util.concurrent.TimeUnit;
*/
@Slf4j
public class NettyChannel {
private NettyChannel() {
}
private static Bootstrap bootstrap;
private static ConcurrentHashMap<Pair<String, String>, Channel> CHANNEL_MAP = new ConcurrentHashMap<>(16);
private NettyChannel() {
}
public static void setChannel(String hostId, String ip, Channel channel) {
CHANNEL_MAP.put(Pair.of(hostId, ip), channel);
@ -70,6 +68,9 @@ public class NettyChannel {
HttpVersion.HTTP_1_1, method, url, Unpooled.wrappedBuffer(body.getBytes(StandardCharsets.UTF_8)));
request.headers()
// Host
.set(HttpHeaderNames.HOST, hostIp)
// Content-Type
.set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
// 开启长连接
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE)