https://bz.apache.org/bugzilla/show_bug.cgi?id=62182
Bug ID: 62182
Summary: Auto unboxing of Long value from a class not working
on Tomcat 8 and Java 8 Linux machine
Product: Tomcat 8
Version: 8.5.28
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ----
Hi Team,
Suppose an Java class object TestBean having arrayList of Long using SOAP CALL
and let's use reflection to inspect the each property of object. I noticed
Long value is converted to Object Type and not as Long even it has long value
in the server so the line having propertyElementValue.getClass().getName())
return java.lang.Object.
This strange behaviour is with Java 8 (any version) and Tomcat 8 (any version)
Linux version and it works fine in Windows version.
Combination of Java 8 and Tomcat 7 in linux machine works fine.
public class TestBean {
private static final long serialVersionUID = 1L;
private List<Long> customerIDs;
public List<Long> getCustomerIDs() {
return customerIDs;
}
public void setCustomerIDs(List<Long> customerIDs) {
this.customerIDs = customerIDs;
}
}
private void inspectObjectProperties(final Object object) throws
Exception {
System.out.println("object class name: "+
object.getClass().getName());
System.out.println("object class name: "+
object.getClass().getComponentType());
BeanInfo infoAboutFoo = Introspector.getBeanInfo(object.getClass());
final PropertyDescriptor[] propertyDescriptors =
infoAboutFoo.getPropertyDescriptors();
for (final PropertyDescriptor propertyDescriptor :
propertyDescriptors) {
final Object propertyValue =
propertyDescriptor.getReadMethod().invoke(object);
if ((propertyValue != null) &&
isArrayOrCollection(propertyValue.getClass())
&& !(propertyValue instanceof byte[])) {
for (final Object propertyElementValue :
((Collection<?>) propertyValue)) {
System.out.println("propertyElementValue: " +
propertyElementValue.getClass().getName());
}
}
}
}
private static boolean isArrayOrCollection(final Class clazz) {
return (clazz.isArray() || clazz.isAssignableFrom(List.class) ||
clazz.isAssignableFrom(ArrayList.class) ||
clazz.isAssignableFrom(Set.class) ||
clazz.isAssignableFrom(SortedSet.class) ||
clazz.isAssignableFrom(AbstractCollection.class) ||
clazz.isAssignableFrom(AbstractList.class) ||
clazz.isAssignableFrom(AbstractSet.class) ||
clazz.isAssignableFrom(HashSet.class) ||
clazz.isAssignableFrom(LinkedHashSet.class) ||
clazz.isAssignableFrom(LinkedList.class) ||
clazz.isAssignableFrom(TreeSet.class) ||
clazz.isAssignableFrom(Vector.class));
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]