Localise and document @SuppressWarnings

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1515046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2013-08-17 23:00:41 +00:00
parent 089daca602
commit 95886bc41d
1 changed files with 3 additions and 2 deletions

View File

@ -42,7 +42,6 @@ public class CloneUtils {
/**
* @since 4.3
*/
@SuppressWarnings("unchecked")
public static <T> T cloneObject(final T obj) throws CloneNotSupportedException {
if (obj == null) {
return null;
@ -56,7 +55,9 @@ public class CloneUtils {
throw new NoSuchMethodError(ex.getMessage());
}
try {
return (T) m.invoke(obj, (Object []) null);
@SuppressWarnings("unchecked") // OK because clone() preserves the class
final T result = (T) m.invoke(obj, (Object []) null);
return result;
} catch (final InvocationTargetException ex) {
final Throwable cause = ex.getCause();
if (cause instanceof CloneNotSupportedException) {