2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.remoting.transport.socket;
25
import org.jboss.remoting.Home;
26
import org.jboss.remoting.InvokerLocator;
27
import org.jboss.remoting.ServerInvoker;
28
import org.jboss.remoting.util.SecurityUtility;
29
import org.jboss.remoting.util.TimerUtil;
30
import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
31
import org.jboss.util.propertyeditor.PropertyEditors;
32
import org.jboss.logging.Logger;
34
import javax.net.ServerSocketFactory;
35
import javax.net.ssl.SSLException;
37
import java.beans.IntrospectionException;
38
import java.io.IOException;
39
import java.net.InetAddress;
40
import java.net.InetSocketAddress;
41
import java.net.ServerSocket;
42
import java.net.Socket;
43
import java.net.SocketAddress;
44
import java.net.SocketException;
45
import java.net.UnknownHostException;
46
import java.security.AccessController;
47
import java.security.PrivilegedActionException;
48
import java.security.PrivilegedExceptionAction;
49
import java.util.ArrayList;
50
import java.util.HashSet;
51
import java.util.Iterator;
52
import java.util.LinkedList;
53
import java.util.List;
55
import java.util.Properties;
57
import java.util.TimerTask;
60
* SocketServerInvoker is the server-side of a SOCKET based transport
62
* @author <a href="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
63
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
64
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
66
* @version $Revision: 5082 $
69
public class SocketServerInvoker extends ServerInvoker implements SocketServerInvokerMBean
71
private static final Logger log = Logger.getLogger(SocketServerInvoker.class);
73
private static boolean trace = log.isTraceEnabled();
75
static int clientCount = 0;
77
protected Properties props = new Properties();
79
private static int BACKLOG_DEFAULT = 200;
80
protected static int MAX_POOL_SIZE_DEFAULT = 300;
83
* Key for indicating if socket invoker should continue to keep socket connection between
84
* client and server open after invocations by sending a ping on the connection
85
* before being re-used. The default for this is false.
87
public static final String CHECK_CONNECTION_KEY = "socket.check_connection";
90
* Specifies the fully qualified class name for the custom SocketWrapper implementation to use on the server.
92
public static final String SERVER_SOCKET_CLASS_FLAG = "serverSocketClass";
93
protected String serverSocketClass = ServerSocketWrapper.class.getName();
95
protected List serverSockets = new ArrayList();
96
protected boolean running = false;
97
protected int backlog = BACKLOG_DEFAULT;
98
protected AcceptThread[] acceptThreads;
99
protected int numAcceptThreads = 1;
100
protected int maxPoolSize = MAX_POOL_SIZE_DEFAULT;
101
protected LRUPool clientpool;
102
protected LinkedList threadpool;
103
protected boolean immediateShutdown;
105
protected ServerSocketRefresh refreshThread;
106
protected boolean newServerSocketFactory = false;
107
protected Object serverSocketFactoryLock = new Object();
109
protected boolean reuseAddress = true;
110
protected int receiveBufferSize = -1;
113
* More socket configuration parameters.
115
protected boolean keepAlive;
116
protected boolean keepAliveSet;
117
protected boolean oOBInline;
118
protected boolean oOBInlineSet;
119
protected int sendBufferSize = -1;
120
protected boolean soLinger;
121
protected boolean soLingerSet;
122
protected int soLingerDuration = -1;
123
protected int trafficClass = -1;
125
// defaults to -1 as to not have idle timeouts
126
protected int idleTimeout = -1;
127
protected IdleTimerTask idleTimerTask = null;
129
protected int writeTimeout = -1;
131
public SocketServerInvoker(InvokerLocator locator)
136
public SocketServerInvoker(InvokerLocator locator, Map configuration)
138
super(locator, configuration);
142
* after a truststore update use this to
143
* set a new ServerSocketFactory to the invoker<br>
144
* then a new ServerSocket is created that accepts the new connections
145
* @param serverSocketFactory
147
public void setNewServerSocketFactory(ServerSocketFactory serverSocketFactory)
149
log.trace("entering setNewServerSocketFactory()");
150
synchronized (serverSocketFactoryLock)
152
newServerSocketFactory=true;
153
setServerSocketFactory(serverSocketFactory);
154
serverSocketFactoryLock.notify();
155
log.info("ServerSocketFactory has been updated");
160
* refreshes the serverSocket by closing old one and
161
* creating a new ServerSocket from new ServerSocketFactory
162
* @throws IOException
164
protected void refreshServerSocket() throws IOException
166
log.trace("entering refreshServerSocket()");
167
synchronized (serverSocketFactoryLock)
169
for (int i = 0; i < acceptThreads.length; i++)
171
// If release() is able to enter its synchronized block and sees
172
// serverSocket == null, then it knows that something went wrong.
173
newServerSocketFactory=false;
174
ServerSocket oldServerSocket = acceptThreads[i].getServerSocket();
175
InetAddress address = oldServerSocket.getInetAddress();
176
int port = oldServerSocket.getLocalPort();
177
oldServerSocket.close();
178
ServerSocket newServerSocket = null;
180
for (int j = 0; j < 5; j++)
184
newServerSocket = createServerSocket(port, backlog, address);
191
// Wait for end of TIME_WAIT state (1 to 4 minutes).
192
log.warn("Unable to recreate ServerSocket: will try again in 65 seconds", e);
193
try {Thread.sleep(65000);} catch (InterruptedException ignored) {}
197
log.error("Unable to recreate ServerSocket after 260 seconds", e);
203
acceptThreads[i].setServerSocket(newServerSocket);
204
log.info(acceptThreads[i] + " has been updated with new ServerSocket");
207
log.trace("leaving refreshServerSocket()");
210
protected void setup() throws Exception
212
props.putAll(getConfiguration());
213
mapJavaBeanProperties(this, props, false);
215
String ssclass = props.getProperty(SERVER_SOCKET_CLASS_FLAG);
218
serverSocketClass = ssclass;
222
protected void finalize() throws Throwable
229
* Starts the invoker.
231
* @jmx.managed-operation description = "Start sets up the ServerInvoker we are wrapping."
234
public synchronized void start() throws IOException
238
log.debug(this + " starting");
242
//need to reset to default
243
maxPoolSize = MAX_POOL_SIZE_DEFAULT;
246
clientpool = new LRUPool(2, maxPoolSize);
248
threadpool = new LinkedList();
250
createServerSockets();
252
refreshThread = new ServerSocketRefresh();
253
refreshThread.setDaemon(true);
254
refreshThread.start();
256
acceptThreads = new AcceptThread[numAcceptThreads * getHomes().size()];
258
Iterator it = serverSockets.iterator();
261
ServerSocket ss = (ServerSocket) it.next();
262
for(int j = 0; j < numAcceptThreads; j++)
264
acceptThreads[i++] = new AcceptThread(ss, refreshThread);
275
log.error("Error starting SocketServerInvoker.", e);
282
for(int i = 0; i < acceptThreads.length; i++)
284
acceptThreads[i].start();
290
if(idleTimerTask != null)
292
idleTimerTask.cancel();
294
idleTimerTask = new IdleTimerTask();
295
TimerUtil.schedule(idleTimerTask, idleTimeout * 1000);
299
if(idleTimerTask != null)
301
idleTimerTask.cancel();
305
log.debug(this + " started");
309
protected ServerSocket createServerSocket(int serverBindPort,
311
InetAddress bindAddress) throws IOException
313
ServerSocketFactory factory = getServerSocketFactory();
314
ServerSocket ss = null;
318
ss = factory.createServerSocket();
320
catch (SocketException e)
322
if (getReuseAddress())
323
log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true",e);
325
ss = factory.createServerSocket(serverBindPort, backlog, bindAddress);
326
configureServerSocket(ss);
330
ss.setReuseAddress(getReuseAddress());
331
configureServerSocket(ss);
332
InetSocketAddress address = new InetSocketAddress(bindAddress, serverBindPort);
333
bind(ss, address, backlog);
337
protected void createServerSockets() throws IOException
339
ServerSocketFactory factory = getServerSocketFactory();
341
Iterator it = getHomes().iterator();
344
Home home = (Home) it.next();
345
InetAddress inetAddress = getAddressByName(home.host);
347
ServerSocket ss = null;
350
ss = factory.createServerSocket();
351
ss.setReuseAddress(getReuseAddress());
352
configureServerSocket(ss);
353
InetSocketAddress address = new InetSocketAddress(inetAddress, home.port);
354
bind(ss, address, backlog);
355
if (log.isDebugEnabled()) log.debug(this + " created " + ss);
357
catch (SocketException e)
359
if (getReuseAddress())
360
log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true");
364
ss = factory.createServerSocket(home.port, backlog, inetAddress);
365
configureServerSocket(ss);
367
catch (IOException e2)
369
String m = this + " error creating ServerSocket[" + home + "]: " + e2.getMessage();
370
IOException e3 = new IOException(m);
375
catch (IOException e)
377
String m = this + " error creating ServerSocket[" + home + "]: " + e.getMessage();
378
IOException e2 = new IOException(m);
383
serverSockets.add(ss);
387
protected void configureServerSocket(ServerSocket ss) throws SocketException
389
if (receiveBufferSize != -1)
391
ss.setReceiveBufferSize(receiveBufferSize);
395
protected String getThreadName(int i)
397
return "AcceptorThread#" + i + ":" + getServerBindPort();
400
public void destroy()
402
if(clientpool != null)
404
synchronized (clientpool)
406
clientpool.destroy();
415
* @jmx.managed-operation description = "Stops the invoker."
418
public synchronized void stop()
427
protected void cleanup()
431
if(acceptThreads != null)
433
for(int i = 0; i < acceptThreads.length; i++)
435
acceptThreads[i].shutdown();
439
if (refreshThread != null)
440
refreshThread.shutdown();
442
if (idleTimerTask != null)
444
idleTimerTask.cancel();
447
maxPoolSize = 0; // so ServerThreads don't reinsert themselves
449
// The following code has been changed to avoid a race condition with ServerThread.run() which
450
// can result in leaving ServerThreads alive, which causes a memory leak.
451
if (clientpool != null)
453
synchronized (clientpool)
455
Set svrThreads = clientpool.getContents();
456
Iterator itr = svrThreads.iterator();
460
Object o = itr.next();
461
ServerThread st = (ServerThread) o;
462
if (immediateShutdown)
464
st.shutdownImmediately();
475
log.debug(this + " stopped threads in clientpool");
477
if (threadpool != null)
479
int threadsToShutdown = threadpool.size();
480
for(int i = 0; i < threadsToShutdown; i++)
482
ServerThread thread = (ServerThread) threadpool.removeFirst();
483
if (immediateShutdown)
485
thread.shutdownImmediately();
493
log.debug(this + " stopped threads in threadpool");
498
log.debug(this + " exiting");
502
public int getReceiveBufferSize()
504
return receiveBufferSize;
507
public void setReceiveBufferSize(int receiveBufferSize)
509
this.receiveBufferSize = receiveBufferSize;
513
* Indicates if SO_REUSEADDR is enabled on server sockets
516
public boolean getReuseAddress()
522
* Sets if SO_REUSEADDR is enabled on server sockets.
527
public void setReuseAddress(boolean reuse)
529
this.reuseAddress = reuse;
532
public boolean isKeepAlive()
537
public void setKeepAlive(boolean keepAlive)
539
this.keepAlive = keepAlive;
543
public boolean isOOBInline()
548
public void setOOBInline(boolean inline)
554
public int getSendBufferSize()
556
return sendBufferSize;
559
public void setSendBufferSize(int sendBufferSize)
561
this.sendBufferSize = sendBufferSize;
564
public boolean isSoLinger()
569
public int getSoLingerDuration()
571
return soLingerDuration;
574
public void setSoLinger(boolean soLinger)
576
this.soLinger = soLinger;
580
public void setSoLingerDuration(int soLingerDuration)
582
this.soLingerDuration = soLingerDuration;
585
public int getTrafficClass()
590
public void setTrafficClass(int trafficClass)
592
this.trafficClass = trafficClass;
596
* @return Number of idle ServerThreads
597
* @jmx:managed-attribute
599
public int getCurrentThreadPoolSize()
601
return threadpool.size();
605
* @return Number of ServerThreads current executing or waiting on an invocation
606
* @jmx:managed-attribute
608
public int getCurrentClientPoolSize()
610
return clientpool.size();
614
* Getter for property numAcceptThreads
616
* @return The number of threads that exist for accepting client connections
617
* @jmx:managed-attribute
619
public int getNumAcceptThreads()
621
return numAcceptThreads;
625
* Setter for property numAcceptThreads
627
* @param size The number of threads that exist for accepting client connections
628
* @jmx:managed-attribute
630
public void setNumAcceptThreads(int size)
632
this.numAcceptThreads = size;
636
* Setter for max pool size.
637
* The number of server threads for processing client. The default is 300.
640
* @jmx:managed-attribute
642
public int getMaxPoolSize()
648
* The number of server threads for processing client. The default is 300.
651
* @jmx:managed-attribute
653
public void setMaxPoolSize(int maxPoolSize)
655
this.maxPoolSize = maxPoolSize;
659
* @jmx:managed-attribute
661
public int getBacklog()
667
* @jmx:managed-attribute
669
public void setBacklog(int backlog)
673
this.backlog = BACKLOG_DEFAULT;
677
this.backlog = backlog;
681
public int getIdleTimeout()
687
* Sets the timeout for idle threads to be removed from pool.
688
* If the value is greater than 0, then idle timeout will be
689
* activated, otherwise no idle timeouts will occur. By default,
692
* @param idleTimeout number of seconds before a idle thread is timed out.
694
public void setIdleTimeout(int idleTimeout)
696
this.idleTimeout = idleTimeout;
702
if(idleTimerTask != null)
704
idleTimerTask.cancel();
706
idleTimerTask = new IdleTimerTask();
707
TimerUtil.schedule(idleTimerTask, idleTimeout * 1000);
711
if(idleTimerTask != null)
713
idleTimerTask.cancel();
719
public boolean isImmediateShutdown()
721
return immediateShutdown;
724
public void setImmediateShutdown(boolean immediateShutdown)
726
this.immediateShutdown = immediateShutdown;
729
public int getWriteTimeout()
734
public void setWriteTimeout(int writeTimeout)
736
this.writeTimeout = writeTimeout;
739
protected void configureSocket(Socket s) throws SocketException
741
s.setReuseAddress(getReuseAddress());
743
if (keepAliveSet) s.setKeepAlive(keepAlive);
744
if (oOBInlineSet) s.setOOBInline(oOBInline);
745
if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
746
if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize);
748
soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
749
if (trafficClass > -1) s.setTrafficClass(trafficClass);
753
* The acceptor thread should spend as little time as possbile doing any kind of operation, and
754
* under no circumstances should perform IO on the new socket, which can potentially block and
755
* lock up the server. For this reason, the acceptor thread should grab a worker thread and
756
* delegate all subsequent work to it.
758
protected void processInvocation(Socket socket) throws Exception
760
ServerThread worker = null;
761
boolean newThread = false;
763
synchronized(clientpool)
765
while(worker == null && running)
767
if(trace) { log.trace(this + " trying to get a worker thread from threadpool for processing"); }
769
if(threadpool.size() > 0)
771
worker = (ServerThread)threadpool.removeFirst();
772
if(trace) { log.trace(this + (worker == null ? " found NO threads in threadpool"
773
: " got " + worker + " from threadpool")); }
776
else if (trace) { { log.trace(this + " has an empty threadpool"); } }
780
if(clientpool.size() < maxPoolSize)
782
if(trace) { log.trace(this + " creating new worker thread"); }
783
worker = new ServerThread(socket, this, clientpool, threadpool,
784
getTimeout(), writeTimeout, serverSocketClass);
785
if(trace) { log.trace(this + " created " + worker); }
791
if(trace) {log.trace(this + " trying to evict a thread from clientpool"); }
793
clientpool.wait(1000); // Keep trying, in case all threads are not evictable.
794
if(trace) { log.trace(this + " notified of clientpool thread availability"); }
803
clientpool.insert(worker, worker);
808
if(trace) {log.trace(this + " starting " + worker); }
813
if(trace) { log.trace(this + " reusing " + worker); }
814
worker.wakeup(socket, getTimeout(), this);
819
* returns true if the transport is bi-directional in nature, for example,
820
* SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall
823
public boolean isTransportBiDirectional()
828
public String toString()
830
return "SocketServerInvoker[" + locator.getHomes() + "]";
834
* Each implementation of the remote client invoker should have
835
* a default data type that is uses in the case it is not specified
836
* in the invoker locator uri.
838
protected String getDefaultDataType()
840
return SerializableMarshaller.DATATYPE;
844
* this thread checks if a new ServerSocketFactory was set,<br>
845
* if so initializes a serversocket refresh
846
* @author Michael Voss
849
public class ServerSocketRefresh extends Thread
851
private boolean running = true;
853
public ServerSocketRefresh()
855
super("ServerSocketRefresh");
862
synchronized (serverSocketFactoryLock)
864
if(newServerSocketFactory)
866
log.debug("got notice about new ServerSocketFactory");
869
log.debug("refreshing server socket");
870
refreshServerSocket();
871
log.debug("server socket refreshed");
872
} catch (IOException e)
874
log.error("could not refresh server socket", e);
880
serverSocketFactoryLock.wait();
881
log.trace("ServerSocketRefresh thread woke up");
883
catch (InterruptedException e)
888
log.debug("ServerSocketRefresh shutting down");
892
* Let SocketServerInvoker.run() resume when refresh is completed
894
public void release() throws InvalidStateException
896
synchronized (serverSocketFactoryLock)
898
// if (serverSocket == null)
900
// throw new InvalidStateException("error refreshing ServerSocket");
902
log.trace("passed through ServerSocketRefresh.release()");
906
public void shutdown()
910
synchronized (serverSocketFactoryLock)
912
serverSocketFactoryLock.notify();
918
* The IdleTimerTask is used to periodically check the server threads to
919
* see if any have been idle for a specified amount of time, and if so,
920
* release those threads and their connections and clear from the server
923
public class IdleTimerTask extends TimerTask
927
Object[] svrThreadArray = null;
928
Set threadsToShutdown = new HashSet();
930
synchronized(clientpool)
932
Set svrThreads = clientpool.getContents();
933
svrThreadArray = svrThreads.toArray();
937
if(svrThreadArray != null)
939
log.trace("Idle timer task fired. Number of ServerThreads = " + svrThreadArray.length);
943
// iterate through pooled server threads and evict idle ones
944
if(svrThreadArray != null)
946
long currentTime = System.currentTimeMillis();
948
for(int x = 0; x < svrThreadArray.length; x++)
950
ServerThread svrThread = (ServerThread)svrThreadArray[x];
952
// check the idle time and evict
953
long idleTime = currentTime - svrThread.getLastRequestTimestamp();
957
log.trace("Idle time for ServerThread (" + svrThread + ") is " + idleTime);
960
long idleTimeout = getIdleTimeout() * 1000;
961
if(idleTime > idleTimeout)
965
log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be evicted.");
967
clientpool.remove(svrThread);
968
threadsToShutdown.add(svrThread);
969
// svrThread.shutdown();
970
// svrThread.unblock();
975
// now check idle server threads in the thread pool
976
svrThreadArray = null;
978
if(threadpool.size() > 0)
980
// now need to check the tread pool to remove threads
981
svrThreadArray = threadpool.toArray();
986
if(svrThreadArray != null)
988
log.trace("Number of ServerThread in thead pool = " + svrThreadArray.length);
992
if(svrThreadArray != null)
994
long currentTime = System.currentTimeMillis();
996
for(int x = 0; x < svrThreadArray.length; x++)
998
ServerThread svrThread = (ServerThread)svrThreadArray[x];
999
long idleTime = currentTime - svrThread.getLastRequestTimestamp();
1003
log.trace("Idle time for ServerThread (" + svrThread + ") is " + idleTime);
1006
long idleTimeout = getIdleTimeout() * 1000;
1007
if(idleTime > idleTimeout)
1011
log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be removed from thread pool.");
1013
threadpool.remove(svrThread);
1014
threadsToShutdown.add(svrThread);
1015
// svrThread.shutdown();
1021
Iterator it = threadsToShutdown.iterator();
1022
while (it.hasNext())
1024
ServerThread svrThread = (ServerThread) it.next();
1025
svrThread.shutdown();
1026
// svrThread.unblock();
1031
public class AcceptThread extends Thread
1033
ServerSocket serverSocket;
1034
ServerSocketRefresh refreshThread;
1036
public AcceptThread(ServerSocket serverSocket, ServerSocketRefresh refreshThread)
1038
this.serverSocket = serverSocket;
1039
this.refreshThread = refreshThread;
1040
setName("AcceptorThread[" + serverSocket + "]");
1041
if(trace) log.trace(SocketServerInvoker.this + " created " + this);
1046
if(trace) { log.trace(this + " started execution of method run()"); }
1052
refreshThread.release(); //goes on if serversocket refresh is completed
1054
if(trace) { log.trace(this + " is going to wait on serverSocket.accept()"); }
1056
Socket socket = accept(serverSocket);
1057
if(trace) { log.trace(this + " accepted " + socket); }
1059
// the acceptor thread should spend as little time as possbile doing any kind of
1060
// operation, and under no circumstances should perform IO on the new socket, which
1061
// can potentially block and lock up the server. For this reason, the acceptor thread
1062
// should grab a worker thread and delegate all subsequent work to it. This is what
1063
// processInvocation() does.
1065
configureSocket(socket);
1066
processInvocation(socket);
1068
catch (SSLException e)
1070
log.error("SSLServerSocket error", e);
1073
catch (InvalidStateException e)
1075
log.error("Cannot proceed without functioning server socket. Shutting down", e);
1082
log.error(this + " failed to handle socket", ex);
1086
log.trace(this + " caught exception in run()", ex);
1092
public void shutdown()
1096
serverSocket.close();
1098
catch (IOException e)
1100
log.debug(this + " error closing " + serverSocket, e);
1104
public ServerSocket getServerSocket()
1106
return serverSocket;
1109
public void setServerSocket(ServerSocket serverSocket)
1111
this.serverSocket = serverSocket;
1115
static private void mapJavaBeanProperties(final Object o, final Properties props, final boolean isStrict)
1116
throws IntrospectionException
1118
if (SecurityUtility.skipAccessControl())
1120
PropertyEditors.mapJavaBeanProperties(o, props, isStrict);
1126
AccessController.doPrivileged( new PrivilegedExceptionAction()
1128
public Object run() throws IntrospectionException
1130
PropertyEditors.mapJavaBeanProperties(o, props, isStrict);
1135
catch (PrivilegedActionException e)
1137
throw (IntrospectionException) e.getCause();
1141
static private Socket accept(final ServerSocket ss) throws IOException
1143
if (SecurityUtility.skipAccessControl())
1150
return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction()
1152
public Object run() throws Exception
1158
catch (PrivilegedActionException e)
1160
throw (IOException) e.getCause();
1164
static private void bind(final ServerSocket ss, final SocketAddress address,
1165
final int backlog) throws IOException
1167
if (SecurityUtility.skipAccessControl())
1169
ss.bind(address, backlog);
1175
AccessController.doPrivileged( new PrivilegedExceptionAction()
1177
public Object run() throws Exception
1179
ss.bind(address, backlog);
1184
catch (PrivilegedActionException e)
1186
throw (IOException) e.getCause();
1190
static private InetAddress getAddressByName(final String host) throws UnknownHostException
1192
if (SecurityUtility.skipAccessControl())
1194
return InetAddress.getByName(host);
1199
return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction()
1201
public Object run() throws IOException
1203
return InetAddress.getByName(host);
1207
catch (PrivilegedActionException e)
1209
throw (UnknownHostException) e.getCause();