Bug 570460 - java.lang.NoSuchFieldException

- add logic to not look for "socket" field of SocketInputStream if
  using Java 13 or above in HttpHijackWorkaround.getOutputStream()
- add additional logic in this method for Java 13 and above to
  find the "parent" field of Socket.SocketInputStream

Change-Id: Iebfd8b4fda0bdc373cbc1c69b5a3ea8ffacc80d2
Reviewed-on: https://git.eclipse.org/r/c/linuxtools/org.eclipse.linuxtools/+/175070
Tested-by: Linux Tools Bot <linuxtools-bot@eclipse.org>
Tested-by: Jeff Johnston <jjohnstn@redhat.com>
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/HttpHijackWorkaround.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/HttpHijackWorkaround.java
index b71b124..a8c4625 100644
--- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/HttpHijackWorkaround.java
+++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/HttpHijackWorkaround.java
@@ -1,6 +1,6 @@
 /*******************************************************************************
- * Copyright (c) 2015, 2020 Red Hat.
- * 
+ * Copyright (c) 2015, 2021 Red Hat.
+ *
  * This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License 2.0
  * which is available at https://www.eclipse.org/legal/epl-2.0/
@@ -24,10 +24,9 @@
 
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.linuxtools.docker.core.Activator;
-import org.osgi.framework.Bundle;
-
 import org.mandas.docker.client.LogReader;
 import org.mandas.docker.client.LogStream;
+import org.osgi.framework.Bundle;
 
 /**
  * This is a workaround for lack of HTTP Hijacking support in Apache
@@ -106,13 +105,28 @@
 			}
 			list.add(new String[] { "sun.security.ssl.AppInputStream", fName }); //$NON-NLS-1$
 		} else {
-			list.add(new String[] { "java.net.SocketInputStream", "socket" }); //$NON-NLS-1$ //$NON-NLS-2$
+			float jvmVersion = Float.parseFloat(
+					System.getProperty("java.specification.version")); //$NON-NLS-1$
+			if (jvmVersion < 13f) {
+				list.add(new String[] { "java.net.SocketInputStream", //$NON-NLS-1$
+						"socket" }); //$NON-NLS-1$
+			}
 		}
 
 		Object res = getInternalField(stream, list, bundles);
 		if (res instanceof WritableByteChannel) {
 			return (WritableByteChannel) res;
-		} else if (res instanceof Socket) {
+		} else if (res != null && res.getClass().getCanonicalName()
+				.equals("java.net.Socket.SocketInputStream")) { //$NON-NLS-1$
+			// if we are here, we are Java 13 or higher and have to use an
+			// alternate field reflection to get the socket
+			List<String[]> list2 = new LinkedList<>();
+			list2.add(new String[] { "java.net.Socket$SocketInputStream", //$NON-NLS-1$
+					"parent" }); //$NON-NLS-1$
+			res = getInternalField(res, list2, bundles);
+		}
+
+		if (res instanceof Socket) {
 			return Channels.newChannel(((Socket) res).getOutputStream());
 		} else {
 			// TODO: throw an exception and let callers handle it.