Java Code Examples for com.alipay.sofa.rpc.context.RpcInternalContext#removeContext()
The following examples show how to use
com.alipay.sofa.rpc.context.RpcInternalContext#removeContext() .
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: BaseNacosTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * Ad after class. */ @AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 2
Source File: BaseZkTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); if (server != null) { try { server.stop(); } catch (IOException e) { e.printStackTrace(); } } }
Example 3
Source File: RpcLookoutTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@AfterClass public static void adAfterClass() { RpcRunningState.setUnitTestMode(true); RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 4
Source File: BaseZkTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); if (server != null) { try { server.stop(); } catch (IOException e) { e.printStackTrace(); } } }
Example 5
Source File: FaultBaseServiceTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@After public void afterMethod() { providerConfig.unExport(); consumerConfigNotUse.unRefer(); consumerConfig.unRefer(); consumerConfig = null; consumerConfig2 = null; consumerConfigAnotherApp = null; helloService = null; RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 6
Source File: ClientProxyInvoker.java From sofa-rpc with Apache License 2.0 | 5 votes |
/** * proxy拦截的调用 * * @param request 请求消息 * @return 调用结果 */ @Override public SofaResponse invoke(SofaRequest request) throws SofaRpcException { SofaResponse response = null; Throwable throwable = null; try { RpcInternalContext.pushContext(); RpcInternalContext context = RpcInternalContext.getContext(); context.setProviderSide(false); // 包装请求 decorateRequest(request); try { // 产生开始调用事件 if (EventBus.isEnable(ClientStartInvokeEvent.class)) { EventBus.post(new ClientStartInvokeEvent(request)); } // 得到结果 response = cluster.invoke(request); } catch (SofaRpcException e) { throwable = e; throw e; } finally { // 产生调用结束事件 if (!request.isAsync()) { if (EventBus.isEnable(ClientEndInvokeEvent.class)) { EventBus.post(new ClientEndInvokeEvent(request, response, throwable)); } } } // 包装响应 decorateResponse(response); return response; } finally { RpcInternalContext.removeContext(); RpcInternalContext.popContext(); } }
Example 7
Source File: AbstractSerializerTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Test public void buildSerializeError() { RpcInternalContext old = RpcInternalContext.peekContext(); try { RpcInternalContext.removeContext(); SofaRpcException exception = serializer.buildSerializeError("xx"); Assert.assertEquals(RpcErrorType.UNKNOWN, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(true); exception = serializer.buildSerializeError("xx"); Assert.assertEquals(RpcErrorType.SERVER_SERIALIZE, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(false); exception = serializer.buildSerializeError("xx"); Assert.assertEquals(RpcErrorType.CLIENT_SERIALIZE, exception.getErrorType()); RpcInternalContext.removeContext(); exception = serializer.buildSerializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.UNKNOWN, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(true); exception = serializer.buildSerializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.SERVER_SERIALIZE, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(false); exception = serializer.buildSerializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.CLIENT_SERIALIZE, exception.getErrorType()); } finally { RpcInternalContext.setContext(old); } }
Example 8
Source File: AbstractSerializerTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Test public void buildDeserializeError() { RpcInternalContext old = RpcInternalContext.peekContext(); try { RpcInternalContext.removeContext(); SofaRpcException exception = serializer.buildDeserializeError("xx"); Assert.assertEquals(RpcErrorType.UNKNOWN, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(true); exception = serializer.buildDeserializeError("xx"); Assert.assertEquals(RpcErrorType.SERVER_DESERIALIZE, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(false); exception = serializer.buildDeserializeError("xx"); Assert.assertEquals(RpcErrorType.CLIENT_DESERIALIZE, exception.getErrorType()); RpcInternalContext.removeContext(); exception = serializer.buildDeserializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.UNKNOWN, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(true); exception = serializer.buildDeserializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.SERVER_DESERIALIZE, exception.getErrorType()); RpcInternalContext.getContext().setProviderSide(false); exception = serializer.buildDeserializeError("xx", new RuntimeException()); Assert.assertEquals(RpcErrorType.CLIENT_DESERIALIZE, exception.getErrorType()); } finally { RpcInternalContext.setContext(old); } }
Example 9
Source File: ActivelyDestroyTest.java From sofa-rpc-boot-projects with Apache License 2.0 | 4 votes |
@AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 10
Source File: BaseMeshTest.java From sofa-rpc with Apache License 2.0 | 4 votes |
@AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 11
Source File: Http1ServerTest.java From sofa-rpc with Apache License 2.0 | 4 votes |
@After public void afterMethod() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }
Example 12
Source File: ActivelyDestroyTest.java From sofa-rpc with Apache License 2.0 | 4 votes |
@AfterClass public static void adAfterClass() { RpcRuntimeContext.destroy(); RpcInternalContext.removeContext(); RpcInvokeContext.removeContext(); }