src/java.base/share/classes/java/net/SocketPermission.java
changeset 58653 71fef5fae9cc
parent 58388 a819c684964b
child 58659 4113f16d5109
--- a/src/java.base/share/classes/java/net/SocketPermission.java	Mon Oct 14 18:48:10 2019 -0700
+++ b/src/java.base/share/classes/java/net/SocketPermission.java	Wed Oct 16 14:32:17 2019 -0700
@@ -287,6 +287,11 @@
      * @param host the hostname or IP address of the computer, optionally
      * including a colon followed by a port or port range.
      * @param action the action string.
+     *
+     * @throws NullPointerException if any parameters are null
+     * @throws IllegalArgumentException if the format of {@code host} is
+     *         invalid, or if the {@code action} string is empty, malformed, or
+     *         contains an action other than the specified possible actions
      */
     public SocketPermission(String host, String action) {
         super(getHost(host));
@@ -589,14 +594,15 @@
             // like "ackbarfaccept".  Also, skip to the comma.
             boolean seencomma = false;
             while (i >= matchlen && !seencomma) {
-                switch(a[i-matchlen]) {
-                case ',':
-                    seencomma = true;
-                    break;
+                switch (c = a[i-matchlen]) {
                 case ' ': case '\r': case '\n':
                 case '\f': case '\t':
                     break;
                 default:
+                    if (c == ',' && i > matchlen) {
+                        seencomma = true;
+                        break;
+                    }
                     throw new IllegalArgumentException(
                             "invalid permission: " + action);
                 }