HTTPConnector
Jim Fox
fox at washington.edu
Wed Oct 24 13:13:55 EDT 2018
I have some more info on this double execution. Apologize for the longish post.
Spoiler alert: If I run the script from a ScriptFile it works correctly.
Note that I am using Java 8 and nashorn.
This is the script.
=============================================================
<Script>
<![CDATA[
var Excp = Java.type("java.lang.Exception");
logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute");
logger.info("=== gws groups - in");
new Excp().printStackTrace();
var HashSet = Java.type("java.util.HashSet");
var HttpClientSupport = Java.type("net.shibboleth.utilities.java.support.httpclient.HttpClientSupport");
var IdPAttribute = Java.type("net.shibboleth.idp.attribute.IdPAttribute");
var StringAttributeValue = Java.type("net.shibboleth.idp.attribute.StringAttributeValue");
logger.info("=== gws groups - 2");
var body = HttpClientSupport.toString(response.getEntity(), "UTF-8", 65536);
var result = JSON.parse(body);
var attr = new IdPAttribute("memberOf");
var values = new HashSet();
if (result.data != null) {
for (var i=0; i<result.data.length; i++) {
values.add(new StringAttributeValue(result.data[i].id));
}
}
attr.setValues(values);
connectorResults.add(attr);
logger.info("=== gws groups - out");
]]>
</Script>
=============================================================
Note the printStackTrace at line 4. When I run this I get two stack traces.
The first starts:
java.lang.Exception
at jdk.nashorn.internal.scripts.Script$26$\^eval\_.:program(<eval>:4)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
...
The trace comes from line 4.
The second trace starts:
java.lang.Exception
at jdk.nashorn.internal.scripts.Script$26$\^eval\_.:program(<eval>:31)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
...
The trace comes from line 31. That's past the end of the script. One gets the impression that the script was not run twice, but compiled twice.
As I said above, when I move the script to a ScriptFile it works correctly.
Jim
More information about the users
mailing list