commit | 7feaf9f93d04469288510bfb40230a3aee3e4285 | [log] [tgz] |
---|---|---|
author | Robert Munteanu <rombert@apache.org> | Thu May 23 17:52:09 2019 +0200 |
committer | Robert Munteanu <robert.munteanu@gmail.com> | Thu May 23 17:59:23 2019 +0200 |
tree | 2d4c1f6c297d3de65272c7879a7d573a15d8486e | |
parent | 2571576b286d24e7b87f41da66d705c201dba659 [diff] |
POC for a Java Agent to set URL connection timeout defaults Add license headers
This module is part of the Apache Sling project.
This module provides a java agent that uses the instrumentation API to add timeouts to connect
calls made via HTTP or HTTPs without setting read and connect timeouts.
Build the project with mvn clean package
and then run a simple connection test with
java -javaagent:target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar -cp target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=<connect-timeout>,<read-timeout> org.apache.sling.uca.impl.Main <url>
The parameters are as follows:
<connect-timeout>
- connection timeout in milliseconds<read-timeout>
- read timeout in milliseconds<url>
- the URL to accessFor a test that always fails, set one of the timeouts to 1. Both executions listed below will typically fail:
java -javaagent:target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1,1000 -cp target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.apache.sling.uca.impl.Main https://sling.apache.org java -javaagent:target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1000,1 -cp target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.apache.sling.uca.impl.Main https://sling.apache.org
In contrast, the execution below should succeed:
java -javaagent:target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar=1000,1000 -cp target/url-connection-agent-0.0.1-SNAPSHOT-jar-with-dependencies.jar org.apache.sling.uca.impl.Main https://sling.apache.org