java - IllegalArgumentException at URLPermission in jre8 -



java - IllegalArgumentException at URLPermission in jre8 -

when run code below,

-in applet on jre8, on line con.getinputstream() throws exception

-in applet on jre7 or jre6 it not throws.

-in desktop app on jre it not throws.

when remove lines starts setrequestpropery, does not throws exception on 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());

exception:

java.lang.illegalargumentexception: invalid actions string @ java.net.urlpermission.init(unknown source) @ java.net.urlpermission.<init>(unknown source) @ sun.net.www.protocol.http.httpurlconnection.urltosocketpermission(unknown source) @ sun.net.www.protocol.http.httpurlconnection.getoutputstream(unknown source)

in applet, trying open connection , need request properties.

do know causes exception on jre8? , why in applet , not desktopapp.

debugin code snippet in applet, shows parameter actions passed urlpermission, ist new win java8, has value get:pragma: not valid according javadoc argument:

the actions string of urlpermission concatenation of method list , request headers list. these lists of permitted request methods , permitted request headers of permission (respectively). 2 lists separated colon ':' character , elements of each list comma separated. examples are:

"post,get,delete" "get:x-foo-request,x-bar-request" "post,get:header1,header2"

and according code in oracle's jdk8:

int colon = actions.indexof(':'); if (actions.lastindexof(':') != colon) { throw new illegalargumentexception("invalid actions string"); }

the code above expects 1 single colon or none.

to solve problem need remove colon after pragma in call

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

running snippet simple junit test not provoke exception, because urlpermition class not invoked. whether invoked or not depends on context application running.

note. depending on context of use, request methods , headers may permitted @ times, , others may not permitted @ time. example, http protocol handler might disallow headers such content-length beingness set application code, regardless of whether security policy in force, permits it.

so seems, when in context of applet permition checks performed.

java applet httpurlconnection japplet illegalargumentexception

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -