org.springframework.remoting.RemoteAccessException Java Examples
The following examples show how to use
org.springframework.remoting.RemoteAccessException.
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: RmiProtocol.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null && e.getCause() != null) { Class<?> cls = e.getCause().getClass(); // 是根据测试Case发现的问题,对RpcException.setCode进行设置 if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #2
Source File: CauchoRemotingTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void hessianProxyFactoryBeanWithCustomProxyFactory() throws Exception { TestHessianProxyFactory proxyFactory = new TestHessianProxyFactory(); HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setProxyFactory(proxyFactory); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); assertEquals("test", proxyFactory.user); assertEquals("bean", proxyFactory.password); assertTrue(proxyFactory.overloadEnabled); assertThatExceptionOfType(RemoteAccessException.class).isThrownBy(() -> bean.setName("test")); }
Example #3
Source File: CauchoRemotingTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void hessianProxyFactoryBeanWithAuthenticationAndAccessError() throws Exception { HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); assertThatExceptionOfType(RemoteAccessException.class).isThrownBy(() -> bean.setName("test")); }
Example #4
Source File: RmiProtocol.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null && e.getCause() != null) { Class<?> cls = e.getCause().getClass(); if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #5
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testInvokesMethodOnEjbInstanceWithBusinessInterfaceWithRemoteException() throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new RemoteException()); final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); BusinessInterface target = (BusinessInterface) configuredProxy(si, BusinessInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteAccessException"); } catch (RemoteAccessException ex) { // expected } verify(mockContext).close(); verify(ejb).remove(); }
Example #6
Source File: RmiClientInterceptorUtils.java From java-technology-stack with MIT License | 6 votes |
/** * Convert the given RemoteException that happened during remote access * to Spring's RemoteAccessException if the method signature does not * support RemoteException. Else, return the original RemoteException. * @param method the invoked method * @param ex the RemoteException that happened * @param isConnectFailure whether the given exception should be considered * a connect failure * @param serviceName the name of the service (for debugging purposes) * @return the exception to be thrown to the caller */ public static Exception convertRmiAccessException( Method method, RemoteException ex, boolean isConnectFailure, String serviceName) { if (logger.isDebugEnabled()) { logger.debug("Remote service [" + serviceName + "] threw exception", ex); } if (ReflectionUtils.declaresException(method, ex.getClass())) { return ex; } else { if (isConnectFailure) { return new RemoteConnectFailureException("Could not connect to remote service [" + serviceName + "]", ex); } else { return new RemoteAccessException("Could not access remote service [" + serviceName + "]", ex); } } }
Example #7
Source File: HttpInvokerClientInterceptor.java From spring-analysis-note with MIT License | 6 votes |
/** * Convert the given HTTP invoker access exception to an appropriate * Spring {@link RemoteAccessException}. * @param ex the exception to convert * @return the RemoteAccessException to throw, or {@code null} to have the * original exception propagated to the caller */ @Nullable protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) { if (ex instanceof ConnectException) { return new RemoteConnectFailureException( "Could not connect to HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError || ex instanceof InvalidClassException) { return new RemoteAccessException( "Could not deserialize result from HTTP invoker remote service [" + getServiceUrl() + "]", ex); } if (ex instanceof Exception) { return new RemoteAccessException( "Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } // For any other Throwable, e.g. OutOfMemoryError: let it get propagated as-is. return null; }
Example #8
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testInvokesMethodOnEjbInstanceWithBusinessInterfaceWithRemoteException() throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new RemoteException()); final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); BusinessInterface target = (BusinessInterface) configuredProxy(si, BusinessInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteAccessException"); } catch (RemoteAccessException ex) { // expected } verify(mockContext).close(); verify(ejb).remove(); }
Example #9
Source File: HttpInvokerClientInterceptor.java From java-technology-stack with MIT License | 6 votes |
/** * Convert the given HTTP invoker access exception to an appropriate * Spring {@link RemoteAccessException}. * @param ex the exception to convert * @return the RemoteAccessException to throw, or {@code null} to have the * original exception propagated to the caller */ @Nullable protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) { if (ex instanceof ConnectException) { return new RemoteConnectFailureException( "Could not connect to HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError || ex instanceof InvalidClassException) { return new RemoteAccessException( "Could not deserialize result from HTTP invoker remote service [" + getServiceUrl() + "]", ex); } if (ex instanceof Exception) { return new RemoteAccessException( "Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } // For any other Throwable, e.g. OutOfMemoryError: let it get propagated as-is. return null; }
Example #10
Source File: CauchoRemotingTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void hessianProxyFactoryBeanWithAuthenticationAndAccessError() throws Exception { HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #11
Source File: CauchoRemotingTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void hessianProxyFactoryBeanWithCustomProxyFactory() throws Exception { TestHessianProxyFactory proxyFactory = new TestHessianProxyFactory(); HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setProxyFactory(proxyFactory); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); assertEquals("test", proxyFactory.user); assertEquals("bean", proxyFactory.password); assertTrue(proxyFactory.overloadEnabled); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #12
Source File: RmiClientInterceptorUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Convert the given RemoteException that happened during remote access * to Spring's RemoteAccessException if the method signature does not * support RemoteException. Else, return the original RemoteException. * @param method the invoked method * @param ex the RemoteException that happened * @param isConnectFailure whether the given exception should be considered * a connect failure * @param serviceName the name of the service (for debugging purposes) * @return the exception to be thrown to the caller */ public static Exception convertRmiAccessException( Method method, RemoteException ex, boolean isConnectFailure, String serviceName) { if (logger.isDebugEnabled()) { logger.debug("Remote service [" + serviceName + "] threw exception", ex); } if (ReflectionUtils.declaresException(method, ex.getClass())) { return ex; } else { if (isConnectFailure) { return new RemoteConnectFailureException("Could not connect to remote service [" + serviceName + "]", ex); } else { return new RemoteAccessException("Could not access remote service [" + serviceName + "]", ex); } } }
Example #13
Source File: HttpInvokerClientInterceptor.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Convert the given HTTP invoker access exception to an appropriate * Spring {@link RemoteAccessException}. * @param ex the exception to convert * @return the RemoteAccessException to throw, or {@code null} to have the * original exception propagated to the caller */ protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) { if (ex instanceof ConnectException) { return new RemoteConnectFailureException( "Could not connect to HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError || ex instanceof InvalidClassException) { return new RemoteAccessException( "Could not deserialize result from HTTP invoker remote service [" + getServiceUrl() + "]", ex); } if (ex instanceof Exception) { return new RemoteAccessException( "Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } // For any other Throwable, e.g. OutOfMemoryError: let it get propagated as-is. return null; }
Example #14
Source File: RmiProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null && e.getCause() != null) { Class<?> cls = e.getCause().getClass(); // 是根据测试Case发现的问题,对RpcException.setCode进行设置 if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #15
Source File: HttpProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null) { Class<?> cls = e.getClass(); // 是根据测试Case发现的问题,对RpcException.setCode进行设置 if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #16
Source File: JsonRpcProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null) { Class<?> cls = e.getClass(); if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #17
Source File: HttpProtocol.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null) { Class<?> cls = e.getClass(); // 是根据测试Case发现的问题,对RpcException.setCode进行设置 if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #18
Source File: RmiClientInterceptorUtils.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Convert the given RemoteException that happened during remote access * to Spring's RemoteAccessException if the method signature does not * support RemoteException. Else, return the original RemoteException. * @param method the invoked method * @param ex the RemoteException that happened * @param isConnectFailure whether the given exception should be considered * a connect failure * @param serviceName the name of the service (for debugging purposes) * @return the exception to be thrown to the caller */ public static Exception convertRmiAccessException( Method method, RemoteException ex, boolean isConnectFailure, String serviceName) { if (logger.isDebugEnabled()) { logger.debug("Remote service [" + serviceName + "] threw exception", ex); } if (ReflectionUtils.declaresException(method, ex.getClass())) { return ex; } else { if (isConnectFailure) { return new RemoteConnectFailureException("Could not connect to remote service [" + serviceName + "]", ex); } else { return new RemoteAccessException("Could not access remote service [" + serviceName + "]", ex); } } }
Example #19
Source File: SimpleRemoteSlsbInvokerInterceptorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testInvokesMethodOnEjbInstanceWithBusinessInterfaceWithRemoteException() throws Exception { final RemoteInterface ejb = mock(RemoteInterface.class); given(ejb.targetMethod()).willThrow(new RemoteException()); final String jndiName= "foobar"; Context mockContext = mockContext(jndiName, ejb); SimpleRemoteSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName); BusinessInterface target = (BusinessInterface) configuredProxy(si, BusinessInterface.class); try { target.targetMethod(); fail("Should have thrown RemoteAccessException"); } catch (RemoteAccessException ex) { // expected } verify(mockContext).close(); verify(ejb).remove(); }
Example #20
Source File: HttpInvokerClientInterceptor.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Convert the given HTTP invoker access exception to an appropriate * Spring RemoteAccessException. * @param ex the exception to convert * @return the RemoteAccessException to throw */ protected RemoteAccessException convertHttpInvokerAccessException(Throwable ex) { if (ex instanceof ConnectException) { return new RemoteConnectFailureException( "Could not connect to HTTP invoker remote service at [" + getServiceUrl() + "]", ex); } if (ex instanceof ClassNotFoundException || ex instanceof NoClassDefFoundError || ex instanceof InvalidClassException) { return new RemoteAccessException( "Could not deserialize result from HTTP invoker remote service [" + getServiceUrl() + "]", ex); } return new RemoteAccessException( "Could not access HTTP invoker remote service at [" + getServiceUrl() + "]", ex); }
Example #21
Source File: CauchoRemotingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void hessianProxyFactoryBeanWithAuthenticationAndAccessError() throws Exception { HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #22
Source File: CauchoRemotingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void hessianProxyFactoryBeanWithCustomProxyFactory() throws Exception { TestHessianProxyFactory proxyFactory = new TestHessianProxyFactory(); HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setProxyFactory(proxyFactory); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); assertEquals(proxyFactory.user, "test"); assertEquals(proxyFactory.password, "bean"); assertTrue(proxyFactory.overloadEnabled); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #23
Source File: CauchoRemotingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void burlapProxyFactoryBeanWithAuthenticationAndAccessError() throws Exception { BurlapProxyFactoryBean factory = new BurlapProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #24
Source File: CauchoRemotingTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void burlapProxyFactoryBeanWithCustomProxyFactory() throws Exception { TestBurlapProxyFactory proxyFactory = new TestBurlapProxyFactory(); BurlapProxyFactoryBean factory = new BurlapProxyFactoryBean(); factory.setServiceInterface(ITestBean.class); factory.setServiceUrl("http://localhosta/testbean"); factory.setProxyFactory(proxyFactory); factory.setUsername("test"); factory.setPassword("bean"); factory.setOverloadEnabled(true); factory.afterPropertiesSet(); assertTrue("Correct singleton value", factory.isSingleton()); assertTrue(factory.getObject() instanceof ITestBean); ITestBean bean = (ITestBean) factory.getObject(); assertEquals(proxyFactory.user, "test"); assertEquals(proxyFactory.password, "bean"); assertTrue(proxyFactory.overloadEnabled); exception.expect(RemoteAccessException.class); bean.setName("test"); }
Example #25
Source File: RmiProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null && e.getCause() != null) { Class<?> cls = e.getCause().getClass(); // // 是根据测试Case发现的问题,对RpcException.setCode进行设置 // if (SocketTimeoutException.class.equals(cls)) { // return RpcException.TIMEOUT_EXCEPTION; // } else if (IOException.class.isAssignableFrom(cls)) { // return RpcException.NETWORK_EXCEPTION; // } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { // return RpcException.SERIALIZATION_EXCEPTION; // } return ErrorCodeUtils.getErrorCode(e, cls); } return super.getErrorCode(e); }
Example #26
Source File: HttpProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null) { Class<?> cls = e.getClass(); // // 是根据测试Case发现的问题,对RpcException.setCode进行设置 // if (SocketTimeoutException.class.equals(cls)) { // return RpcException.TIMEOUT_EXCEPTION; // } else if (IOException.class.isAssignableFrom(cls)) { // return RpcException.NETWORK_EXCEPTION; // } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { // return RpcException.SERIALIZATION_EXCEPTION; // } return ErrorCodeUtils.getErrorCode(e, cls); } return super.getErrorCode(e); }
Example #27
Source File: ConnectExceptionHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override public boolean handle(Thread thread, Throwable exception) { @SuppressWarnings("unchecked") List<Throwable> list = ExceptionUtils.getThrowableList(exception); for (Throwable throwable : list) { if (throwable instanceof RemoteAccessException) { Messages messages = AppBeans.get(Messages.NAME); String msg = messages.getMessage(getClass(), "connectException.message"); if (throwable.getCause() == null) { App.getInstance().getMainFrame().showNotification(msg, Frame.NotificationType.ERROR); } else { String description = messages.formatMessage(getClass(), "connectException.description", throwable.getCause().toString()); App.getInstance().getMainFrame().showNotification(msg, description, Frame.NotificationType.ERROR); } return true; } } return false; }
Example #28
Source File: App.java From cuba with Apache License 2.0 | 6 votes |
protected void exit() { try { userActionsLog.trace("Closing application..."); if (connection.isConnected()) { recursiveClosingFrames(topLevelFrames.iterator(), () -> { exiting = true; connection.logout(); forceExit(); }); } else { forceExit(); } } catch (Throwable e) { log.warn("Error closing application", e); String title = messages.getMainMessage("errorPane.title"); String text = messages.getMainMessage("unexpectedCloseException.message") + "\n"; if (e instanceof RemoteAccessException) { text = text + messages.getMainMessage("connectException.message"); } else { text = text + e.getClass().getSimpleName() + ": " + e.getMessage(); } JOptionPane.showMessageDialog(mainFrame, text, title, JOptionPane.WARNING_MESSAGE); forceExit(); } }
Example #29
Source File: JsonRpcProtocol.java From dubbo-rpc-jsonrpc with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null) { Class<?> cls = e.getClass(); if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }
Example #30
Source File: RmiProtocol.java From dubbox with Apache License 2.0 | 6 votes |
protected int getErrorCode(Throwable e) { if (e instanceof RemoteAccessException) { e = e.getCause(); } if (e != null && e.getCause() != null) { Class<?> cls = e.getCause().getClass(); // 是根据测试Case发现的问题,对RpcException.setCode进行设置 if (SocketTimeoutException.class.equals(cls)) { return RpcException.TIMEOUT_EXCEPTION; } else if (IOException.class.isAssignableFrom(cls)) { return RpcException.NETWORK_EXCEPTION; } else if (ClassNotFoundException.class.isAssignableFrom(cls)) { return RpcException.SERIALIZATION_EXCEPTION; } } return super.getErrorCode(e); }