Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thread block in BeanUtil class #110

Merged
merged 1 commit into from
Jun 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.WeakHashMap;

import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
Expand All @@ -57,6 +58,7 @@

public class BeanUtil {
private static int nsCount = 1;
private static Map<String, BeanInfo> beanInfoMap = new WeakHashMap<>();

/**
* To Serilize Bean object this method is used, this will create an object array using given
Expand Down Expand Up @@ -97,18 +99,24 @@ private static String getClassName(Class type) {


private static BeanInfo getBeanInfo(Class beanClass, Class beanSuperclass) throws IntrospectionException {
BeanInfo beanInfo;
try {
if (beanSuperclass != null)
beanInfo = Introspector.getBeanInfo(beanClass, beanSuperclass);
else
beanInfo = Introspector.getBeanInfo(beanClass);
}
catch (IntrospectionException e) {
throw e;
String beanInfoKey;
if (beanSuperclass != null)
beanInfoKey = beanClass.getName().concat("|").concat(beanSuperclass.getName());
else
beanInfoKey = beanClass.getName();

BeanInfo beanInfo = beanInfoMap.get(beanInfoKey);
if (beanInfo == null) {
try {
if (beanSuperclass != null)
beanInfo = Introspector.getBeanInfo(beanClass, beanSuperclass);
else
beanInfo = Introspector.getBeanInfo(beanClass);
} catch (IntrospectionException e) {
throw e;
}
beanInfoMap.put(beanInfoKey, beanInfo);
}


return beanInfo;
}

Expand Down