/hg/icedtea-web: 3 new changesets
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Fri Feb 14 08:12:51 PST 2014
changeset dd0226500903 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=dd0226500903
author: Jiri Vanek <jvanek at redhat.com>
date: Wed Feb 12 18:36:45 2014 +0100
Fixed behaviour of href in jnlp file to correctly download another it if it is remote
* netx/net/sourceforge/jnlp/Launcher.java: (fromUrl) if file is not local, and have href and href point elsewhere, then it is used as future jnlpfile
* tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java: (launchRemoteChangedFileWithHref) adapted to new behaviour
changeset 14ed5b5d8ccd in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=14ed5b5d8ccd
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Feb 13 12:52:42 2014 +0100
Added possibility to follow redirects for javaws in demand by -allowredirect switch.
changeset d2563e68c74a in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=d2563e68c74a
author: Jiri Vanek <jvanek at redhat.com>
date: Thu Feb 13 12:56:17 2014 +0100
Get rid of ConcurrentModificationException in Console output.
diffstat:
ChangeLog | 30 +++
netx/net/sourceforge/jnlp/Launcher.java | 11 +
netx/net/sourceforge/jnlp/cache/ResourceTracker.java | 98 ++++++++-
netx/net/sourceforge/jnlp/resources/Messages.properties | 1 +
netx/net/sourceforge/jnlp/runtime/Boot.java | 4 +
netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java | 13 +
netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java | 10 +-
tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java | 5 +-
8 files changed, 151 insertions(+), 21 deletions(-)
diffs (302 lines):
diff -r 8a12faa4525d -r d2563e68c74a ChangeLog
--- a/ChangeLog Wed Feb 12 13:52:13 2014 +0100
+++ b/ChangeLog Thu Feb 13 12:56:17 2014 +0100
@@ -1,3 +1,33 @@
+2014-02-13 Jiri Vanek <jvanek at redhat.com>
+
+ Get rid of ConcurrentModificationException in Console output.
+ * netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java: (importList)
+ now synchronise over original data, instead of (somtimes by) copy as, wrongly, before.
+
+2014-02-13 Jiri Vanek <jvanek at redhat.com>
+
+ Added possibility to follow redirects for javaws in demand by
+ -allowredirect switch.
+ * netx/net/sourceforge/jnlp/cache/ResourceTracker.java: added inner class
+ (CodeWithRedirect), which stores server result and possible redirection target
+ (getUrlResponseCode) is only wrapper around new (getUrlResponseCodeWithRedirectonResult)
+ which returns (CodeWithRedirect). It fills url form Location header field if
+ any. (findBestUrl) now follow 301,302,303,307,308 redirects if enabled
+ and valid - otherwise new (RedirectionException) is thrown.
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: described
+ -allowredirect by (BOredirect) key.
+ * netx/net/sourceforge/jnlp/runtime/Boot.java: and
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: added handling of
+ -allowredirect. New (allowRedirect) field.
+
+2014-02-12 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed behaviour of href in jnlp file to correctly download another it if it is remote
+ * netx/net/sourceforge/jnlp/Launcher.java: (fromUrl) if file is not local, and
+ have href and href point elsewhere, then it is used as future jnlpfile
+ * tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java:
+ (launchRemoteChangedFileWithHref) adapted to new behaviour
+
2014-02-12 Jiri Vanek <jvanek at redhat.com>
Implemented Codebase manifest entry handling.
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/Launcher.java
--- a/netx/net/sourceforge/jnlp/Launcher.java Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/Launcher.java Thu Feb 13 12:56:17 2014 +0100
@@ -465,6 +465,17 @@
if (file.getSourceLocation() != null) {
haveHref = true;
}
+ if (!isLocal && haveHref){
+ //this is case when remote file have href to different file
+ if (!location.equals(file.getSourceLocation())){
+ //mark local true, so the folowing condition will be true and
+ //new jnlp file will be downlaoded
+ isLocal = true;
+ //maybe this check is to strict, and will force redownlaod to often
+ //another check can be just on jnlp name. But it will not work
+ //if the href will be the file of same name, but on diferent path (or even domain)
+ }
+ }
if (isLocal && haveHref) {
file = new JNLPFile(file.getSourceLocation(), parserSettings);
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/cache/ResourceTracker.java
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Thu Feb 13 12:56:17 2014 +0100
@@ -849,21 +849,55 @@
}
}
/**
- * Connects to the given URL, and grabs a response code if the URL uses
- * the HTTP protocol, or returns an arbitrary valid HTTP response code.
- *
- * @return the response code if HTTP connection, or HttpURLConnection.HTTP_OK if not.
+ * testing wrapper
+ *
+ * @param url
+ * @param requestProperties
+ * @param requestMethod
+ * @return
* @throws IOException
*/
- static int getUrlResponseCode(URL url, Map<String, String> requestProperties, String requestMethod) throws IOException {
+ static int getUrlResponseCode(URL url, Map<String, String> requestProperties, String requestMethod) throws IOException {
+ return getUrlResponseCodeWithRedirectonResult(url, requestProperties, requestMethod).result;
+ }
+
+ private static class CodeWithRedirect {
+
+ int result = HttpURLConnection.HTTP_OK;
+ URL URL;
+
+ public boolean shouldRedirect() {
+ return (result == 301
+ || result == 302
+ || result == 303/*?*/
+ || result == 307
+ || result == 308);
+ }
+
+ public boolean isInvalid() {
+ return (result < 200 || result >= 300);
+ }
+ }
+
+ /**
+ * Connects to the given URL, and grabs a response code and redirecton if
+ * the URL uses the HTTP protocol, or returns an arbitrary valid HTTP
+ * response code.
+ *
+ * @return the response code if HTTP connection and redirection value, or
+ * HttpURLConnection.HTTP_OK and null if not.
+ * @throws IOException
+ */
+ static CodeWithRedirect getUrlResponseCodeWithRedirectonResult(URL url, Map<String, String> requestProperties, String requestMethod) throws IOException {
+ CodeWithRedirect result = new CodeWithRedirect();
URLConnection connection = url.openConnection();
- for (Map.Entry<String, String> property : requestProperties.entrySet()){
+ for (Map.Entry<String, String> property : requestProperties.entrySet()) {
connection.addRequestProperty(property.getKey(), property.getValue());
}
if (connection instanceof HttpURLConnection) {
- HttpURLConnection httpConnection = (HttpURLConnection)connection;
+ HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.setRequestMethod(requestMethod);
int responseCode = httpConnection.getResponseCode();
@@ -872,10 +906,24 @@
* See http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html */
HttpUtils.consumeAndCloseConnectionSilently(httpConnection);
- return responseCode;
+ result.result = responseCode;
}
- return HttpURLConnection.HTTP_OK /* return a valid response code */;
+ Map<String, List<String>> header = connection.getHeaderFields();
+ for (Map.Entry<String, List<String>> entry : header.entrySet()) {
+ OutputController.getLogger().log("Key : " + entry.getKey() + " ,Value : " + entry.getValue());
+ }
+ /*
+ * Do this only on 301,302,303(?)307,308>
+ * Now setting value for all, and lets upper stack to handle it
+ */
+ String possibleRedirect = connection.getHeaderField("Location");
+ if (possibleRedirect != null && possibleRedirect.trim().length() > 0) {
+ result.URL = new URL(possibleRedirect);
+ }
+
+ return result;
+
}
@@ -898,15 +946,25 @@
+ resource.toString() + " : " + urls);
for (String requestMethod : requestMethods) {
- for (URL url : urls) {
+ for (int i = 0; i < urls.size(); i++) {
+ URL url = urls.get(i);
try {
Map<String, String> requestProperties = new HashMap<String, String>();
requestProperties.put("Accept-Encoding", "pack200-gzip, gzip");
- int responseCode = getUrlResponseCode(url, requestProperties, requestMethod);
-
- if (responseCode < 200 || responseCode >= 300) {
- OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "For " + resource.toString() + " the server returned " + responseCode + " code for " + requestMethod + " request for " + url.toExternalForm());
+ CodeWithRedirect response = getUrlResponseCodeWithRedirectonResult(url, requestProperties, requestMethod);
+ if (response.shouldRedirect()){
+ if (response.URL == null) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Although " + resource.toString() + " got redirect " + response.result + " code for " + requestMethod + " request for " + url.toExternalForm() + " the target was null. Not following");
+ } else {
+ OutputController.getLogger().log(OutputController.Level.MESSAGE_DEBUG, "Resource " + resource.toString() + " got redirect " + response.result + " code for " + requestMethod + " request for " + url.toExternalForm() + " adding " + response.URL.toExternalForm()+" to list of possible urls");
+ if (!JNLPRuntime.isAllowRedirect()){
+ throw new RedirectionException("The resource " + url.toExternalForm() + " is being redirected (" + response.result + ") to " + response.URL.toExternalForm() + ". This is disabled by default. If you wont to allow it, run javaws with -allowredirect parameter.");
+ }
+ urls.add(response.URL);
+ }
+ } else if (response.isInvalid()) {
+ OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "For " + resource.toString() + " the server returned " + response.result + " code for " + requestMethod + " request for " + url.toExternalForm());
} else {
OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "best url for " + resource.toString() + " is " + url.toString() + " by " + requestMethod);
return url; /* This is the best URL */
@@ -1127,6 +1185,18 @@
}
}
+ private static class RedirectionException extends RuntimeException {
+
+ public RedirectionException(String string) {
+ super(string);
+ }
+
+ public RedirectionException(Throwable cause) {
+ super(cause);
+ }
+
+ }
+
// inner classes
/**
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties Thu Feb 13 12:56:17 2014 +0100
@@ -208,6 +208,7 @@
BOStrict = Enables strict checking of JNLP file format.
BOViewer = Shows the trusted certificate viewer.
BOXml = Uses a strict XML parser to parse the JNLP file.
+BOredirect = Allow to follow 301, 302, 303, 307 and 308 redirections
BXnofork = Do not create another JVM.
BXclearcache= Clean the JNLP application cache.
BXignoreheaders= Skip jar header verification.
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/runtime/Boot.java
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Thu Feb 13 12:56:17 2014 +0100
@@ -111,6 +111,7 @@
+ " -headless " + R("BOHeadless") + "\n"
+ " -strict " + R("BOStrict") + "\n"
+ " -xml " + R("BOXml") + "\n"
+ + " -allowredirect " + R("BOredirect") + "\n"
+ " -Xnofork " + R("BXnofork") + "\n"
+ " -Xclearcache " + R("BXclearcache") + "\n"
+ " -Xignoreheaders " + R("BXignoreheaders") + "\n"
@@ -186,6 +187,9 @@
if (null != getOption("-Xignoreheaders")) {
JNLPRuntime.setIgnoreHeaders(true);
}
+ if (null != getOption("-allowredirect")) {
+ JNLPRuntime.setAllowRedirect(true);
+ }
JNLPRuntime.setInitialArgments(Arrays.asList(argsIn));
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Thu Feb 13 12:56:17 2014 +0100
@@ -143,6 +143,9 @@
/** all security dialogs will be consumed and pretented as being verified by user and allowed.*/
private static boolean trustAll=false;
+
+ /** allows 301.302.303.307.308 redirects to be followed when downloading resources*/
+ private static boolean allowRedirect = false;;
/**
* Header is not checked and so eg
@@ -441,6 +444,16 @@
checkInitialized();
headless = enabled;
}
+
+ public static void setAllowRedirect(boolean enabled) {
+ checkInitialized();
+ allowRedirect = enabled;
+ }
+
+ public static boolean isAllowRedirect() {
+ return allowRedirect;
+ }
+
/**
* Sets whether we will verify code signing.
diff -r 8a12faa4525d -r d2563e68c74a netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java
--- a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java Wed Feb 12 13:52:13 2014 +0100
+++ b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java Thu Feb 13 12:56:17 2014 +0100
@@ -142,10 +142,12 @@
}
List<MessageWithHeader> sortedList;
- if (start == 0) {
- sortedList = preSort(dataProvider.getData(), sortByLocal);
- } else {
- sortedList = preSort(Collections.synchronizedList(dataProvider.getData().subList(start, dataProvider.getData().size())), sortByLocal);
+ synchronized (dataProvider.getData()) {
+ if (start == 0) {
+ sortedList = preSort(dataProvider.getData(), sortByLocal);
+ } else {
+ sortedList = preSort(Collections.synchronizedList(dataProvider.getData().subList(start, dataProvider.getData().size())), sortByLocal);
+ }
}
lastUpdateIndex = dataProvider.getData().size();
diff -r 8a12faa4525d -r d2563e68c74a tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java
--- a/tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java Wed Feb 12 13:52:13 2014 +0100
+++ b/tests/reproducers/simple/GeneratedId/testcases/GeneratedIdTest.java Thu Feb 13 12:56:17 2014 +0100
@@ -150,13 +150,12 @@
//remote
//have href
- //should NOT be redownloaded
- //href is different file
+ //should be redownloaded as href is different file
@Test
public void launchRemoteChangedFileWithHref() throws Exception {
File f = prepareChangedFileWithHref();
ProcessResult pr = server.executeJavawsHeadless("/" + f.getName());
- Assert.assertTrue("Stdout should contain '" + okBase2 + "', but did not.", pr.stdout.contains(okBase2));
+ Assert.assertTrue("Stdout should contain '" + okBase1 + "', but did not.", pr.stdout.contains(okBase1));
}
@Test
More information about the distro-pkg-dev
mailing list