Skip to content

Commit

Permalink
Don't wrap exceptions thrown inside measured method
Browse files Browse the repository at this point in the history
- closes gh-7
  • Loading branch information
lukashinsch committed Jul 3, 2015
1 parent 2d3c6be commit ac2001a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.2.2
- Don't wrap exceptions thrown inside measured code (closes gh-7)

## 0.2.1
- Fix autoconfig
- Fix finding implementation method by including parameter types
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Maven
<dependency>
<groupId>eu.hinsch</groupId>
<artifactId>spring-boot-execution-metric</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>
</dependency>
```

Gradle
```groovy
compile 'eu.hinsch:spring-boot-execution-metric:0.2.1'
compile 'eu.hinsch:spring-boot-execution-metric:0.2.2'
```

### Use with AOP / Annotations
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'

version = '0.2.1'
version = '0.2.2'
group = 'eu.hinsch'

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ public Object measure(ProceedingJoinPoint joinPoint) throws Throwable {
SupplierMetric<Object> supplierMetric = store.computeIfAbsent(metricName,
(name) -> factory.supplierMetric(name, targetLogger, executionMetric.loglevel()));

return supplierMetric.measure(() -> {
try {
return joinPoint.proceed();
} catch (Throwable throwable) {
throw new RuntimeException("error invoking method", throwable);
}
});

// TODO clean up exception handling
try {
return supplierMetric.measure(() -> {
try {
return joinPoint.proceed();
} catch (Throwable throwable) {
throw new WrapperException(throwable);
}
});
}
catch (WrapperException e) {
throw e.getCause();
}
}

private Class getClassForLogger(ProceedingJoinPoint joinPoint) throws Exception {
Expand All @@ -72,4 +77,10 @@ private ExecutionMetric getExecutionMetric(ProceedingJoinPoint joinPoint) throws
}
return executionMetric;
}

private static class WrapperException extends RuntimeException {
public WrapperException(Throwable t) {
super(t);
}
}
}

0 comments on commit ac2001a

Please sign in to comment.