java.rmi.ConnectException Java Examples
The following examples show how to use
java.rmi.ConnectException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteHostOverview.java From visualvm with GNU General Public License v2.0 | 6 votes |
public double getSystemLoadAverage() { if (loadAverageAvailable) { checkJmxApp(); if (jmxApp == null) { return -1; } try { return osMXBean.getSystemLoadAverage(); } catch (UndeclaredThrowableException ex) { if (ex.getCause() instanceof ConnectException) { jmxApp = null; return getSystemLoadAverage(); } throw ex; } } return -1; }
Example #2
Source File: HbDaemo.java From Fourinone with Apache License 2.0 | 6 votes |
public void run() { try{ //System.out.println("heartbeat"); String[] putarr = new String[putList.size()]; putList.toArray(putarr); pk.heartbeat(putarr, sessionid); }catch(Exception e){ //e.printStackTrace(); LogUtil.info("[PutHbTask]", "[heartbeat:]", e.getMessage()); //this.cancel(); //HbDaemo.tm.cancel(); if(e instanceof ConnectException){ this.pk = pl.getNextLeader(); } } }
Example #3
Source File: ThrowsAdviceInterceptorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCorrectHandlerUsedForSubclass() throws Throwable { MyThrowsHandler th = new MyThrowsHandler(); ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); // Extends RemoteException ConnectException ex = new ConnectException(""); MethodInvocation mi = mock(MethodInvocation.class); given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); } catch (Exception caught) { assertEquals(ex, caught); } assertEquals(1, th.getCalls()); assertEquals(1, th.getCalls("remoteException")); }
Example #4
Source File: VMLogger.java From openjdk-systemtest with Apache License 2.0 | 6 votes |
public void writeServerData(String msg) { VMData.writeHeading(logFile, true, msg); try { envData.writeData(mbs, srvRuntimeName, srvOSName, srvLogName, true); classData.writeData(mbs, srvClassName, srvCompName, srvRuntimeName, true); memoryData.writeData(mbs, srvMemName, srvMemMgrNames, srvMemPoolNames, srvGCNames, true); threadData.writeData(mbs, srvThrdName, 8, true); } catch ( ConnectException ce) { Message.logOut("ConnectException when trying to access the Platform MBean Server"); ce.printStackTrace(); Assert.fail("ConnectException when trying to access the Platform MBean Server"); } catch ( UnmarshalException ue) { Message.logOut("UnmarshelException when trying to access the Platform MBean Server"); ue.printStackTrace(); Assert.fail("UnmarshelException when trying to access the Platform MBean Server"); } }
Example #5
Source File: ThrowsAdviceInterceptorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCorrectHandlerUsedForSubclass() throws Throwable { MyThrowsHandler th = new MyThrowsHandler(); ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th); // Extends RemoteException ConnectException ex = new ConnectException(""); MethodInvocation mi = mock(MethodInvocation.class); given(mi.proceed()).willThrow(ex); try { ti.invoke(mi); fail(); } catch (Exception caught) { assertEquals(ex, caught); } assertEquals(1, th.getCalls()); assertEquals(1, th.getCalls("remoteException")); }
Example #6
Source File: ServerHealthCheckTask.java From cassandra-mesos-deprecated with Apache License 2.0 | 5 votes |
@Nullable private static ConnectException findConnectException(@Nullable final Throwable t) { if (t == null) { return null; } else if (t instanceof ConnectException) { return (ConnectException) t; } else { return findConnectException(t.getCause()); } }
Example #7
Source File: BackgroundCommandTask.java From ghidra with Apache License 2.0 | 5 votes |
private boolean ignoreException(Throwable t) { //@formatter:off return t instanceof ConnectException || t instanceof TerminatedTransactionException || t instanceof DomainObjectLockedException || t instanceof ClosedException; //@formatter:on }
Example #8
Source File: ToolTaskManager.java From ghidra with Apache License 2.0 | 5 votes |
private boolean applyCommand(Command cmd, UndoableDomainObject domainObject) { boolean success = false; boolean error = false; String cmdName = cmd.getName(); int id = domainObject.startTransaction(cmdName); try { try { success = cmd.applyTo(domainObject); // TODO Ok, this seems bad--why track the success of the given command, but // not any of the queued commands? (Are they considered unrelated follow-up // commands?) executeQueueCommands(domainObject, cmdName); } catch (Throwable t) { error = true; clearQueuedCommands(domainObject); if (t instanceof DomainObjectException) { t = t.getCause(); } // these are not 'unexpected', so don't show the user if (t instanceof ConnectException) { return false; } if (t instanceof RollbackException) { return false; } Msg.showError(this, null, "Command Failure", "An unexpected error occurred running command: " + cmd.getName(), t); } } finally { domainObject.endTransaction(id, !error); } return success; }
Example #9
Source File: ReflectionUtilsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void declaresException() throws Exception { Method remoteExMethod = A.class.getDeclaredMethod("foo", Integer.class); assertTrue(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class)); assertTrue(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, NoSuchMethodException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, Exception.class)); Method illegalExMethod = B.class.getDeclaredMethod("bar", String.class); assertTrue(ReflectionUtils.declaresException(illegalExMethod, IllegalArgumentException.class)); assertTrue(ReflectionUtils.declaresException(illegalExMethod, NumberFormatException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, IllegalStateException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class)); }
Example #10
Source File: SwingExceptionHandler.java From ghidra with Apache License 2.0 | 5 votes |
public static void handleUncaughtException(Throwable t) { if (t instanceof InvocationTargetException) { t = t.getCause(); } if (t instanceof ThreadDeath) { return; } if (t instanceof ConnectException) { return; } if (t instanceof ClosedException) { return; } String details = ""; if (t instanceof OutOfMemoryError) { Runtime rt = Runtime.getRuntime(); details = "\nMemory: free=" + rt.freeMemory() + " max=" + rt.maxMemory() + " total=" + rt.totalMemory(); } else { String message = t.getMessage(); if (message != null) { details = "\n" + t.getClass().getSimpleName() + " - " + message; } } Msg.showError(SwingExceptionHandler.class, null, "Error", "Uncaught Exception! " + details, t); }
Example #11
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From spring-analysis-note with MIT License | 5 votes |
private void doTestInvokesMethodOnEjbInstanceWithConnectExceptionWithRefresh( boolean lookupHomeOnStartup, boolean cacheHome) throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new ConnectException("")); int lookupCount = 2; if (!cacheHome) { lookupCount++; if (lookupHomeOnStartup) { lookupCount++; } } final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); si.setRefreshHomeOnConnectFailure(true); si.setLookupHomeOnStartup(lookupHomeOnStartup); si.setCacheHome(cacheHome); RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteException"); } catch (ConnectException ex) { // expected } verify(mockContext, times(lookupCount)).close(); verify(ejb, times(2)).remove(); }
Example #12
Source File: GhidraScript.java From ghidra with Apache License 2.0 | 5 votes |
private boolean verifyRepositoryConnection() { Project project = state.getProject(); if (project != null) { RepositoryAdapter repository = project.getRepository(); if (repository != null) { try { repository.connect(); } catch (IOException e) { if ((e instanceof ConnectException) || (e instanceof NotConnectedException)) { return false; } if (isRunningHeadless()) { Msg.error(this, "Server Connect Error: Server repository connection failed: " + repository + ", Exception: " + e.toString()); } else { PluginTool tool = state.getTool(); Msg.showError(this, tool != null ? tool.getActiveWindow() : null, "Server Connect Error", "Server repository connection failed: " + repository, e); } } return repository.isConnected(); } return true; // private project } return false; // no active project }
Example #13
Source File: ParkLeader.java From Fourinone with Apache License 2.0 | 5 votes |
protected Park electionLeader(int i){ Park pk = null; boolean thesarrok = true; i=i<groupserver.length?i:0; String[] sarr = groupserver[i]; try{ pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg); if(pk!=null) pk.askLeader(); }catch(RemoteException re){ LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage()); thesarrok = false; if(re instanceof ConnectException){ pk = electionLeader(i+1); } }catch(LeaderException le){ //le.printStackTrace(); LogUtil.info("electionLeader", "LeaderException", le); thesarrok = false; String[] ls = le.getLeaderServer(); int leaderindex = getLeaderIndex(ls); pk = electionLeader(leaderindex); } if(thesarrok) { thisserver = sarr; LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")"); } return pk; }
Example #14
Source File: ParkLeader.java From Fourinone with Apache License 2.0 | 5 votes |
protected Park electionLeader(int b, int i){ Park pk = null; boolean thesarrok = true; i=i<groupserver.length?i:0; //b=b<0?groupserver.length-1:b; String[] sarr = groupserver[i]; try{ pk = (Park)BeanService.getBean(sarr[0],Integer.parseInt(sarr[1]),parkservicecfg); if(pk!=null) pk.askLeader(); }catch(RemoteException re){ LogUtil.info("electionLeader", "("+sarr[0]+":"+sarr[1]+"):", re.getMessage()); thesarrok = false; if(re instanceof ConnectException){ if(b!=i)//one cycle { b=!alwaystry&&b<0?i:b; pk = electionLeader(b,i+1); } } }catch(LeaderException le){ //le.printStackTrace(); LogUtil.info("[electionLeader]", "[LeaderException]", le.getMessage()); thesarrok = false; String[] ls = le.getLeaderServer(); int leaderindex = getLeaderIndex(ls); pk = electionLeader(-1,leaderindex); } if(thesarrok) { thisserver = sarr; LogUtil.info("", "", "leader server is("+thisserver[0]+":"+thisserver[1]+")"); } return pk; }
Example #15
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From java-technology-stack with MIT License | 5 votes |
private void doTestInvokesMethodOnEjbInstanceWithConnectExceptionWithRefresh( boolean lookupHomeOnStartup, boolean cacheHome) throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new ConnectException("")); int lookupCount = 2; if (!cacheHome) { lookupCount++; if (lookupHomeOnStartup) { lookupCount++; } } final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); si.setRefreshHomeOnConnectFailure(true); si.setLookupHomeOnStartup(lookupHomeOnStartup); si.setCacheHome(cacheHome); RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteException"); } catch (ConnectException ex) { // expected } verify(mockContext, times(lookupCount)).close(); verify(ejb, times(2)).remove(); }
Example #16
Source File: ReflectionUtilsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void declaresException() throws Exception { Method remoteExMethod = A.class.getDeclaredMethod("foo", Integer.class); assertTrue(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class)); assertTrue(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, NoSuchMethodException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, Exception.class)); Method illegalExMethod = B.class.getDeclaredMethod("bar", String.class); assertTrue(ReflectionUtils.declaresException(illegalExMethod, IllegalArgumentException.class)); assertTrue(ReflectionUtils.declaresException(illegalExMethod, NumberFormatException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, IllegalStateException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class)); }
Example #17
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void doTestInvokesMethodOnEjbInstanceWithConnectExceptionWithRefresh( boolean lookupHomeOnStartup, boolean cacheHome) throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new ConnectException("")); int lookupCount = 2; if (!cacheHome) { lookupCount++; if (lookupHomeOnStartup) { lookupCount++; } } final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); si.setRefreshHomeOnConnectFailure(true); si.setLookupHomeOnStartup(lookupHomeOnStartup); si.setCacheHome(cacheHome); RemoteInterface target = (RemoteInterface) configuredProxy(si, RemoteInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteException"); } catch (ConnectException ex) { // expected } verify(mockContext, times(lookupCount)).close(); verify(ejb, times(2)).remove(); }
Example #18
Source File: ReflectionUtilsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void declaresException() throws Exception { Method remoteExMethod = A.class.getDeclaredMethod("foo", Integer.class); assertTrue(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class)); assertTrue(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, NoSuchMethodException.class)); assertFalse(ReflectionUtils.declaresException(remoteExMethod, Exception.class)); Method illegalExMethod = B.class.getDeclaredMethod("bar", String.class); assertTrue(ReflectionUtils.declaresException(illegalExMethod, IllegalArgumentException.class)); assertTrue(ReflectionUtils.declaresException(illegalExMethod, NumberFormatException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, IllegalStateException.class)); assertFalse(ReflectionUtils.declaresException(illegalExMethod, Exception.class)); }
Example #19
Source File: JvmstatApplicationProvider.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void registerJvmstatConnection(Host host, HostIdentifier hostId, int interval) { // Monitor the Host for new/finished Applications // NOTE: the code relies on the fact that the provider is the first listener registered in MonitoredHost of the Host // in which case the first obtained event contains all applications already running on the Host JvmstatConnection hostListener = null; // Get the MonitoredHost for Host final MonitoredHost monitoredHost = getMonitoredHost(hostId); if (monitoredHost == null) { // monitored host not available reschedule rescheduleProcessNewHost(host,hostId); return; } hostId = monitoredHost.getHostIdentifier(); monitoredHost.setInterval(interval); if (host == Host.LOCALHOST) checkForBrokenLocalJps(monitoredHost); try { // Fetch already running applications on the host processNewApplicationsByPids(host, hostId, monitoredHost.activeVms()); hostListener = new JvmstatConnection(host, monitoredHost); monitoredHost.addHostListener(hostListener); registerHostListener(host, hostId, hostListener); } catch (MonitorException e) { Throwable t = e.getCause(); monitoredHost.setLastException(e); if (!(t instanceof ConnectException)) { DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message( NbBundle.getMessage(JvmstatApplicationProvider.class, "MSG_Broken_Jvmstat", // NOI18N DataSourceDescriptorFactory.getDescriptor(host).getName()), NotifyDescriptor.ERROR_MESSAGE)); LOGGER.log(Level.INFO, "Jvmstat connection to " + host + " failed.", t); // NOI18N } else { rescheduleProcessNewHost(host,hostId); } } }
Example #20
Source File: RemoteHostOverview.java From visualvm with GNU General Public License v2.0 | 5 votes |
public int getAvailableProcessors() { checkJmxApp(); if (jmxApp == null) { return -1; } try { return osMXBean.getAvailableProcessors(); } catch (UndeclaredThrowableException ex) { if (ex.getCause() instanceof ConnectException) { jmxApp = null; return getAvailableProcessors(); } throw ex; } }
Example #21
Source File: ServerHealthCheckTask.java From cassandra-mesos-deprecated with Apache License 2.0 | 5 votes |
private HealthCheckDetails doHealthCheck() { final HealthCheckDetails.Builder builder = HealthCheckDetails.newBuilder(); if (jmxConnect == null) { return builder.setHealthy(false) .setMsg("no JMX connect to Cassandra process") .build(); } try { final CassandraFrameworkProtos.NodeInfo info = buildInfo(); builder.setHealthy(true) .setInfo(info); LOGGER.info("Healthcheck succeeded: operationMode:{} joined:{} gossip:{} native:{} rpc:{} uptime:{}s endpoint:{}, dc:{}, rack:{}, hostId:{}, version:{}", info.getOperationMode(), info.getJoined(), info.getGossipRunning(), info.getNativeTransportRunning(), info.getRpcServerRunning(), info.getUptimeMillis() / 1000, info.getEndpoint(), info.getDataCenter(), info.getRack(), info.getHostId(), info.getVersion()); } catch (final Exception e) { //noinspection ThrowableResultOfMethodCallIgnored final ConnectException connectException = findConnectException(e); if (connectException != null) { LOGGER.info("Health check failed: {}", connectException.getMessage().replaceAll("\\n\\t", "")); } else { LOGGER.warn("Health check failed due to unexpected exception.", e); builder.setHealthy(false) .setMsg(e.toString()); } } return builder.build(); }
Example #22
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithConnectExceptionAndRefresh() throws Exception { doTestRmiProxyFactoryBeanWithExceptionAndRefresh(ConnectException.class); }
Example #23
Source File: HandshakeTimeout.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #24
Source File: HandshakeTimeout.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #25
Source File: HandshakeFailure.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #26
Source File: HandshakeFailure.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { /* * Listen on port... */ ServerSocket serverSocket = new ServerSocket(PORT); /* * (Attempt RMI call to port in separate thread.) */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * ...accept one connection from port and send non-JRMP data. */ Socket socket = serverSocket.accept(); socket.getOutputStream().write("Wrong way".getBytes()); socket.close(); /* * Wait for call attempt to finish, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #27
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithBusinessInterfaceAndConnectException() throws Exception { doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException( ConnectException.class, RemoteConnectFailureException.class); }
Example #28
Source File: RmiSupportTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void rmiProxyFactoryBeanWithBusinessInterfaceAndConnectExceptionAndRefresh() throws Exception { doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh( ConnectException.class, RemoteConnectFailureException.class); }
Example #29
Source File: HandshakeTimeout.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { System.setProperty("sun.rmi.transport.tcp.handshakeTimeout", String.valueOf(TIMEOUT / 2)); /* * Listen on port, but never process connections made to it. */ ServerSocket serverSocket = new ServerSocket(PORT); /* * Attempt RMI call to port in separate thread. */ Registry registry = LocateRegistry.getRegistry(PORT); Connector connector = new Connector(registry); Thread t = new Thread(connector); t.setDaemon(true); t.start(); /* * Wait for call attempt to finished, and analyze result. */ t.join(TIMEOUT); synchronized (connector) { if (connector.success) { throw new RuntimeException( "TEST FAILED: remote call succeeded??"); } if (connector.exception == null) { throw new RuntimeException( "TEST FAILED: remote call did not time out"); } else { System.err.println("remote call failed with exception:"); connector.exception.printStackTrace(); System.err.println(); if (connector.exception instanceof MarshalException) { System.err.println( "TEST FAILED: MarshalException thrown, expecting " + "java.rmi.ConnectException or ConnectIOException"); } else if (connector.exception instanceof ConnectException || connector.exception instanceof ConnectIOException) { System.err.println( "TEST PASSED: java.rmi.ConnectException or " + "ConnectIOException thrown"); } else { throw new RuntimeException( "TEST FAILED: unexpected Exception thrown", connector.exception); } } } }
Example #30
Source File: RmiSupportTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void rmiProxyFactoryBeanWithBusinessInterfaceAndConnectExceptionAndRefresh() throws Exception { doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh( ConnectException.class, RemoteConnectFailureException.class); }