Author: markt Date: Fri Dec 3 18:07:52 2010 New Revision: 1041940 URL: http://svn.apache.org/viewvc?rev=1041940&view=rev Log: Revert r1041120 but disable rather than delete new test
Added: tomcat/trunk/.fbprefs Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java tomcat/trunk/java/org/apache/coyote/ProtocolHandler.java tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java tomcat/trunk/webapps/docs/changelog.xml Added: tomcat/trunk/.fbprefs URL: http://svn.apache.org/viewvc/tomcat/trunk/.fbprefs?rev=1041940&view=auto ============================================================================== --- tomcat/trunk/.fbprefs (added) +++ tomcat/trunk/.fbprefs Fri Dec 3 18:07:52 2010 @@ -0,0 +1,127 @@ +#FindBugs User Preferences +#Thu Dec 02 16:10:08 GMT 2010 +detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true +detectorBadAppletConstructor=BadAppletConstructor|false +detectorBadResultSetAccess=BadResultSetAccess|true +detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true +detectorBadUseOfReturnValue=BadUseOfReturnValue|true +detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true +detectorBooleanReturnNull=BooleanReturnNull|true +detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false +detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true +detectorCheckTypeQualifiers=CheckTypeQualifiers|true +detectorCloneIdiom=CloneIdiom|true +detectorComparatorIdiom=ComparatorIdiom|true +detectorConfusedInheritance=ConfusedInheritance|true +detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true +detectorCrossSiteScripting=CrossSiteScripting|true +detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true +detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true +detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true +detectorDontUseEnum=DontUseEnum|true +detectorDroppedException=DroppedException|true +detectorDumbMethodInvocations=DumbMethodInvocations|true +detectorDumbMethods=DumbMethods|true +detectorDuplicateBranches=DuplicateBranches|true +detectorEmptyZipFileEntry=EmptyZipFileEntry|true +detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true +detectorFinalizerNullsFields=FinalizerNullsFields|true +detectorFindBadCast2=FindBadCast2|true +detectorFindBadForLoop=FindBadForLoop|true +detectorFindCircularDependencies=FindCircularDependencies|false +detectorFindDeadLocalStores=FindDeadLocalStores|true +detectorFindDoubleCheck=FindDoubleCheck|true +detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true +detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true +detectorFindFinalizeInvocations=FindFinalizeInvocations|true +detectorFindFloatEquality=FindFloatEquality|true +detectorFindHEmismatch=FindHEmismatch|true +detectorFindInconsistentSync2=FindInconsistentSync2|true +detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true +detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true +detectorFindMaskedFields=FindMaskedFields|true +detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true +detectorFindNakedNotify=FindNakedNotify|true +detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true +detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true +detectorFindNonShortCircuit=FindNonShortCircuit|true +detectorFindNullDeref=FindNullDeref|true +detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true +detectorFindOpenStream=FindOpenStream|true +detectorFindPuzzlers=FindPuzzlers|true +detectorFindRefComparison=FindRefComparison|true +detectorFindReturnRef=FindReturnRef|true +detectorFindRunInvocations=FindRunInvocations|true +detectorFindSelfComparison=FindSelfComparison|true +detectorFindSelfComparison2=FindSelfComparison2|true +detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true +detectorFindSpinLoop=FindSpinLoop|true +detectorFindSqlInjection=FindSqlInjection|true +detectorFindTwoLockWait=FindTwoLockWait|true +detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true +detectorFindUnconditionalWait=FindUnconditionalWait|true +detectorFindUninitializedGet=FindUninitializedGet|true +detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true +detectorFindUnreleasedLock=FindUnreleasedLock|true +detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true +detectorFindUnsyncGet=FindUnsyncGet|true +detectorFindUselessControlFlow=FindUselessControlFlow|true +detectorFormatStringChecker=FormatStringChecker|true +detectorHugeSharedStringConstants=HugeSharedStringConstants|true +detectorIDivResultCastToDouble=IDivResultCastToDouble|true +detectorIncompatMask=IncompatMask|true +detectorInconsistentAnnotations=InconsistentAnnotations|true +detectorInefficientMemberAccess=InefficientMemberAccess|false +detectorInefficientToArray=InefficientToArray|true +detectorInfiniteLoop=InfiniteLoop|true +detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true +detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false +detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true +detectorInitializationChain=InitializationChain|true +detectorInstantiateStaticClass=InstantiateStaticClass|true +detectorInvalidJUnitTest=InvalidJUnitTest|true +detectorIteratorIdioms=IteratorIdioms|true +detectorLazyInit=LazyInit|true +detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true +detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true +detectorMethodReturnCheck=MethodReturnCheck|true +detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true +detectorMutableLock=MutableLock|true +detectorMutableStaticFields=MutableStaticFields|true +detectorNaming=Naming|true +detectorNumberConstructor=NumberConstructor|true +detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true +detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true +detectorPublicSemaphores=PublicSemaphores|false +detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true +detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true +detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true +detectorRedundantInterfaces=RedundantInterfaces|true +detectorRepeatedConditionals=RepeatedConditionals|true +detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true +detectorSerializableIdiom=SerializableIdiom|true +detectorStartInConstructor=StartInConstructor|true +detectorStaticCalendarDetector=StaticCalendarDetector|true +detectorStringConcatenation=StringConcatenation|true +detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true +detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true +detectorSwitchFallthrough=SwitchFallthrough|true +detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true +detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true +detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true +detectorURLProblems=URLProblems|true +detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true +detectorUnnecessaryMath=UnnecessaryMath|true +detectorUnreadFields=UnreadFields|true +detectorUseObjectEquals=UseObjectEquals|false +detectorUselessSubclassMethod=UselessSubclassMethod|false +detectorVarArgsProblems=VarArgsProblems|true +detectorVolatileUsage=VolatileUsage|true +detectorWaitInLoop=WaitInLoop|true +detectorWrongMapIterator=WrongMapIterator|true +detectorXMLFactoryBypass=XMLFactoryBypass|true +detector_threshold=2 +effort=default +filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false +filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL| +run_at_full_build=false Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Fri Dec 3 18:07:52 2010 @@ -895,7 +895,6 @@ public class Connector extends Lifecycle // Initialize adapter adapter = new CoyoteAdapter(this); protocolHandler.setAdapter(adapter); - protocolHandler.setDomain(getDomain()); // Make sure parseBodyMethodsSet has a default if(null == parseBodyMethodsSet) Modified: tomcat/trunk/java/org/apache/coyote/ProtocolHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ProtocolHandler.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ProtocolHandler.java (original) +++ tomcat/trunk/java/org/apache/coyote/ProtocolHandler.java Fri Dec 3 18:07:52 2010 @@ -91,11 +91,4 @@ public interface ProtocolHandler { * Destroy the protocol (optional). */ public void destroy() throws Exception; - - - /** - * Domain for registering handler with JMX. - */ - public void setDomain(String domain); - public String getDomain(); } Modified: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Fri Dec 3 18:07:52 2010 @@ -251,12 +251,6 @@ public abstract class AbstractAjpProtoco return oname; } - @Override - public void setDomain(String domain) { - this.domain = domain; - } - - @Override public String getDomain() { return domain; } Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Fri Dec 3 18:07:52 2010 @@ -28,7 +28,6 @@ import javax.management.ObjectName; import org.apache.coyote.Adapter; import org.apache.coyote.ProtocolHandler; -import org.apache.coyote.RequestGroupInfo; import org.apache.juli.logging.Log; import org.apache.tomcat.util.modeler.Registry; import org.apache.tomcat.util.net.AbstractEndpoint; @@ -118,38 +117,7 @@ public abstract class AbstractHttp11Prot return ("http-" + encodedAddr + endpoint.getPort()); } - @Override - public void init() throws Exception { - if (this.domain != null) { - try { - tpOname = new ObjectName - (domain + ":" + "type=ThreadPool,name=" + getName()); - Registry.getRegistry(null, null) - .registerComponent(endpoint, tpOname, null ); - } catch (Exception e) { - getLog().error("Can't register endpoint"); - } - rgOname=new ObjectName(domain + - ":type=GlobalRequestProcessor,name=" + getName()); - Registry.getRegistry(null, null).registerComponent( - getRequestGroupInfo(), rgOname, null ); - } - - endpoint.setName(getName()); - - try { - endpoint.init(); - } catch (Exception ex) { - getLog().error( - sm.getString("http11protocol.endpoint.initerror"), ex); - throw ex; - } - if (getLog().isInfoEnabled()) - getLog().info(sm.getString("http11protocol.init", getName())); - } - protected abstract RequestGroupInfo getRequestGroupInfo(); - @Override public void pause() throws Exception { try { @@ -396,6 +364,9 @@ public abstract class AbstractHttp11Prot public int getSoLinger() { return endpoint.getSoLinger(); } public void setSoLinger(int soLinger) { endpoint.setSoLinger(soLinger); } + @Override + public abstract void init() throws Exception; + // -------------------- JMX related methods -------------------- protected String domain; @@ -406,17 +377,11 @@ public abstract class AbstractHttp11Prot return oname; } - @Override public String getDomain() { return domain; } @Override - public void setDomain(String domain) { - this.domain = domain; - } - - @Override public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { oname=name; Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Fri Dec 3 18:07:52 2010 @@ -73,14 +73,37 @@ public class Http11AprProtocol extends A */ @Override public void init() throws Exception { - + endpoint.setName(getName()); ((AprEndpoint)endpoint).setHandler(cHandler); - - super.init(); + + try { + endpoint.init(); + } catch (Exception ex) { + log.error(sm.getString("http11protocol.endpoint.initerror"), ex); + throw ex; + } + if(log.isInfoEnabled()) + log.info(sm.getString("http11protocol.init", getName())); + } @Override public void start() throws Exception { + if( this.domain != null ) { + try { + tpOname=new ObjectName + (domain + ":" + "type=ThreadPool,name=" + getName()); + Registry.getRegistry(null, null) + .registerComponent(endpoint, tpOname, null ); + } catch (Exception e) { + log.error("Can't register threadpool" ); + } + rgOname=new ObjectName + (domain + ":type=GlobalRequestProcessor,name=" + getName()); + Registry.getRegistry(null, null).registerComponent + ( cHandler.global, rgOname, null ); + } + try { endpoint.start(); } catch (Exception ex) { @@ -97,12 +120,6 @@ public class Http11AprProtocol extends A super.destroy(); } - @Override - protected RequestGroupInfo getRequestGroupInfo() { - return cHandler.global; - } - - private Http11ConnectionHandler cHandler; public boolean getUseSendfile() { return ((AprEndpoint)endpoint).getUseSendfile(); } Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Fri Dec 3 18:07:52 2010 @@ -76,16 +76,39 @@ public class Http11NioProtocol extends A */ @Override public void init() throws Exception { - + endpoint.setName(getName()); ((NioEndpoint)endpoint).setHandler(cHandler); + + try { + endpoint.init(); + sslImplementation = new JSSEImplementation(); + } catch (Exception ex) { + log.error(sm.getString("http11protocol.endpoint.initerror"), ex); + throw ex; + } + if(log.isInfoEnabled()) + log.info(sm.getString("http11protocol.init", getName())); - super.init(); } @Override public void start() throws Exception { + if( this.domain != null ) { + try { + tpOname=new ObjectName + (domain + ":" + "type=ThreadPool,name=" + getName()); + Registry.getRegistry(null, null) + .registerComponent(endpoint, tpOname, null ); + } catch (Exception e) { + log.error("Can't register threadpool" ); + } + rgOname=new ObjectName + (domain + ":type=GlobalRequestProcessor,name=" + getName()); + Registry.getRegistry(null, null).registerComponent + ( cHandler.global, rgOname, null ); + } + try { - sslImplementation = new JSSEImplementation(); endpoint.start(); } catch (Exception ex) { log.error(sm.getString("http11protocol.endpoint.starterror"), ex); @@ -96,12 +119,6 @@ public class Http11NioProtocol extends A } - @Override - protected RequestGroupInfo getRequestGroupInfo() { - return cHandler.global; - } - - // -------------------- Properties-------------------- Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri Dec 3 18:07:52 2010 @@ -85,14 +85,9 @@ public class Http11Protocol extends Abst @Override public void init() throws Exception { - + ((JIoEndpoint)endpoint).setName(getName()); ((JIoEndpoint)endpoint).setHandler(cHandler); - super.init(); - } - - @Override - public void start() throws Exception { // Verify the validity of the configured socket factory try { if (isSSLEnabled()) { @@ -120,6 +115,34 @@ public class Http11Protocol extends Abst } try { + endpoint.init(); + } catch (Exception ex) { + log.error(sm.getString("http11protocol.endpoint.initerror"), ex); + throw ex; + } + if (log.isInfoEnabled()) + log.info(sm.getString("http11protocol.init", getName())); + + } + + @Override + public void start() throws Exception { + if (this.domain != null) { + try { + tpOname = new ObjectName + (domain + ":" + "type=ThreadPool,name=" + getName()); + Registry.getRegistry(null, null) + .registerComponent(endpoint, tpOname, null ); + } catch (Exception e) { + log.error("Can't register endpoint"); + } + rgOname=new ObjectName + (domain + ":type=GlobalRequestProcessor,name=" + getName()); + Registry.getRegistry(null, null).registerComponent + ( cHandler.global, rgOname, null ); + } + + try { endpoint.start(); } catch (Exception ex) { log.error(sm.getString("http11protocol.endpoint.starterror"), ex); @@ -135,14 +158,6 @@ public class Http11Protocol extends Abst cHandler.recycledProcessors.clear(); super.destroy(); } - - - @Override - protected RequestGroupInfo getRequestGroupInfo() { - return cHandler.global; - } - - // ------------------------------------------------------------- Properties @@ -354,4 +369,6 @@ public class Http11Protocol extends Abst } } + + } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Fri Dec 3 18:07:52 2010 @@ -128,6 +128,11 @@ public abstract class AbstractEndpoint { protected volatile boolean paused = false; /** + * Track the initialization state of the endpoint. + */ + protected boolean initialized = false; + + /** * Are we using an internal executor */ protected volatile boolean internalExecutor = false; @@ -444,10 +449,7 @@ public abstract class AbstractEndpoint { } - public void init() throws Exception { - // TODO JMX Registration? - } - + public abstract void init() throws Exception; public abstract void start() throws Exception; /** Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Fri Dec 3 18:07:52 2010 @@ -362,10 +362,14 @@ public class AprEndpoint extends Abstrac /** - * Start the APR endpoint, creating acceptor, poller and sendfile threads. + * Initialize the endpoint. */ @Override - public void start() throws Exception { + public void init() + throws Exception { + + if (initialized) + return; // Create the root APR memory pool try { @@ -515,6 +519,21 @@ public class AprEndpoint extends Abstrac useSendfile = false; } + initialized = true; + + } + + + /** + * Start the APR endpoint, creating acceptor, poller and sendfile threads. + */ + @Override + public void start() + throws Exception { + // Initialize socket if not done before + if (!initialized) { + init(); + } if (!running) { running = true; paused = false; @@ -639,7 +658,18 @@ public class AprEndpoint extends Abstrac } } shutdownExecutor(); - + } + + + /** + * Deallocate APR memory pools, and close server socket. + */ + @Override + public void destroy() throws Exception { + if (running) { + stop(); + } + // Destroy pool if it was initialised if (serverSockPool != 0) { Pool.destroy(serverSockPool); @@ -659,17 +689,8 @@ public class AprEndpoint extends Abstrac Pool.destroy(rootPool); rootPool = 0; } - } - - /** - * Deallocate APR memory pools, and close server socket. - */ - @Override - public void destroy() throws Exception { - if (running) { - stop(); - } + initialized = false; } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Fri Dec 3 18:07:52 2010 @@ -322,8 +322,12 @@ public class JIoEndpoint extends Abstrac // -------------------- Public methods -------------------- @Override - public void start() throws Exception { + public void init() + throws Exception { + if (initialized) + return; + // Initialize thread count defaults for acceptor if (acceptorThreadCount == 0) { acceptorThreadCount = 1; @@ -393,7 +397,19 @@ public class JIoEndpoint extends Abstrac throw be; } } - + //if( serverTimeout >= 0 ) + // serverSocket.setSoTimeout( serverTimeout ); + + initialized = true; + + } + + @Override + public void start() throws Exception { + // Initialize socket if not done before + if (!initialized) { + init(); + } if (!running) { running = true; paused = false; @@ -431,16 +447,6 @@ public class JIoEndpoint extends Abstrac unlockAccept(); } shutdownExecutor(); - - if (serverSocket != null) { - try { - if (serverSocket != null) - serverSocket.close(); - } catch (Exception e) { - log.error(sm.getString("endpoint.err.close"), e); - } - serverSocket = null; - } } /** @@ -451,6 +457,16 @@ public class JIoEndpoint extends Abstrac if (running) { stop(); } + if (serverSocket != null) { + try { + if (serverSocket != null) + serverSocket.close(); + } catch (Exception e) { + log.error(sm.getString("endpoint.err.close"), e); + } + serverSocket = null; + } + initialized = false ; } Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Fri Dec 3 18:07:52 2010 @@ -448,28 +448,18 @@ public class NioEndpoint extends Abstrac } - public KeyManager[] wrap(KeyManager[] managers) { - if (managers==null) return null; - KeyManager[] result = new KeyManager[managers.length]; - for (int i=0; i<result.length; i++) { - if (managers[i] instanceof X509KeyManager && getKeyAlias()!=null) { - result[i] = new NioX509KeyManager((X509KeyManager)managers[i],getKeyAlias()); - } else { - result[i] = managers[i]; - } - } - return result; - } - - // ----------------------------------------------- Public Lifecycle Methods /** - * Start the NIO endpoint, creating acceptor, poller threads. + * Initialize the endpoint. */ @Override - public void start() throws Exception { + public void init() + throws Exception { + + if (initialized) + return; serverSock = ServerSocketChannel.open(); socketProperties.setProperties(serverSock.socket()); @@ -535,7 +525,34 @@ public class NioEndpoint extends Abstrac if (oomParachute>0) reclaimParachute(true); selectorPool.open(); + initialized = true; + + } + + public KeyManager[] wrap(KeyManager[] managers) { + if (managers==null) return null; + KeyManager[] result = new KeyManager[managers.length]; + for (int i=0; i<result.length; i++) { + if (managers[i] instanceof X509KeyManager && getKeyAlias()!=null) { + result[i] = new NioX509KeyManager((X509KeyManager)managers[i],getKeyAlias()); + } else { + result[i] = managers[i]; + } + } + return result; + } + + /** + * Start the NIO endpoint, creating acceptor, poller threads. + */ + @Override + public void start() + throws Exception { + // Initialize socket if not done before + if (!initialized) { + init(); + } if (!running) { running = true; paused = false; @@ -570,7 +587,7 @@ public class NioEndpoint extends Abstrac * Stop the endpoint. This will cause all processing threads to stop. */ @Override - public void stop() throws Exception { + public void stop() { if (!paused) { pause(); } @@ -590,13 +607,6 @@ public class NioEndpoint extends Abstrac processorCache.clear(); shutdownExecutor(); - // Close server socket - serverSock.socket().close(); - serverSock.close(); - serverSock = null; - sslContext = null; - releaseCaches(); - selectorPool.close(); } @@ -611,7 +621,14 @@ public class NioEndpoint extends Abstrac if (running) { stop(); } - + // Close server socket + serverSock.socket().close(); + serverSock.close(); + serverSock = null; + sslContext = null; + initialized = false; + releaseCaches(); + selectorPool.close(); if (log.isDebugEnabled()) { log.debug("Destroy completed for "+new InetSocketAddress(getAddress(),getPort())); } Modified: tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java (original) +++ tomcat/trunk/test/org/apache/tomcat/util/net/TestXxxEndpoint.java Fri Dec 3 18:07:52 2010 @@ -29,7 +29,7 @@ import org.apache.catalina.startup.Tomca */ public class TestXxxEndpoint extends TomcatBaseTest { - public void testStartStop() throws Exception { + public void disbaletestStartStop() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File(getBuildDirectory(), "webapps/examples"); tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath()); Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1041940&r1=1041939&r2=1041940&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Dec 3 18:07:52 2010 @@ -82,12 +82,8 @@ of the deprecated Embedded class. (markt) </fix> <fix> - <bug>50360</bug>: Further Lifecycle refactoring for Connectors and - associated components. The socket is now bound on - <code>Connector.start()</code> rather than - <code>Connector.init()</code> and the socket is released on - <code>Connector.stop()</code> rather than - <code>Connector.destroy()</code>.(markt) + Further Lifecycle refactoring for Connectors and associated components. + (markt) </fix> <fix> Correct handling of versioned web applications in deployer. (markt) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org