test_class.declarator: genericImplFilter = new GenericImplFilter()
test_class.modifier: private
test_class.original_string: private GenericImplFilter genericImplFilter = new GenericImplFilter();
test_class.type: GenericImplFilter
test_class.var_name: genericImplFilter
test_class.file: dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/GenericImplFilterTest.java
test_class.identifier: GenericImplFilterTest
test_case.body: @Test
      public void testInvoke() throws Exception {
  
          RpcInvocation invocation = new RpcInvocation("getPerson", "org.apache.dubbo.rpc.support.DemoService",
                  "org.apache.dubbo.rpc.support.DemoService:dubbo", new Class[]{Person.class}, new Object[]{new Person("dubbo", 10)});
  
  
          URL url = URL.valueOf("test://test:11/org.apache.dubbo.rpc.support.DemoService?" +
                  "accesslog=true&group=dubbo&version=1.1&generic=true");
          Invoker invoker = Mockito.mock(Invoker.class);
  
          Map<String, Object> person = new HashMap<String, Object>();
          person.put("name", "dubbo");
          person.put("age", 10);
  
          AppResponse mockRpcResult = new AppResponse(person);
          when(invoker.invoke(any(Invocation.class))).thenReturn(AsyncRpcResult.newDefaultAsyncResult(mockRpcResult, invocation));
          when(invoker.getUrl()).thenReturn(url);
          when(invoker.getInterface()).thenReturn(DemoService.class);
  
          Result asyncResult = genericImplFilter.invoke(invoker, invocation);
          Result result = asyncResult.get();
          genericImplFilter.onResponse(result, invoker, invocation);
  
          Assertions.assertEquals(Person.class, result.getValue().getClass());
          Assertions.assertEquals(10, ((Person) result.getValue()).getAge());
      }
test_case.class_method_signature: GenericImplFilterTest.testInvoke()
test_case.full_signature: @Test public void testInvoke()
test_case.identifier: testInvoke
test_case.invocations: valueOf mock put put thenReturn when invoke any newDefaultAsyncResult thenReturn when getUrl thenReturn when getInterface invoke get onResponse assertEquals getClass getValue assertEquals getAge getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInvoke()
focal_class.declarator: logger = LoggerFactory.getLogger(GenericImplFilter.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(GenericImplFilter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: GENERIC_PARAMETER_TYPES = new Class<?>[]{String.class, String[].class, Object[].class}
focal_class.modifier: private static final
focal_class.original_string: private static final Class<?>[] GENERIC_PARAMETER_TYPES = new Class<?>[]{String.class, String[].class, Object[].class};
focal_class.type: Class<?>[]
focal_class.var_name: GENERIC_PARAMETER_TYPES
focal_class.declarator: GENERIC_IMPL_MARKER = "GENERIC_IMPL"
focal_class.modifier: private static final
focal_class.original_string: private static final String GENERIC_IMPL_MARKER = "GENERIC_IMPL";
focal_class.type: String
focal_class.var_name: GENERIC_IMPL_MARKER
focal_class.file: dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/GenericImplFilter.java
focal_class.identifier: GenericImplFilter
focal_class.interfaces: implements Filter, Filter.Listener
focal_class.class_method_signature: GenericImplFilter.invoke(Invoker<?> invoker, Invocation invocation)
focal_class.full_signature: @Override public Result invoke(Invoker<?> invoker, Invocation invocation)
focal_class.identifier: invoke
focal_class.modifiers: @Override public
focal_class.parameters: (Invoker<?> invoker, Invocation invocation)
focal_class.return: Result
focal_class.signature: Result invoke(Invoker<?> invoker, Invocation invocation)
focal_class.class_method_signature: GenericImplFilter.error(String generic, String expected, String actual)
focal_class.full_signature: private void error(String generic, String expected, String actual)
focal_class.identifier: error
focal_class.modifiers: private
focal_class.parameters: (String generic, String expected, String actual)
focal_class.return: void
focal_class.signature: void error(String generic, String expected, String actual)
focal_class.class_method_signature: GenericImplFilter.onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation)
focal_class.full_signature: @Override public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation)
focal_class.identifier: onResponse
focal_class.modifiers: @Override public
focal_class.parameters: (Result appResponse, Invoker<?> invoker, Invocation invocation)
focal_class.return: void
focal_class.signature: void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation)
focal_class.class_method_signature: GenericImplFilter.onError(Throwable t, Invoker<?> invoker, Invocation invocation)
focal_class.full_signature: @Override public void onError(Throwable t, Invoker<?> invoker, Invocation invocation)
focal_class.identifier: onError
focal_class.modifiers: @Override public
focal_class.parameters: (Throwable t, Invoker<?> invoker, Invocation invocation)
focal_class.return: void
focal_class.signature: void onError(Throwable t, Invoker<?> invoker, Invocation invocation)
focal_class.class_method_signature: GenericImplFilter.isCallingGenericImpl(String generic, Invocation invocation)
focal_class.full_signature: private boolean isCallingGenericImpl(String generic, Invocation invocation)
focal_class.identifier: isCallingGenericImpl
focal_class.modifiers: private
focal_class.parameters: (String generic, Invocation invocation)
focal_class.return: boolean
focal_class.signature: boolean isCallingGenericImpl(String generic, Invocation invocation)
focal_class.class_method_signature: GenericImplFilter.isMakingGenericCall(String generic, Invocation invocation)
focal_class.full_signature: private boolean isMakingGenericCall(String generic, Invocation invocation)
focal_class.identifier: isMakingGenericCall
focal_class.modifiers: private
focal_class.parameters: (String generic, Invocation invocation)
focal_class.return: boolean
focal_class.signature: boolean isMakingGenericCall(String generic, Invocation invocation)
focal_method.body: @Override
      public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
          String generic = invoker.getUrl().getParameter(GENERIC_KEY);
          // calling a generic impl service
          if (isCallingGenericImpl(generic, invocation)) {
              RpcInvocation invocation2 = new RpcInvocation(invocation);
  
              /**
               * Mark this invocation as a generic impl call, this value will be removed automatically before passing on the wire.
               * See {@link RpcUtils#sieveUnnecessaryAttachments(Invocation)}
               */
              invocation2.put(GENERIC_IMPL_MARKER, true);
  
              String methodName = invocation2.getMethodName();
              Class<?>[] parameterTypes = invocation2.getParameterTypes();
              Object[] arguments = invocation2.getArguments();
  
              String[] types = new String[parameterTypes.length];
              for (int i = 0; i < parameterTypes.length; i++) {
                  types[i] = ReflectUtils.getName(parameterTypes[i]);
              }
  
              Object[] args;
              if (ProtocolUtils.isBeanGenericSerialization(generic)) {
                  args = new Object[arguments.length];
                  for (int i = 0; i < arguments.length; i++) {
                      args[i] = JavaBeanSerializeUtil.serialize(arguments[i], JavaBeanAccessor.METHOD);
                  }
              } else {
                  args = PojoUtils.generalize(arguments);
              }
  
              if (RpcUtils.isReturnTypeFuture(invocation)) {
                  invocation2.setMethodName($INVOKE_ASYNC);
              } else {
                  invocation2.setMethodName($INVOKE);
              }
              invocation2.setParameterTypes(GENERIC_PARAMETER_TYPES);
              invocation2.setParameterTypesDesc(GENERIC_PARAMETER_DESC);
              invocation2.setArguments(new Object[]{methodName, types, args});
              return invoker.invoke(invocation2);
          }
          // making a generic call to a normal service
          else if (isMakingGenericCall(generic, invocation)) {
  
              Object[] args = (Object[]) invocation.getArguments()[2];
              if (ProtocolUtils.isJavaGenericSerialization(generic)) {
  
                  for (Object arg : args) {
                      if (!(byte[].class == arg.getClass())) {
                          error(generic, byte[].class.getName(), arg.getClass().getName());
                      }
                  }
              } else if (ProtocolUtils.isBeanGenericSerialization(generic)) {
                  for (Object arg : args) {
                      if (!(arg instanceof JavaBeanDescriptor)) {
                          error(generic, JavaBeanDescriptor.class.getName(), arg.getClass().getName());
                      }
                  }
              }
  
              invocation.setAttachment(
                      GENERIC_KEY, invoker.getUrl().getParameter(GENERIC_KEY));
          }
          return invoker.invoke(invocation);
      }
focal_method.class_method_signature: GenericImplFilter.invoke(Invoker<?> invoker, Invocation invocation)
focal_method.full_signature: @Override public Result invoke(Invoker<?> invoker, Invocation invocation)
focal_method.identifier: invoke
focal_method.invocations: getParameter getUrl isCallingGenericImpl put getMethodName getParameterTypes getArguments getName isBeanGenericSerialization serialize generalize isReturnTypeFuture setMethodName setMethodName setParameterTypes setParameterTypesDesc setArguments invoke isMakingGenericCall getArguments isJavaGenericSerialization getClass error getName getName getClass isBeanGenericSerialization error getName getName getClass setAttachment getParameter getUrl invoke
focal_method.modifiers: @Override public
focal_method.parameters: (Invoker<?> invoker, Invocation invocation)
focal_method.return: Result
focal_method.signature: Result invoke(Invoker<?> invoker, Invocation invocation)