Remove some @SuppressWarnings.
This commit is contained in:
parent
1682277ebc
commit
357951ff5c
|
@ -1082,11 +1082,10 @@ public class ObjectUtils {
|
|||
Validate.notEmpty(items, "null/empty items");
|
||||
Validate.noNullElements(items);
|
||||
Validate.notNull(comparator, "comparator");
|
||||
final TreeSet<T> sort = new TreeSet<>(comparator);
|
||||
Collections.addAll(sort, items);
|
||||
final TreeSet<T> treeSet = new TreeSet<>(comparator);
|
||||
Collections.addAll(treeSet, items);
|
||||
@SuppressWarnings("unchecked") //we know all items added were T instances
|
||||
final
|
||||
T result = (T) sort.toArray()[(sort.size() - 1) / 2];
|
||||
final T result = (T) treeSet.toArray()[(treeSet.size() - 1) / 2];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,21 +138,17 @@ public class SerializationUtils {
|
|||
final byte[] objectData = serialize(object);
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
|
||||
|
||||
try (ClassLoaderAwareObjectInputStream in = new ClassLoaderAwareObjectInputStream(bais,
|
||||
object.getClass().getClassLoader())) {
|
||||
final Class<T> cls = ObjectUtils.getClass(object);
|
||||
try (ClassLoaderAwareObjectInputStream in = new ClassLoaderAwareObjectInputStream(bais, cls.getClassLoader())) {
|
||||
/*
|
||||
* when we serialize and deserialize an object,
|
||||
* it is reasonable to assume the deserialized object
|
||||
* is of the same type as the original serialized object
|
||||
* when we serialize and deserialize an object, it is reasonable to assume the deserialized object is of the
|
||||
* same type as the original serialized object
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // see above
|
||||
final T readObject = (T) in.readObject();
|
||||
return readObject;
|
||||
return cls.cast(in.readObject());
|
||||
|
||||
} catch (final ClassNotFoundException ex) {
|
||||
throw new SerializationException("ClassNotFoundException while reading cloned object data", ex);
|
||||
} catch (final IOException ex) {
|
||||
throw new SerializationException("IOException while reading or closing cloned object data", ex);
|
||||
} catch (final ClassNotFoundException | IOException ex) {
|
||||
throw new SerializationException(
|
||||
String.format("%s while reading cloned object data", ex.getClass().getSimpleName()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue