Merge Conscrypt upstream master.

Contains the following upstream changes:
  d34311de Release event after select on Windows. Fixes #799.
  64d4b3cb Close resources InputStream after use.  Fixes #801.

Test: atest CtsLibcoreTestCases
Change-Id: Ib6ba45097ce7493e9f11eaf028149d9fb7ef644d
diff --git a/common/src/jni/main/cpp/conscrypt/native_crypto.cc b/common/src/jni/main/cpp/conscrypt/native_crypto.cc
index 52410f4..c739546 100644
--- a/common/src/jni/main/cpp/conscrypt/native_crypto.cc
+++ b/common/src/jni/main/cpp/conscrypt/native_crypto.cc
@@ -5993,6 +5993,7 @@
         } else {
             result = 1;
         }
+        WSACloseEvent(events[1]);
     } while (0);
 
     JNI_TRACE("sslSelect type=%s fd=%d appData=%p timeout_millis=%d => %d",
diff --git a/common/src/main/java/org/conscrypt/Conscrypt.java b/common/src/main/java/org/conscrypt/Conscrypt.java
index c562a69..42440fd 100644
--- a/common/src/main/java/org/conscrypt/Conscrypt.java
+++ b/common/src/main/java/org/conscrypt/Conscrypt.java
@@ -34,6 +34,7 @@
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
+import org.conscrypt.io.IoUtils;
 
 /**
  * Core API for creating and configuring all Conscrypt types.
@@ -76,8 +77,9 @@
         int major = -1;
         int minor = -1;
         int patch = -1;
+        InputStream stream = null;
         try {
-            InputStream stream = Conscrypt.class.getResourceAsStream("conscrypt.properties");
+            stream = Conscrypt.class.getResourceAsStream("conscrypt.properties");
             if (stream != null) {
                 Properties props = new Properties();
                 props.load(stream);
@@ -86,6 +88,8 @@
                 patch = Integer.parseInt(props.getProperty("org.conscrypt.version.patch", "-1"));
             }
         } catch (IOException e) {
+        } finally {
+            IoUtils.closeQuietly(stream);
         }
         if ((major >= 0) && (minor >= 0) && (patch >= 0)) {
             VERSION = new Version(major, minor, patch);
diff --git a/repackaged/common/src/main/java/com/android/org/conscrypt/Conscrypt.java b/repackaged/common/src/main/java/com/android/org/conscrypt/Conscrypt.java
index 4bbf0e0..33a3959 100644
--- a/repackaged/common/src/main/java/com/android/org/conscrypt/Conscrypt.java
+++ b/repackaged/common/src/main/java/com/android/org/conscrypt/Conscrypt.java
@@ -16,6 +16,7 @@
  */
 package com.android.org.conscrypt;
 
+import com.android.org.conscrypt.io.IoUtils;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
@@ -82,8 +83,9 @@
         int major = -1;
         int minor = -1;
         int patch = -1;
+        InputStream stream = null;
         try {
-            InputStream stream = Conscrypt.class.getResourceAsStream("conscrypt.properties");
+            stream = Conscrypt.class.getResourceAsStream("conscrypt.properties");
             if (stream != null) {
                 Properties props = new Properties();
                 props.load(stream);
@@ -92,6 +94,8 @@
                 patch = Integer.parseInt(props.getProperty("com.android.org.conscrypt.version.patch", "-1"));
             }
         } catch (IOException e) {
+        } finally {
+            IoUtils.closeQuietly(stream);
         }
         if ((major >= 0) && (minor >= 0) && (patch >= 0)) {
             VERSION = new Version(major, minor, patch);