[Spotbugs 4.7.0] More precise exception handling, don't throw
RuntimeException, use our own UncheckedException.
This commit is contained in:
parent
af157c49d5
commit
f813045283
|
@ -17,12 +17,12 @@
|
|||
package org.apache.commons.lang3;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.apache.commons.lang3.exception.UncheckedException;
|
||||
|
||||
/**
|
||||
* <p>Helper methods for working with {@link Annotation} instances.</p>
|
||||
|
@ -136,7 +136,7 @@ public class AnnotationUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (final IllegalAccessException | InvocationTargetException ex) {
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -161,14 +161,11 @@ public class AnnotationUtils {
|
|||
try {
|
||||
final Object value = m.invoke(a);
|
||||
if (value == null) {
|
||||
throw new IllegalStateException(
|
||||
String.format("Annotation method %s returned null", m));
|
||||
throw new IllegalStateException(String.format("Annotation method %s returned null", m));
|
||||
}
|
||||
result += hashMember(m.getName(), value);
|
||||
} catch (final RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (final Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new UncheckedException(ex);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -186,14 +183,12 @@ public class AnnotationUtils {
|
|||
final ToStringBuilder builder = new ToStringBuilder(a, TO_STRING_STYLE);
|
||||
for (final Method m : a.annotationType().getDeclaredMethods()) {
|
||||
if (m.getParameterTypes().length > 0) {
|
||||
continue; //wtf?
|
||||
continue; // wtf?
|
||||
}
|
||||
try {
|
||||
builder.append(m.getName(), m.invoke(a));
|
||||
} catch (final RuntimeException ex) {
|
||||
throw ex;
|
||||
} catch (final Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (final ReflectiveOperationException ex) {
|
||||
throw new UncheckedException(ex);
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
|
|
Loading…
Reference in New Issue