Received: from datsunx.us.oracle.com (datsunx [10.132.180.90]) by datsun.us.oracle.com (8.14.2+Sun/8.14.2) with ESMTP id p3IM7VjX026079 for ; Mon, 18 Apr 2011 15:07:31 -0700 (PDT) Received: from [IPv6:::1] (localhost [IPv6:::1] (may be forged)) by datsunx.us.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p3IM7UI2006303; Mon, 18 Apr 2011 15:07:31 -0700 (PDT) Message-ID: <4DACB622.7070005@oracle.com> Date: Mon, 18 Apr 2011 15:07:30 -0700 From: Bill Shannon User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.13) Gecko/20110214 Lightning/1.0b2 OracleBeehiveExtension/1.0.0.3pre1-Champion ObetStats/1297113563424-705034935 Thunderbird/3.1.7 MIME-Version: 1.0 To: dev@glassfish.java.net Subject: FindBugs errors - ignoring return value from filesystem operations Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit FindBugs complains if you ignore the error return value from a filesystem operation, e.g., f.mkdirs(); Be careful when fixing these errors. In many cases it's ok if the operation fails, e.g., if the directory already exists. The fix for the above is NOT if (!f.mkdirs()) error(); // WRONG A better fix is if (!f.isDirectory() && !f.mkdirs()) error(); Also, be careful with filesystem operations that might behave differently on Windows. I recently got bit by some permission changing code. When I fixed it to fail if the permissions weren't changed, it failed on Windows. The permission changing method as currently implemented always fails on Windows. Ouch. In this case I chose to always ignore the return value.