Skip to content

Commit

Permalink
Switched the default for exception handling in the advice component.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Apr 18, 2016
1 parent 87956e1 commit 42e457b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion byte-buddy-dep/src/main/java/net/bytebuddy/asm/Advice.java
Expand Up @@ -6456,7 +6456,7 @@ public String toString() {
*
* @return {@code true} if the advice method should be invoked when a method terminates exceptionally.
*/
boolean onThrowable() default true;
boolean onThrowable() default false;
}

/**
Expand Down
Expand Up @@ -30,7 +30,7 @@ public static Collection<Object[]> data() {
{FrameAdviceEntryOnlyWithSuppression.class, 1},
{FrameAdviceExitOnly.class, 1},
{FrameAdviceExitOnlyWithSuppression.class, 1},
{FrameAdviceExitOnlyWithSuppressionAndNotException.class, 1},
{FrameAdviceExitOnlyWithSuppressionAndNonExceptionHandling.class, 1},
{FrameReturnAdvice.class, 2}
});
}
Expand Down Expand Up @@ -206,7 +206,7 @@ public static String bar(String value) {
public static class FrameAdvice {

@Advice.OnMethodEnter
@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
int v0 = 1;
{
Expand Down Expand Up @@ -241,7 +241,7 @@ private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) St
public static class FrameAdviceWithoutThrowable {

@Advice.OnMethodEnter
@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
int v0 = 1;
{
Expand Down Expand Up @@ -276,7 +276,7 @@ private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) St
public static class FrameAdviceWithSuppression {

@Advice.OnMethodEnter(suppress = Exception.class)
@Advice.OnMethodExit(suppress = Exception.class)
@Advice.OnMethodExit(suppress = Exception.class, onThrowable = true)
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
int v0 = 1;
{
Expand Down Expand Up @@ -378,7 +378,7 @@ private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) St
@SuppressWarnings("unused")
public static class FrameAdviceExitOnly {

@Advice.OnMethodEnter
@Advice.OnMethodExit(onThrowable = true)
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
int v0 = 1;
{
Expand Down Expand Up @@ -412,7 +412,7 @@ private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) St
@SuppressWarnings("unused")
public static class FrameAdviceExitOnlyWithSuppression {

@Advice.OnMethodExit(suppress = Exception.class)
@Advice.OnMethodExit(suppress = Exception.class, onThrowable = true)
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
int v0 = 1;
{
Expand Down Expand Up @@ -444,7 +444,7 @@ private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) St
}

@SuppressWarnings("unused")
public static class FrameAdviceExitOnlyWithSuppressionAndNotException {
public static class FrameAdviceExitOnlyWithSuppressionAndNonExceptionHandling {

@Advice.OnMethodExit(suppress = Exception.class, onThrowable = false)
private static String advice(@Advice.Ignored int ignored, @Advice.Argument(0) String value) {
Expand Down
42 changes: 21 additions & 21 deletions byte-buddy-dep/src/test/java/net/bytebuddy/asm/AdviceTest.java
Expand Up @@ -1489,7 +1489,7 @@ private static void enter() {
/* empty */
}

@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void exit() {
/* empty */
}
Expand All @@ -1503,7 +1503,7 @@ private static void enter() {
Sample.enter++;
}

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void exit() {
Sample.exit++;
}
Expand Down Expand Up @@ -1535,7 +1535,7 @@ public void foo() {
public static class EmptyAdvice {

@Advice.OnMethodEnter
@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void advice() {
/* empty */
}
Expand All @@ -1549,7 +1549,7 @@ public void foo() {
}

@Advice.OnMethodEnter(inline = false)
@Advice.OnMethodExit(onThrowable = false, inline = false)
@Advice.OnMethodExit(inline = false)
private static void advice() {
/* empty */
}
Expand All @@ -1559,7 +1559,7 @@ private static void advice() {
public static class EmptyAdviceWithEntrySuppression {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void advice() {
/* empty */
}
Expand All @@ -1569,7 +1569,7 @@ private static void advice() {
public static class EmptyAdviceWithExitSuppression {

@Advice.OnMethodEnter
@Advice.OnMethodExit(onThrowable = false, suppress = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand All @@ -1579,7 +1579,7 @@ private static void advice() {
public static class EmptyAdviceWithSuppression {

@Advice.OnMethodEnter
@Advice.OnMethodExit(onThrowable = false, suppress = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand All @@ -1589,7 +1589,7 @@ private static void advice() {
public static class EmptyAdviceWithExceptionHandling {

@Advice.OnMethodEnter
@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void advice() {
/* empty */
}
Expand All @@ -1599,7 +1599,7 @@ private static void advice() {
public static class EmptyAdviceWithExceptionHandlingAndEntrySuppression {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void advice() {
/* empty */
}
Expand All @@ -1609,7 +1609,7 @@ private static void advice() {
public static class EmptyAdviceWithExceptionHandlingAndExitSuppression {

@Advice.OnMethodEnter
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = true, suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand All @@ -1619,7 +1619,7 @@ private static void advice() {
public static class EmptyAdviceWithExceptionHandlingAndSuppression {

@Advice.OnMethodEnter(suppress = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = true, suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand All @@ -1646,7 +1646,7 @@ private static void advice() {
@SuppressWarnings("unused")
public static class EmptyAdviceExit {

@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void advice() {
/* empty */
}
Expand All @@ -1655,7 +1655,7 @@ private static void advice() {
@SuppressWarnings("unused")
public static class EmptyAdviceExitAndSuppression {

@Advice.OnMethodExit(onThrowable = false, suppress = Throwable.class)
@Advice.OnMethodExit(suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand All @@ -1664,7 +1664,7 @@ private static void advice() {
@SuppressWarnings("unused")
public static class EmptyAdviceExitWithExceptionHandling {

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void advice() {
/* empty */
}
Expand All @@ -1673,7 +1673,7 @@ private static void advice() {
@SuppressWarnings("unused")
public static class EmptyAdviceExitWithExceptionHandlingAndSuppression {

@Advice.OnMethodExit(suppress = Throwable.class)
@Advice.OnMethodExit(onThrowable = true, suppress = Throwable.class)
private static void advice() {
/* empty */
}
Expand Down Expand Up @@ -1707,7 +1707,7 @@ private static void enter() {
Sample.enter++;
}

@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void exit() {
Sample.exit++;
}
Expand All @@ -1721,7 +1721,7 @@ private static void enter() {
Sample.enter++;
}

@Advice.OnMethodExit(onThrowable = false, suppress = Exception.class)
@Advice.OnMethodExit(suppress = Exception.class)
private static void exit() {
Sample.exit++;
}
Expand Down Expand Up @@ -1843,7 +1843,7 @@ private static void enter(@Advice.This Sample thiz) {
Sample.enter++;
}

@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void exit(@Advice.This Sample thiz) {
if (thiz == null) {
throw new AssertionError();
Expand Down Expand Up @@ -1932,7 +1932,7 @@ private static void exit() {
@SuppressWarnings("unused")
public static class ThrowableAdvice {

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void exit(@Advice.Thrown Throwable throwable) {
Sample.throwable = throwable;
}
Expand Down Expand Up @@ -2292,7 +2292,7 @@ private static void enter(@Advice.FieldValue("foo") String foo) {
@SuppressWarnings("all")
public static class ExceptionSuppressionAdvice {

@Advice.OnMethodExit
@Advice.OnMethodExit(onThrowable = true)
private static void exit(@Advice.Thrown(readOnly = false) Throwable throwable) {
throwable = null;
}
Expand Down Expand Up @@ -2442,7 +2442,7 @@ private static void exit(@Advice.Return(readOnly = false) Object value) {
@SuppressWarnings("unused")
public static class IllegalThrowableRequestAdvice {

@Advice.OnMethodExit(onThrowable = false)
@Advice.OnMethodExit
private static void exit(@Advice.Thrown Throwable value) {
throw new AssertionError();
}
Expand Down

0 comments on commit 42e457b

Please sign in to comment.