Skip to content

Commit

Permalink
Update release notes wrt #785, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 8, 2015
1 parent afb688a commit 7db1f44
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 53 deletions.
5 changes: 5 additions & 0 deletions release-notes/CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ Eugene Lukash
Fernando Otero (zeitos@github)
* Contributed fix for #610: Problem with forward reference in hierarchies
(2.4.4)

Charles Allen:
* Contributed #785: Add handlings for classes which are available in
`Thread.currentThread().getContextClassLoader()`
(2.5.4)
4 changes: 3 additions & 1 deletion release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Project: jackson-databind
=== Releases ===
------------------------------------------------------------------------

2.4.7 (not yet released)
2.4.6.1 (not yet released)

#676: Deserialization of class with generic collection inside depends on
how is was deserialized first time
#785: Add handlings for classes which are available in `Thread.currentThread().getContextClassLoader()`
(contributed by Charles A)

2.4.6 (23-Apr-2015)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,30 +378,7 @@ private void resolveCreators()
List<AnnotatedMethod> creatorMethods = null;

// Then static methods which are potential factory methods

Method[] classMethods;
try{
classMethods = _class.getDeclaredMethods();
}catch(final NoClassDefFoundError ex){
// One of the methods had a class that was not found in the cls.getClassLoader.
// Maybe the developer was nice and has a different class loader for this context.
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
if(loader == null){
// Nope... this is going to end poorly
throw ex;
}
final Class<?> contextClass;
try {
contextClass = loader.loadClass(_class.getName());
}
catch (ClassNotFoundException e) {
//ex.addSuppressed(e); Not until 1.7
throw ex;
}
classMethods = contextClass.getDeclaredMethods(); // Cross fingers
}

for (Method m : classMethods) {
for (Method m : _findClassMethods(_class)) {
if (!Modifier.isStatic(m.getModifiers())) {
continue;
}
Expand Down Expand Up @@ -432,7 +409,7 @@ private void resolveCreators()
}
_creatorsResolved = true;
}

/**
* Method for resolving member method information: aggregating all non-static methods
* and combining annotations (to implement method-annotation inheritance)
Expand Down Expand Up @@ -619,29 +596,8 @@ protected void _addMemberMethods(Class<?> cls, AnnotatedMethodMap methods,
if (cls == null) { // just so caller need not check when passing super-class
return;
}
Method[] classMethods;
try{
classMethods = cls.getDeclaredMethods();
}catch(final NoClassDefFoundError ex){
// One of the methods had a class that was not found in the cls.getClassLoader.
// Maybe the developer was nice and has a different class loader for this context.
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
// Nope... this is going to end poorly
throw ex;
}
final Class<?> contextClass;
try {
contextClass = loader.loadClass(cls.getName());
}
catch (ClassNotFoundException e) {
//ex.addSuppressed(e); Not until 1.7
throw ex;
}
classMethods = contextClass.getDeclaredMethods(); // Cross fingers
}
// then methods from the class itself
for (Method m : classMethods) {
for (Method m : _findClassMethods(cls)) {
if (!_isIncludableMemberMethod(m)) {
continue;
}
Expand Down Expand Up @@ -1056,11 +1012,41 @@ protected void _addMixUnders(Method src, AnnotatedMethod target) {
_addAnnotationsIfNotPresent(target, src.getDeclaredAnnotations());
}

private final boolean _isAnnotationBundle(Annotation ann)
{
return (_annotationIntrospector != null) && _annotationIntrospector.isAnnotationBundle(ann);
}

private final boolean _isAnnotationBundle(Annotation ann) {
return (_annotationIntrospector != null) && _annotationIntrospector.isAnnotationBundle(ann);
}

/**
* Helper method that gets methods declared in given class; usually a simple thing,
* but sometimes (as per [databind#785]) more complicated, depending on classloader
* setup.
*
* @since 2.4.7
*/
protected Method[] _findClassMethods(Class<?> cls)
{
try {
return cls.getDeclaredMethods();
} catch (final NoClassDefFoundError ex) {
// One of the methods had a class that was not found in the cls.getClassLoader.
// Maybe the developer was nice and has a different class loader for this context.
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
if(loader == null){
// Nope... this is going to end poorly
throw ex;
}
final Class<?> contextClass;
try {
contextClass = loader.loadClass(cls.getName());
} catch (ClassNotFoundException e) {
// !!! TODO: 08-May-2015, tatu: Chain appropriately once we have JDK7 as baseline
//ex.addSuppressed(e); Not until 1.7
throw ex;
}
return contextClass.getDeclaredMethods(); // Cross fingers
}
}

/*
/**********************************************************
/* Other methods
Expand Down

0 comments on commit 7db1f44

Please sign in to comment.