---
title: "查找出的细节bug"
author: "悲剧了"
date: "2013-03-18T17:29:18Z"
tags: []
categories: ["编程语言"]
slug: "bug"
draft: false
lastmod: "2013-03-18T17:33:09Z"
id: 1831344
url: "https://blognojava.iteye.com/blog/1831344"
---

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

```java

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();

```java

//  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)

```java

	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;
	}

```