Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection problem for ipv6 peer #670

Closed
wants to merge 1 commit into from
Closed

Fix connection problem for ipv6 peer #670

wants to merge 1 commit into from

Conversation

sulenn
Copy link
Contributor

@sulenn sulenn commented Jun 29, 2020

Fix the problem that web3sdk cannot connect to IPv6 node probabilistically

@ghost
Copy link

ghost commented Jun 29, 2020

Warnings are found on analyzing the commit 3eb9aae.

2 warnings:

We recommend to address them as possible, for example, update outdated dependencies, fix the tool's configuration, configure sider.yml, turn off unused tools, and so on.

If you are struggling with these errors or warnings, feel free to ask us via chat. 💬

@@ -92,10 +93,12 @@ public void retrySendMessage() {
errorCode = ChannelMessageError.NODES_UNREACHABLE.getError();
throw new Exception(" Failed to send message,all retry failed ");
}
String host = getFromConnection().getHost();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DU'-anomaly for variable 'host' (lines '96'-'143'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

@@ -92,10 +93,12 @@ public void retrySendMessage() {
errorCode = ChannelMessageError.NODES_UNREACHABLE.getError();
throw new Exception(" Failed to send message,all retry failed ");
}
String host = getFromConnection().getHost();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused local variables such as 'host'. (view)

Rule Ruleset Priority
UnusedLocalVariable Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -92,10 +93,12 @@ public void retrySendMessage() {
errorCode = ChannelMessageError.NODES_UNREACHABLE.getError();
throw new Exception(" Failed to send message,all retry failed ");
}
String host = getFromConnection().getHost();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +300,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +300,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -95,7 +96,8 @@ public void retrySendMessage() {

ChannelHandlerContext ctx =
fromChannelConnections.getNetworkConnectionByHost(
getFromConnection().getHost(), getFromConnection().getPort());
Inet6Address.getByName(getFromConnection().getHost()).getHostAddress(),
getFromConnection().getPort());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -106,7 +108,7 @@ public void retrySendMessage() {

logger.debug(
"send message to {}:{} success ",
fromConnection.getHost(),
Inet6Address.getByName(fromConnection.getHost()).getHostAddress(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@@ -3,6 +3,7 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.Timeout;
import java.net.Inet6Address;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid unused imports such as 'java.net.Inet6Address' (view)

Rule Ruleset Priority
UnusedImports Best Practices 4

References:

You can close this issue if no need to fix it. Learn more.

@@ -95,7 +96,8 @@ public void retrySendMessage() {

ChannelHandlerContext ctx =
fromChannelConnections.getNetworkConnectionByHost(
getFromConnection().getHost(), getFromConnection().getPort());
getFromConnection().getHost(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = "";
try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = "";
try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = "";
try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +318,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +318,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DD'-anomaly for variable 'peer' (lines '598'-'598'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DU'-anomaly for variable 'peer' (lines '598'-'611'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Logger calls should be surrounded by log level guards. (view)

Rule Ruleset Priority
GuardLogStatement Best Practices 2

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +315,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -299,6 +315,13 @@ public void init() {
String IP = connectionStr.substring(0, index);
String port = connectionStr.substring(index + 1);

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DD'-anomaly for variable 'peer' (lines '595'-'595'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DU'-anomaly for variable 'peer' (lines '595'-'608'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +320,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +320,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
@FISCO-BCOS FISCO-BCOS deleted a comment Jun 30, 2020
try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint = host + ":" + port;

try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint = host + ":" + port

try {
endpoint = Inet6Address.getByName(host).getHostAddress() + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endpoint = host + ":" + port

host = Inet6Address.getByName(host).getHostAddress();
endpoint = host + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Logger calls should be surrounded by log level guards. (view)

Rule Ruleset Priority
GuardLogStatement Best Practices 2

References:

You can close this issue if no need to fix it. Learn more.

host = Inet6Address.getByName(host).getHostAddress();
endpoint = host + ":" + port;
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Logger calls should be surrounded by log level guards. (view)

Rule Ruleset Priority
GuardLogStatement Best Practices 2

References:

You can close this issue if no need to fix it. Learn more.

@@ -245,7 +246,13 @@ public ChannelHandlerContext randomNetworkConnection(
}

public ChannelHandlerContext getNetworkConnectionByHost(String host, Integer port) {
String endpoint = host + ":" + port;
String endpoint = "";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DD'-anomaly for variable 'endpoint' (lines '249'-'252'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = host + ":" + port;
String endpoint = "";
try {
host = Inet6Address.getByName(host).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
host = Inet6Address.getByName(host).getHostAddress();
endpoint = host + ":" + port;
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = host + ":" + port;
String endpoint = "";
try {
host = Inet6Address.getByName(host).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
host = Inet6Address.getByName(host).getHostAddress();
endpoint = host + ":" + port;
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +323,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +323,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DD'-anomaly for variable 'peer' (lines '595'-'595'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

String peer = connectionInfo.getHost() + ":" + connectionInfo.getPort();
ChannelHandlerContext ctx = networkConnections.get(peer);
for (Map.Entry<String, ChannelHandlerContext> entry : networkConnections.entrySet()) {
String peer = entry.getKey();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Found 'DU'-anomaly for variable 'peer' (lines '595'-'608'). (view)

Rule Ruleset Priority
DataflowAnomalyAnalysis Error Prone 5

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +320,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -304,6 +320,13 @@ public void init() {
" Invalid configuration, invalid IP string format, value: " + IP);
}

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
IP = Inet6Address.getByName(IP).getHostAddress();
} catch (Exception e) {
throw new IllegalArgumentException(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] New exception is thrown in catch block, original stack trace may be lost (view)

Rule Ruleset Priority
PreserveStackTrace Best Practices 3

References:

You can close this issue if no need to fix it. Learn more.

@@ -260,12 +266,22 @@ public ChannelHandlerContext getNetworkConnectionByHost(String host, Integer por
*/
public ChannelHandlerContext setAndGetNetworkConnectionByHost(
String host, Integer port, ChannelHandlerContext ctx) {
try {
host = Inet6Address.getByName(host).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
host = Inet6Address.getByName(host).getHostAddress();
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Logger calls should be surrounded by log level guards. (view)

Rule Ruleset Priority
GuardLogStatement Best Practices 2

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = host + ":" + port;
return networkConnections.put(endpoint, ctx);
}

public void removeNetworkConnectionByHost(
String host, Integer port, ChannelHandlerContext ctx) {
try {
host = Inet6Address.getByName(host).getHostAddress();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Potential violation of Law of Demeter (method chain calls) (view)

Rule Ruleset Priority
LawOfDemeter Design 3

References:

You can close this issue if no need to fix it. Learn more.

String endpoint = host + ":" + port;
return networkConnections.put(endpoint, ctx);
}

public void removeNetworkConnectionByHost(
String host, Integer port, ChannelHandlerContext ctx) {
try {
host = Inet6Address.getByName(host).getHostAddress();
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block (view)

Rule Ruleset Priority
AvoidCatchingGenericException Design 3

References:

You can close this issue if no need to fix it. Learn more.

try {
host = Inet6Address.getByName(host).getHostAddress();
} catch (Exception e) {
logger.error("invalid host string format, value: " + host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PMD Java] Logger calls should be surrounded by log level guards. (view)

Rule Ruleset Priority
GuardLogStatement Best Practices 2

References:

You can close this issue if no need to fix it. Learn more.

@sulenn sulenn closed this Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants