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 2012/07/15 09:53:43 UTC
svn commit: r1361646 - in /river/jtsk/trunk: qa/ src/com/sun/jini/fiddler/
src/com/sun/jini/norm/ src/com/sun/jini/start/
src/org/apache/river/api/security/ src/org/apache/river/impl/net/
Author: peter_firmstone
Date: Sun Jul 15 07:53:42 2012
New Revision: 1361646
URL: http://svn.apache.org/viewvc?rev=1361646&view=rev
Log:
Fixing URI / URL issues on windows, fixing Thread.sleep replacements for Thread.yield
Added:
river/jtsk/trunk/src/org/apache/river/impl/net/
river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java
- copied, changed from r1361523, river/jtsk/trunk/src/org/apache/river/api/security/UriString.java
Removed:
river/jtsk/trunk/src/org/apache/river/api/security/UriString.java
Modified:
river/jtsk/trunk/qa/build.xml
river/jtsk/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java
river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java
river/jtsk/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java
river/jtsk/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java
Modified: river/jtsk/trunk/qa/build.xml
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/qa/build.xml?rev=1361646&r1=1361645&r2=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/qa/build.xml (original)
+++ river/jtsk/trunk/qa/build.xml Sun Jul 15 07:53:42 2012
@@ -368,7 +368,7 @@
<target name="run-categories" depends="james-brown" description="Execute QA test categories">
<!-- categories can be found under packages com.sun.jini.test.impl and com.sun.jini.test.spec, some of them: -->
<!--<property name="test.categories" value="id,loader,policyprovider,locatordiscovery,activation,
- config,constraint,discoverymanager,discoveryservice,joinmanager,url,
+ config,constraint,discoverymanager,discoveryservice,joinmanager,url,lookupservice,
eventmailbox,jeri,iiop,jrmp,reliability,scalability,thread,renewalservice"/>-->
<property name="run.categories" value="joinmanager"/>
<testrun>
Modified: river/jtsk/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java?rev=1361646&r1=1361645&r2=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java Sun Jul 15 07:53:42 2012
@@ -2427,11 +2427,19 @@ class FiddlerImpl implements ServerProxy
*/
final long endTime = System.currentTimeMillis()+MAX_UNEXPORT_DELAY;
boolean unexported = false;
- /* Unexport only if there are no pending or in-progress calls*/
- while(!unexported && (System.currentTimeMillis() < endTime)) {
- unexported = serverExporter.unexport(false);
- if(!unexported) Thread.yield();
- }//end loop
+ boolean interrupted = false;
+ /* Unexport only if there are no pending or in-progress calls*/
+ while(!unexported && (System.currentTimeMillis() < endTime)) {
+ unexported = serverExporter.unexport(false);
+ if(!unexported) try {
+ Thread.sleep(500L);
+ } catch (InterruptedException ex) {
+ interrupted = true;
+ continue;
+ }
+ }//end loop
+ // Restore the interrupt.
+ if (interrupted) Thread.currentThread().interrupt();
if(!unexported) {//Not yet unexported. Forcibly unexport
serverExporter.unexport(true);
}//endif
Modified: river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java?rev=1361646&r1=1361645&r2=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java Sun Jul 15 07:53:42 2012
@@ -1045,9 +1045,7 @@ abstract class NormServerBaseImpl
}
try {
// Give other threads a chance to run
- long expires = set.getExpiration() - System.currentTimeMillis();
- // Thread sleep time decreases as it approaches the lease expiration.
- Thread.sleep(expires / 2);
+ Thread.sleep(100L);
// Thread.yield();
} catch (InterruptedException ex) {
// Reset the interrupt status.
@@ -1617,9 +1615,7 @@ abstract class NormServerBaseImpl
if (!unexported) {
// Thread.yield();
try {
- // Sleep time decreases as we approach the max delay
- // and retries increase.
- Thread.sleep((end_time - System.currentTimeMillis())/2);
+ Thread.sleep(100L);
} catch (InterruptedException e){
// Reset interrupt status
Thread.currentThread().interrupt();
Modified: river/jtsk/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java?rev=1361646&r1=1361645&r2=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java (original)
+++ river/jtsk/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java Sun Jul 15 07:53:42 2012
@@ -21,13 +21,18 @@ package com.sun.jini.start;
import java.io.File;
import java.io.FilePermission;
import java.io.Serializable;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.MalformedURLException;
+import java.net.URI;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.river.impl.net.UriString;
/**
* {@link Permission} class used by the
@@ -97,6 +102,36 @@ public final class SharedActivationPolic
policyPermission = init(policy);
}
+// /**
+// * Contains common code to all constructors.
+// */
+// private Permission init(final String policy) {
+// /*
+// * In order to leverage the <code>FilePermission</code> logic
+// * we need to make sure that forward slashes ("/"), in
+// * <code>URLs</code>, are converted to
+// * the appropriate system dependent <code>File.separatorChar</code>.
+// * For example,
+// * http://host:port/* matches http://host:port/bogus.jar under
+// * UNIX, but not under Windows since "\*" is the wildcard there.
+// */
+// if (policy == null) throw new NullPointerException("Null policy string not allowed");
+// String uncanonicalPath = null;
+// try {
+// URL url = new URL(policy);
+// uncanonicalPath = url.toExternalForm();
+// uncanonicalPath = uncanonicalPath.replace('/', File.separatorChar);
+// if (DEBUG) {
+// System.out.println("SharedActivationPolicyPermission::init() - "
+// + policy + " => " + uncanonicalPath);
+// }
+// } catch (MalformedURLException me) {
+// uncanonicalPath = policy;
+// }
+//
+// return new FilePermission(uncanonicalPath, "read");
+// }
+
/**
* Contains common code to all constructors.
*/
@@ -114,15 +149,17 @@ public final class SharedActivationPolic
String uncanonicalPath = null;
try {
URL url = new URL(policy);
- uncanonicalPath = url.toExternalForm();
- uncanonicalPath = uncanonicalPath.replace('/', File.separatorChar);
+ uncanonicalPath = UriString.escapeIllegalCharacters(url.toExternalForm());
+ uncanonicalPath = new File(new URI(uncanonicalPath)).getPath();
if (DEBUG) {
System.out.println("SharedActivationPolicyPermission::init() - "
+ policy + " => " + uncanonicalPath);
}
} catch (MalformedURLException me) {
uncanonicalPath = policy;
- }
+ } catch (URISyntaxException ex){
+ uncanonicalPath = policy;
+ }
return new FilePermission(uncanonicalPath, "read");
}
Modified: river/jtsk/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java?rev=1361646&r1=1361645&r2=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java (original)
+++ river/jtsk/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java Sun Jul 15 07:53:42 2012
@@ -22,6 +22,7 @@
package org.apache.river.api.security;
+import org.apache.river.impl.net.UriString;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
@@ -284,7 +285,8 @@ class DefaultPolicyParser implements Pol
Segment seg = segment(s,p);
Collection<String> urls = new ArrayList<String>();
while ( seg.hasNext() ){
- urls.add(seg.next().replace(File.separatorChar, '/'));
+// urls.add(seg.next().replace(File.separatorChar, '/'));
+ urls.add(seg.next());
}
return urls;
}
Copied: river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java (from r1361523, river/jtsk/trunk/src/org/apache/river/api/security/UriString.java)
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java?p2=river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java&p1=river/jtsk/trunk/src/org/apache/river/api/security/UriString.java&r1=1361523&r2=1361646&rev=1361646&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/api/security/UriString.java (original)
+++ river/jtsk/trunk/src/org/apache/river/impl/net/UriString.java Sun Jul 15 07:53:42 2012
@@ -15,8 +15,9 @@
* limitations under the License.
*/
-package org.apache.river.api.security;
+package org.apache.river.impl.net;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -28,7 +29,7 @@ import java.util.Map;
*
* @author Peter Firmstone.
*/
-class UriString {
+public class UriString {
private final static Map<Character,String> escaped = new HashMap<Character,String>();
private final static Collection<Character> alpha;
@@ -78,7 +79,7 @@ class UriString {
addArrayToCollection(alpha, upalpha);
}
- static void escapes(Character [] unicode, String[] escape){
+ private static void escapes(Character [] unicode, String[] escape){
int l = unicode.length;
if (l != escape.length) throw new IllegalArgumentException("unequal arrays");
for (int i = 0; i < l; i++){
@@ -86,23 +87,28 @@ class UriString {
}
}
- static void addArrayToCollection(Collection<Character> col, char [] chars){
+ private static void addArrayToCollection(Collection<Character> col, char [] chars){
int l = chars.length;
for ( int i = 0; i < l; i++){
col.add(chars[i]);
}
}
- static String escapeIllegalCharacters(String url){
+ public static String escapeIllegalCharacters(String url){
boolean isFile = url.startsWith("file:");
char [] u = url.toCharArray();
int l = u.length;
StringBuilder sb = new StringBuilder();
for (int i=0; i<l; i++){
- if (isFile && i == 5 && url.startsWith(":", 6 )) {
- //Windows drive letter without leading slashes.
- if ( alpha.contains(u[i])){
- sb.append("///");
+ if (isFile){
+ // Ensure we use forward slashes
+ if (u[i] == File.separatorChar) u[i] = '/';
+ if (i == 5 && url.startsWith(":", 6 )) {
+ // Windows drive letter without leading slashes doesn't comply
+ // with URI spec, fix it here.
+ if ( alpha.contains(u[i])){
+ sb.append("///");
+ }
}
}
Character c = Character.valueOf(u[i]);