IllegalArgumentException in URLPermission in jre8

when i run the code below

- in the Applet on JRE8, in the line con.getInputStream () it throws an exception

- in the applet on JRE7 or JRE6 he does not drop.

- in the desktop application on any JRE he does not drop.

when I delete the lines it starts with setRequestPropery , it does not throw an exception in any JRE.

        URLConnection con = new URL(adress).openConnection();
        con.setDoOutput(true);
        con.setDoInput(true);
        con.setUseCaches(false);
        con.setRequestProperty("Content-Type",
                "application/octet-stream");
        con.setRequestProperty("pragma:", "no-cache");
        PrintStream ps = new PrintStream(con.getOutputStream());
        ps.println("Test");
        ps.close();
        in = new DataInputStream(conn.getInputStream());

An exception:

java.lang.IllegalArgumentException: invalid actions string
at java.net.URLPermission.init(Unknown Source)
at java.net.URLPermission.<init>(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.URLtoSocketPermission(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)

In my applet, I am trying to open a connection, and I need these request properties.

Do you know what causes this exception in JRE8? and why only in the applet, and not in the desktopapp.

+1
1

, , actions URLPermission, ist new win java8, GET:pragma:, javadoc :

URLPermission . (). : . :

     "POST,GET,DELETE"
     "GET:X-Foo-Request,X-Bar-Request"
     "POST,GET:Header1,Header2"

oracle jdk8:

int colon = actions.indexOf(':');
if (actions.lastIndexOf(':') != colon) {
    throw new IllegalArgumentException("invalid actions string");
}

.

, pragma

con.setRequestProperty("pragma", "no-cache");

junit , URLPermition . , , .

. , . , HTTP , Content-Length, , , .

, , .

+3

All Articles