id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	due_date
147	产品库动态其中一台机负载高问题分析	liaojunqiang		"网络反映pdlib有台机负载又比较高了，239.59，打开jdk-out.log，看到以下的线程比较多


{{{
cn.com.pconline.core.product.database.DbProduct.getMapProductItemWEBVisable (DbProduct.java:1205)

}}}

查看代码发现有成员变量被2个方法共用，造成线程不安全，导致死锁
{{{
private Map mapProductItemWEB = new HashMap();	
	public Map getMapProductItemWEB(ConfigProfile cp) {
		if (mapProductItemWEB!=null && mapProductItemWEB.size()>0) return mapProductItemWEB;
		mapProductItemWEB = new HashMap();
		try {
			List items = getProductItemWEB(cp);
			for (Iterator it = items.iterator(); it.hasNext();) {
				ProductItemWEB piweb = (ProductItemWEB) it.next();
				/*if (mapProductItemWEB.get(piweb.getTitle()) == null && !piweb.isHidden())*/
                                String title = piweb.getTitle();
				if (mapProductItemWEB.get(title) == null)
					mapProductItemWEB.put(title, piweb);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapProductItemWEB;
	}
	
	private Map mapProductItemWEBVisable = new HashMap();
	
	public Map getMapProductItemWEBVisable(ConfigProfile cp) {
		if (mapProductItemWEB!=null && mapProductItemWEB.size()>0) return mapProductItemWEB;
		mapProductItemWEB = new HashMap();
		try {
			List items = getProductItemWEB(cp);
			for (Iterator it = items.iterator(); it.hasNext();) {
				ProductItemWEB piweb = (ProductItemWEB) it.next();
				if (mapProductItemWEB.get(piweb.getTitle()) == null && !piweb.isHidden())
					mapProductItemWEB.put(piweb.getTitle(), piweb);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapProductItemWEB;
	}
	
}}}

修改代码后更新，待观察

{{{
public Map getMapProductItemWEB(ConfigProfile cp) {
                Map mapProductItemWEB = new HashMap();	
		try {
			List items = getProductItemWEB(cp);
			for (Iterator it = items.iterator(); it.hasNext();) {
				ProductItemWEB piweb = (ProductItemWEB) it.next();
				/*if (mapProductItemWEB.get(piweb.getTitle()) == null && !piweb.isHidden())*/
                                String title = piweb.getTitle();
				if (mapProductItemWEB.get(title) == null)
					mapProductItemWEB.put(title, piweb);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapProductItemWEB;
	}
	
	
	public Map getMapProductItemWEBVisable(ConfigProfile cp) {
                Map mapProductItemWEBVisable = new HashMap();
		try {
			List items = getProductItemWEB(cp);
			for (Iterator it = items.iterator(); it.hasNext();) {
				ProductItemWEB piweb = (ProductItemWEB) it.next();
				if (mapProductItemWEBVisable.get(piweb.getTitle()) == null && !piweb.isHidden())
					mapProductItemWEBVisable.put(piweb.getTitle(), piweb);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mapProductItemWEBVisable;
	}
}}}
"	Bug	new	major		产品库	报价库5.0		死锁 非线程安全		18/05/2016
