Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-991

Possible faster deserialization in AbstractIoBuffer object deserialization.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.8
    • 2.0.9
    • Core

    Description

      In ObjectInputStream.resolveClass() of AbstractIoBuffer.getObject() there is a possibility to avoid duplicate call to Class.forName(). First call is done in readClassDescriptor() and second in resolveClass() in case we deal with Serializables, class descriptors are cached by the java platform, and a call of desc.forClass() in resolveClass() returns a previous resolved class, which allows skipping the ClassLoader call. I append the original source and a possible fix for this issue. Is it possible to get this in the upcomming 2.0.9 release of MINA?

      Original source :

      protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
                          String name = desc.getName();
                          try {
                              return Class.forName(name, false, classLoader);
                          } catch (ClassNotFoundException ex) {
                              return super.resolveClass(desc);
                          }
      
      

      Possible fix :

      protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
                          if (null == desc.forClass()) {  //this works for serializable desc classes.
                              String name = desc.getName();
                              try {
                                  return Class.forName(name, false, classLoader);
                              } catch (ClassNotFoundException ex) {
                                  return super.resolveClass(desc);
                              }
                          } else {
                              return desc.forClass();
                          }
                      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            j.michelberger Jörg Michelberger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: