ITeye博客

查找出的细节bug

悲剧了 · 2013-03-18 17:29 · 细节理解 · 编程语言 · Markdown

1.批量导入总是少1条数据,多线程导入,少得梳理跟线程数一样 忘记 conn.setAutoCommit( true);


conn.setAutoCommit(false);
                    Object[] parmas = list.toArray();
                    ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS );
                     qr.fillStatement(ps, parmas);
                    ps.executeUpdate();
                    conn.commit();
                   


2.逻辑判断遭遇null转换字符串 由于return (obj == null) ? "null" : obj.toString();


//  public static String valueOf(Object obj) {
//	return (obj == null) ? "null" : obj.toString();
//    }
System.out.println(StringUtils. isEmpty(String. valueOf((Object) null)));----false
//  public static String valueOf(char data[]) {
//	return new String(data);
//   }
System.out.println(StringUtils. isEmpty(String. valueOf(null));---报错

System.out.println(StringUtils. isEmpty((String) null))---true


3.多线程里面框架执行 while(!service.isTerminated()){ } 代码属性执行到这,死循环卡主,并且不会跳过此段代码执行下面的

4.类似limit1,10与 id>1 and id<10的错误使用,使用以下方法,却传递 xtractRuleProcess.getAllCotentsExtract(preFileName,start,end)


	public static List<Map<String, String>> getAllCotentsExtract(
			String preFileName, int start, int length)
			throws FileNotFoundException, IOException {
		File[] files = new File[length];
		for (int i =0; i <length; i++) {
			files[i] = new File(preFileName +(start+i)+".html");
		}
		List<Map<String, String>> listMaps = new ArrayList<Map<String, String>>(
				files.length);
		for (File f : files) {
			if (f.exists()) {
				FileInputStream inputStream = new FileInputStream(f);
				String html = IOUtils.toString(inputStream, "UTF-8");
				try {
					listMaps.add(getOriginMapByHtml(html));
					inputStream.close();
				} catch (Exception e) {
					System.out.println(f.getName());
					e.printStackTrace();
				}
			}
		}
		return listMaps;
	}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。