You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2013/03/11 11:30:30 UTC
svn commit: r1455084 - in /river/jtsk/skunk/qa_refactor/trunk:
qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java
src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java
Author: peter_firmstone
Date: Mon Mar 11 10:30:30 2013
New Revision: 1455084
URL: http://svn.apache.org/r1455084
Log:
Fix LinkedList sendQueue reference escaping synchronisation in com.sun.jini.jeri.internal.mux.StreamConnectionIO.java
Added URI normalisation to codebase strings in qa tests to avoid false test failures, when codebase strings are compared. AbstractServiceAdmin
Modified:
river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java
Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java?rev=1455084&r1=1455083&r2=1455084&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java Mon Mar 11 10:30:30 2013
@@ -322,19 +322,58 @@ public abstract class AbstractServiceAdm
* if codebase integrity is required and a problem occurs
* converting the URL
*/
- protected final String getServiceCodebase() throws TestException {
+ protected final String getServiceCodebase() throws TestException, URISyntaxException {
codebase = getMandatoryParameter("codebase");
codebase = fixCodebase(codebase);
+ codebase = uriToCodebaseString(pathToURIs(codebase));
return codebase;
}
- private String normaliseCodebase(String cb) throws URISyntaxException{
- String result = UriString.escapeIllegalCharacters(cb);
- result = UriString.normalisation(new URI(result)).toString();
- return result;
+ /**
+ * Convert a string containing a space-separated list of URL Strings into a
+ * corresponding array of URI objects, throwing a MalformedURLException
+ * if any of the URLs are invalid. This method returns null if the
+ * specified string is null.
+ *
+ * @param path the string path to be converted to an array of urls
+ * @return the string path converted to an array of URLs, or null
+ * @throws MalformedURLException if the string path of urls contains a
+ * mal-formed url which can not be converted into a url object.
+ */
+ private static URI[] pathToURIs(String path) throws URISyntaxException {
+ if (path == null) {
+ return null;
+ }
+ URI[] urls = null;
+ StringTokenizer st = new StringTokenizer(path); // divide by spaces
+ urls = new URI[st.countTokens()];
+ for (int i = 0; st.hasMoreTokens(); i++) {
+ String uri = st.nextToken();
+ uri = UriString.fixWindowsURI(uri);
+ urls[i] = UriString.normalise(new URI(UriString.escapeIllegalCharacters(uri)));
+ }
+ return urls;
}
/**
+ * Convert URI[] to a space delimited code base string.
+ * @param uri
+ * @return Code base String.
+ */
+ private static String uriToCodebaseString(URI[] uri){
+ if (uri == null) throw new NullPointerException("uri was null");
+ StringBuilder sb = new StringBuilder(200);
+ int l = uri.length;
+ for (int i = 0; i < l; i++){
+ if (uri[i] != null){
+ sb.append(uri[i]);
+ if ( i != l - 1) sb.append(" ");
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
* Return the codebase originally returned by the
* <code>getServiceCodebase</code> method.
*
Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java?rev=1455084&r1=1455083&r2=1455084&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/jeri/internal/mux/StreamConnectionIO.java Mon Mar 11 10:30:30 2013
@@ -67,8 +67,10 @@ final class StreamConnectionIO extends C
/**
* queue of buffers of data to be sent over connection, interspersed
* with IOFuture objects that need to be notified in sequence
+ *
+ * Synchronised on super.mux.muxLock;
*/
- private LinkedList sendQueue = new LinkedList();
+ private final LinkedList sendQueue;
/** buffer for reading incoming data from connection */
private final ByteBuffer inputBuffer =
@@ -86,6 +88,7 @@ final class StreamConnectionIO extends C
outChannel = newChannel(out);
inChannel = newChannel(in);
+ sendQueue = new LinkedList();
}
/**
@@ -178,9 +181,9 @@ final class StreamConnectionIO extends C
"down and nothing more to send");
break;
}
-
- localQueue = sendQueue;
- sendQueue = new LinkedList();
+ /* Clone an unshared copy and clear the queue while synchronized */
+ localQueue = (LinkedList) sendQueue.clone();
+ sendQueue.clear();
}
boolean needToFlush = false;