tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 60199] New: Improve error message if a session attribute could not load due to deserialization problems
Date Tue, 04 Oct 2016 09:27:33 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=60199

            Bug ID: 60199
           Summary: Improve error message if a session attribute could not
                    load due to deserialization problems
           Product: Tomcat 8
           Version: 8.0.37
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: igor.mukhin@gmx.de

Again and again I find myself in searching for classes that do not implement
Serializable interface but are set into session. When you have such a class you
just see in the log at tomcat start that there was a problem while
deserializing the session object. I would be very helpful if the log would say
which attribute have caused the problem.

Sample implementation StandardSession.java in doReadObject(ObjectInputStream
stream):

Instead of:

        for (int i = 0; i < n; i++) {
            String name = (String) stream.readObject();
            Object value = stream.readObject();
            if ((value instanceof String) && (value.equals(NOT_SERIALIZED)))
                continue;
            if (manager.getContext().getLogger().isDebugEnabled())
                manager.getContext().getLogger().debug("  loading attribute '"
+ name +
                    "' with value '" + value + "'");
            attributes.put(name, value);
        }

do:


        for (int i = 0; i < n; i++) {
            String name = (String) stream.readObject();

            Object value = null;
            try {
                value = stream.readObject();
            } catch (Exception e) {
                manager.getContext().getLogger().error(String.format("Attribute
%s could not be deserialized due to %s", name, e.getMessage()));
            }

            if ((value instanceof String) && (value.equals(NOT_SERIALIZED)))
                continue;

            if (manager.getContext().getLogger().isDebugEnabled())
                manager.getContext().getLogger().debug("  loading attribute '"
+ name +
                    "' with value '" + value + "'");
            attributes.put(name, value);
        }

-- 
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


Mime
View raw message