日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

靜態(tài)分析工具Findbugs怎么用?( 二 )


迭代器Iterator無(wú)法拋出NoSuchElement異常,類(lèi)實(shí)現(xiàn)了java.util.Iterator接口,但是next()方法無(wú)法拋出java.util.NoSuchElementException異常,因此,next()方法應(yīng)該做如此修改,當(dāng)被調(diào)用時(shí),如果沒(méi)有element返回,則拋出NoSuchElementException異常
4.4 J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION
J2EE: Store of non serializable object into HttpSession (J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION)
This code seems to be storing a non-serializable object into an HttpSession. If this session is passivated or migrated, an error will result.
將沒(méi)有實(shí)現(xiàn)serializable的對(duì)象放到HttpSession中,當(dāng)這個(gè)session被鈍化和遷移時(shí),將會(huì)產(chǎn)生錯(cuò)誤,建議放到HttpSession中的對(duì)象都實(shí)現(xiàn)serializable接口 。
4.5 ODR_OPEN_DATABASE_RESOURCE
ODR: Method may fail to close database resource (ODR_OPEN_DATABASE_RESOURCE)
The method creates a database resource (such as a database connection or row set), does not assign it to any fields, pass it to other methods, or return it, and does not appear to close the object on all paths out of the method. Failure to close database resources on all paths out of a method may result in poor performance, and could cause the application to have problems communicating with the database.
方法可能未關(guān)閉數(shù)據(jù)庫(kù)資源,未關(guān)閉數(shù)據(jù)庫(kù)資源將會(huì)導(dǎo)致性能變差,還可能引起應(yīng)用與服務(wù)器間的通訊問(wèn)題 。
4.6 OS_OPEN_STREAM
OS: Method may fail to close stream (OS_OPEN_STREAM)
The method creates an IO stream object, does not assign it to any fields, pass it to other methods that might close it, or return it, and does not appear to close the stream on all paths out of the method. This may result in a file descriptor leak. It is generally a good idea to use a finally block to ensure that streams are closed.
方法可能未關(guān)閉stream,方法產(chǎn)生了一個(gè)IO流,卻未關(guān)閉,將會(huì)導(dǎo)致文件描繪符的泄漏,建議使用finally block來(lái)確保io stream被關(guān)閉 。
4.7 DMI_CALLING_NEXT_FROM_HASNEXT
DMI: hasNext method invokes next (DMI_CALLING_NEXT_FROM_HASNEXT)
The hasNext() method invokes the next() method. This is almost certainly wrong, since the hasNext() method is not supposed to change the state of the iterator, and the next method is supposed to change the state of the iterator.
4.8 IL_INFINITE_LOOP
IL: An apparent infinite loop (IL_INFINITE_LOOP)
This loop doesn't seem to have a way to terminate (other than by perhaps throwing an exception).
明顯的無(wú)限循環(huán).
4.9 IL_INFINITE_RECURSIVE_LOOP
IL: An apparent infinite recursive loop (IL_INFINITE_RECURSIVE_LOOP)
This method unconditionally invokes itself. This would seem to indicate an infinite recursive loop that will result in a stack overflow.
明顯的無(wú)限迭代循環(huán),將導(dǎo)致堆棧溢出.
4.10 WMI_WRONG_MAP_ITERATOR
WMI: Inefficient use of keySet iterator instead of entrySet iterator (WMI_WRONG_MAP_ITERATOR)
This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.
使用了keySet iterator和Map.get(key)來(lái)獲取Map值,這種方式效率低,建議使用entrySet的iterator效率更高.
4.11 IM_BAD_CHECK_FOR_ODD
IM: Check for oddness that won't work for negative numbers (IM_BAD_CHECK_FOR_ODD)
The code uses x % 2 == 1 to check to see if a value is odd, but this won't work for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check for oddness, consider using x & 1 == 1, or x % 2 != 0.
奇偶檢測(cè)邏輯,未考慮負(fù)數(shù)情況.

推薦閱讀