Author: peter_firmstone Date: Thu May 23 08:15:45 2013 New Revision: 1485607
URL: http://svn.apache.org/r1485607 Log: River-420 Fixes for unsafe publication during construction. Fixed NullPointerException caused by previous commit not calling export after removing it from constructor. Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/norm/OneExpireOneNotTest.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseBackEndImpl.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/TestLeaseProvider.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/lease/LeaseExpiration.java Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/norm/OneExpireOneNotTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/norm/OneExpireOneNotTest.java?rev=1485607&r1=1485606&r2=1485607&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/norm/OneExpireOneNotTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/norm/OneExpireOneNotTest.java Thu May 23 08:15:45 2013 @@ -123,6 +123,7 @@ public class OneExpireOneNotTest extends "test.normLeasePreparer", expsLease); final LeaseBackEndImpl backend = new LeaseBackEndImpl(leaseCount); + backend.export(); for (int i=0; i<leaseCount; i+=2) { long initExpiration = System.currentTimeMillis() + renewGrant; Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseBackEndImpl.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseBackEndImpl.java?rev=1485607&r1=1485606&r2=1485607&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseBackEndImpl.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseBackEndImpl.java Thu May 23 08:15:45 2013 @@ -114,7 +114,7 @@ public class LeaseBackEndImpl implements this.factoryClass = factoryClass; } - private synchronized void export() throws ExportException, RemoteException { + public synchronized void export() throws ExportException, RemoteException { LeaseBackEnd stub = (LeaseBackEnd) exporter.export(this); Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/TestLeaseProvider.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/TestLeaseProvider.java?rev=1485607&r1=1485606&r2=1485607&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/TestLeaseProvider.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/TestLeaseProvider.java Thu May 23 08:15:45 2013 @@ -59,6 +59,7 @@ public class TestLeaseProvider { */ public TestLeaseProvider(int leaseCount) throws RemoteException { leaseBackEnd = new LeaseBackEndImpl(leaseCount); + leaseBackEnd.export(); } /** @@ -73,6 +74,7 @@ public class TestLeaseProvider { public TestLeaseProvider(int leaseCount, Class factoryClass) throws RemoteException { leaseBackEnd = new LeaseBackEndImpl(leaseCount, factoryClass); + leaseBackEnd.export(); } /** Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/lease/LeaseExpiration.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/lease/LeaseExpiration.java?rev=1485607&r1=1485606&r2=1485607&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/lease/LeaseExpiration.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoveryservice/lease/LeaseExpiration.java Thu May 23 08:15:45 2013 @@ -68,6 +68,7 @@ import net.jini.security.proxytrust.Serv import com.sun.jini.proxy.BasicProxyTrustVerifier; import com.sun.jini.qa.harness.Test; +import java.rmi.server.ExportException; /** * This class determines if, when a client's lease on a registration with the @@ -90,13 +91,16 @@ public class LeaseExpiration extends Abs /** Convenience class for handling the events sent by the service * with which the client (the test) has registered */ - - private Object proxy; + + public class ServiceEventListener implements RemoteEventListener, ServerProxyTrust, Serializable { + private final Exporter exporter; + private Object proxy; + public ServiceEventListener() throws RemoteException { super(); Configuration c = getConfig().getConfiguration(); @@ -110,14 +114,19 @@ public class LeaseExpiration extends Abs throw new RemoteException("Could not find listener exporter", e); } } + this.exporter = exporter; + } + + private synchronized void export() throws ExportException{ proxy = exporter.export(this); } + - public Object writeReplace() throws ObjectStreamException { + public synchronized Object writeReplace() throws ObjectStreamException { return proxy; } - public TrustVerifier getProxyVerifier() { + public synchronized TrustVerifier getProxyVerifier() { return new BasicProxyTrustVerifier(proxy); } @@ -175,14 +184,14 @@ public class LeaseExpiration extends Abs }//end class LRMListener private ServiceRegistrar srvcReg = null; - private ArrayList lookupList = new ArrayList(); + private final ArrayList lookupList = new ArrayList(); private String[] memberGroups = DiscoveryGroupManagement.NO_GROUPS; private static final int N_CYCLES_WAIT_EXPIRATION = 10; private static final long N_SECS = 30; - private long duration = N_SECS*1000; + private final long duration = N_SECS*1000; private MarshalledObject handback = null; private boolean eventReceived = false; - private Object eventLock = new Object(); + private final Object eventLock = new Object(); /** Constructs and returns the duration values (in milliseconds) to * request on each renewal attempt (can be overridden by sub-classes) @@ -205,21 +214,23 @@ public class LeaseExpiration extends Abs /* Start a lookup service */ logger.log(Level.FINE, "starting a new lookup service"); - synchronized(eventLock) { - eventReceived = false; - srvcReg = getManager().startLookupService(); // already prepared - lookupList.add( srvcReg ); + synchronized (this){ + synchronized(eventLock) { + eventReceived = false; + srvcReg = getManager().startLookupService(); // already prepared + lookupList.add( srvcReg ); + } + DiscoveryAdmin admin = DiscoveryAdminUtil.getDiscoveryAdmin(srvcReg); + memberGroups = admin.getMemberGroups(); + LocatorsUtil.displayLocator(QAConfig.getConstrainedLocator(srvcReg.getLocator()), + " lookup locator",Level.FINE); + logger.log(Level.FINE, + " lookup MemberGroup(s) = " + +GroupsUtil.toCommaSeparatedStr(memberGroups)); + handback = new MarshalledObject + (GroupsUtil.toCommaSeparatedStr(memberGroups)); + return this; } - DiscoveryAdmin admin = DiscoveryAdminUtil.getDiscoveryAdmin(srvcReg); - memberGroups = admin.getMemberGroups(); - LocatorsUtil.displayLocator(QAConfig.getConstrainedLocator(srvcReg.getLocator()), - " lookup locator",Level.FINE); - logger.log(Level.FINE, - " lookup MemberGroup(s) = " - +GroupsUtil.toCommaSeparatedStr(memberGroups)); - handback = new MarshalledObject - (GroupsUtil.toCommaSeparatedStr(memberGroups)); - return this; }//end construct /** Executes the current test by doing the following: @@ -257,7 +268,7 @@ public class LeaseExpiration extends Abs * 9. Verify that the lookup discovery service does not send anymore * discovery events to the registration's listener */ - public void run() throws Exception { + public synchronized void run() throws Exception { logger.log(Level.FINE, "run()"); if(discoverySrvc == null) { throw new TestException("could not successfully start the service " @@ -270,6 +281,7 @@ public class LeaseExpiration extends Abs /* Request a registration with the lookup discovery service */ logger.log(Level.FINE, "registering with the lookup discovery service"); ServiceEventListener eventListener = new ServiceEventListener(); + eventListener.export(); LookupDiscoveryRegistration reg = DiscoveryServiceUtil.getRegistration (discoverySrvc,
