hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amit Sela <am...@infolinks.com>
Subject Re: Class loading in Hadoop and HBase
Date Thu, 20 Mar 2014 06:43:40 GMT
I understand that. But why ? Why prefer the TCCL over the class's CL ?
On Mar 20, 2014 3:00 AM, "haosdent" <haosdent@gmail.com> wrote:

> Sometimes we would use "Thread.currentThread().setContextClassLoader(
> classLoader);" to specify classloader. So
> "Thread.currentThread().getContextClassLoader();"
> should be the first choice.
>
>
> On Thu, Mar 20, 2014 at 1:53 AM, Amit Sela <amits@infolinks.com> wrote:
>
> > Hi all,
> > I'm running with Hadoop 1.0.4 and HBase 0.94.12 bundled (OSGi) versions I
> > built.
> > Most issues I encountered are related to class loaders.
> >
> > One of the patterns I noticed in both projects is:
> >
> >     ClassLoader cl = Thread.currentThread().getContextClassLoader();
> >       if(cl == null) {
> >       cl = Clazz.class.getClassLoader();
> >     }
> >
> > Where Clazz is the Class containing this code.
> >
> > I was wondering about this choice... Why not go the other way around:
> >
> >     ClassLoader cl = Clazz.class.getClassLoader();
> >       if(cl == null) {
> >       cl = Thread.currentThread().getContextClassLoader();
> >     }
> >
> > And in a more general note, why not always use Configuration (and let
> it's
> > cl be this.getClass().getClassLoader()) to load classes ?
> >
> > That would surely help in integration with modularity frameworks.
> >
> > Thanks,
> > Amit.
> >
>
>
>
> --
> Best Regards,
> Haosdent Huang
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message