You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by mm...@apache.org on 2021/08/24 18:41:36 UTC
[ignite] branch master updated: IGNITE-15367 Fix unnecessary socket
shutdown and close log output (#9353)
This is an automated email from the ASF dual-hosted git repository.
mmuzaf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 4714f6a IGNITE-15367 Fix unnecessary socket shutdown and close log output (#9353)
4714f6a is described below
commit 4714f6a85c8b6cda9956d247dc820da44134e402
Author: Maxim Muzafarov <mm...@apache.org>
AuthorDate: Tue Aug 24 21:41:04 2021 +0300
IGNITE-15367 Fix unnecessary socket shutdown and close log output (#9353)
---
.../apache/ignite/internal/util/IgniteUtils.java | 39 +++++++++++++---------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 947fa54..e06f11e 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -74,6 +74,7 @@ import java.net.URLClassLoader;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileLock;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
@@ -244,6 +245,7 @@ import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
@@ -4236,22 +4238,29 @@ public abstract class IgniteUtils {
* @param log Logger to log possible checked exception with (optional).
*/
public static void close(@Nullable Socket sock, @Nullable IgniteLogger log) {
- if (sock != null) {
- try {
- // Avoid tls 1.3 incompatibility https://bugs.openjdk.java.net/browse/JDK-8208526
- sock.shutdownOutput();
- sock.shutdownInput();
- }
- catch (Exception e) {
- warn(log, "Failed to shutdown socket: " + e.getMessage(), e);
- }
+ if (sock == null)
+ return;
- try {
- sock.close();
- }
- catch (Exception e) {
- warn(log, "Failed to close socket: " + e.getMessage(), e);
- }
+ try {
+ // Avoid tls 1.3 incompatibility https://bugs.openjdk.java.net/browse/JDK-8208526
+ sock.shutdownOutput();
+ sock.shutdownInput();
+ }
+ catch (ClosedChannelException | SocketException ex) {
+ LT.warn(log, "Failed to shutdown socket", ex);
+ }
+ catch (Exception e) {
+ warn(log, "Failed to shutdown socket: " + e.getMessage(), e);
+ }
+
+ try {
+ sock.close();
+ }
+ catch (ClosedChannelException | SocketException ex) {
+ LT.warn(log, "Failed to close socket", ex);
+ }
+ catch (Exception e) {
+ warn(log, "Failed to close socket: " + e.getMessage(), e);
}
}