@Test(expectedExceptions = { RemoteException.class }) public void remoteException() throws Throwable { String methodSignature = "methodSignature"; RemoteException remoteException = mock(RemoteException.class); when(jp.proceed()).thenThrow(remoteException); when(signature.toString()).thenReturn(methodSignature); try { interceptor.logServiceException(jp); } finally { verify(jp, times(1)).proceed(); verify(remoteException, times(1)).setServiceMethodSignature(methodSignature); verify(log, times(1)).warn(anyString(), eq(remoteException)); } }
@Around("execution(* rocks.inspectit.server.service.*.*(..))") public Object logServiceException(ProceedingJoinPoint jp) throws Exception { try { return jp.proceed(); } catch (BusinessException e) { if (log.isDebugEnabled()) { log.debug("BusinessException thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", e); } e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (RemoteException e) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ". Original exception class is: " + e.getOriginalExceptionClass(), e); e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (Throwable t) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", t); RemoteException transformException = transformException(t, new ArrayList<Throwable>()); transformException.setServiceMethodSignature(jp.getSignature().toString()); throw transformException; } }
ExceptionInterceptor { @Around("execution(* rocks.inspectit.server.service.*.*(..))") public Object logServiceException(ProceedingJoinPoint jp) throws Exception { try { return jp.proceed(); } catch (BusinessException e) { if (log.isDebugEnabled()) { log.debug("BusinessException thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", e); } e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (RemoteException e) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ". Original exception class is: " + e.getOriginalExceptionClass(), e); e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (Throwable t) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", t); RemoteException transformException = transformException(t, new ArrayList<Throwable>()); transformException.setServiceMethodSignature(jp.getSignature().toString()); throw transformException; } } }
ExceptionInterceptor { @Around("execution(* rocks.inspectit.server.service.*.*(..))") public Object logServiceException(ProceedingJoinPoint jp) throws Exception { try { return jp.proceed(); } catch (BusinessException e) { if (log.isDebugEnabled()) { log.debug("BusinessException thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", e); } e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (RemoteException e) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ". Original exception class is: " + e.getOriginalExceptionClass(), e); e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (Throwable t) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", t); RemoteException transformException = transformException(t, new ArrayList<Throwable>()); transformException.setServiceMethodSignature(jp.getSignature().toString()); throw transformException; } }  }
ExceptionInterceptor { @Around("execution(* rocks.inspectit.server.service.*.*(..))") public Object logServiceException(ProceedingJoinPoint jp) throws Exception { try { return jp.proceed(); } catch (BusinessException e) { if (log.isDebugEnabled()) { log.debug("BusinessException thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", e); } e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (RemoteException e) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ". Original exception class is: " + e.getOriginalExceptionClass(), e); e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (Throwable t) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", t); RemoteException transformException = transformException(t, new ArrayList<Throwable>()); transformException.setServiceMethodSignature(jp.getSignature().toString()); throw transformException; } }  @Around("execution(* rocks.inspectit.server.service.*.*(..))") Object logServiceException(ProceedingJoinPoint jp); static RemoteException transformException(Throwable throwable); }
ExceptionInterceptor { @Around("execution(* rocks.inspectit.server.service.*.*(..))") public Object logServiceException(ProceedingJoinPoint jp) throws Exception { try { return jp.proceed(); } catch (BusinessException e) { if (log.isDebugEnabled()) { log.debug("BusinessException thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", e); } e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (RemoteException e) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ". Original exception class is: " + e.getOriginalExceptionClass(), e); e.setServiceMethodSignature(jp.getSignature().toString()); throw e; } catch (Throwable t) { log.warn("Exception thrown in the service method " + jp.getSignature() + " executed with following parameters: " + Arrays.toString(jp.getArgs()) + ".", t); RemoteException transformException = transformException(t, new ArrayList<Throwable>()); transformException.setServiceMethodSignature(jp.getSignature().toString()); throw transformException; } }  @Around("execution(* rocks.inspectit.server.service.*.*(..))") Object logServiceException(ProceedingJoinPoint jp); static RemoteException transformException(Throwable throwable);  }