[ 
https://issues.apache.org/jira/browse/DIRMINA-991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14176848#comment-14176848
 ] 

Emmanuel Lecharny commented on DIRMINA-991:
-------------------------------------------

As for DIRMINA-990, MINA 2.0.9 is already been vote, it's a bit too late to get 
this fix included in the package. I'll apply the proposed patch in 2.0.10, 
which should be out soon.

Here is the code after the patch :

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

> Possible faster deserialization in AbstractIoBuffer object deserialization.
> ---------------------------------------------------------------------------
>
>                 Key: DIRMINA-991
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-991
>             Project: MINA
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 2.0.8
>            Reporter: Jörg Michelberger
>              Labels: patch, performance
>
> 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 :
> {code}
> 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);
>                     }
> {code}
> Possible fix :
> {code}
> 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();
>                     }
>                 }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to