You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2018/03/15 15:56:22 UTC

[Bug 62182] New: Auto unboxing of Long value from a class not working on Tomcat 8 and Java 8 Linux machine

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: dev@tomcat.apache.org
          Reporter: mahesha.puttaswamy@gmail.com
  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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 62182] Auto unboxing of Long value from a class not working on Tomcat 8 and Java 8 Linux machine

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62182

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
This is nothing to do with Tomcat.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org