Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Code cleanup: fix minor style & findbugs issues

  • Loading branch information...
commit 7091f332e0b4a84ba28cbc499a66bab6373c7f86 1 parent fd31d2f
Chris Wilper cwilper authored
57 akubra-fs/src/main/java/org/akubraproject/fs/FSBlob.java
View
@@ -21,30 +21,28 @@
*/
package org.akubraproject.fs;
+import org.akubraproject.Blob;
+import org.akubraproject.DuplicateBlobException;
+import org.akubraproject.MissingBlobException;
+import org.akubraproject.UnsupportedIdException;
+import org.akubraproject.impl.AbstractBlob;
+import org.akubraproject.impl.StreamManager;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
import java.net.URI;
import java.net.URISyntaxException;
-
import java.nio.channels.FileChannel;
-
import java.util.Map;
import java.util.Set;
-import org.akubraproject.Blob;
-import org.akubraproject.DuplicateBlobException;
-import org.akubraproject.MissingBlobException;
-import org.akubraproject.UnsupportedIdException;
-import org.akubraproject.impl.AbstractBlob;
-import org.akubraproject.impl.StreamManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Filesystem-backed Blob implementation.
*
@@ -78,6 +76,7 @@
* @param blobId the identifier for the blob
* @param manager the stream manager
* @param modified the set of modified files in the connection; may be null
+ * @throws UnsupportedIdException if the given id is not supported
*/
FSBlob(FSBlobStoreConnection connection, File baseDir, URI blobId, StreamManager manager,
Set<File> modified) throws UnsupportedIdException {
@@ -194,10 +193,9 @@ public Blob moveTo(URI blobId, Map<String, String> hints) throws IOException {
success = true;
} finally {
- if (!success) {
- if (other.exists() && !other.delete())
- log.error("Error deleting destination file '" + other + "' after source file '" + file
- + "' copy failure");
+ if (!success && other.exists() && !other.delete()) {
+ log.error("Error deleting destination file '" + other + "' after source file '" + file
+ + "' copy failure");
}
}
}
@@ -234,7 +232,7 @@ private void makeParentDirs(File file) throws IOException {
File parent = file.getParentFile();
if (parent != null && !parent.exists()) {
- parent.mkdirs();
+ parent.mkdirs(); // See https://jira.duraspace.org/browse/AKUBRA-3
if (!parent.exists())
throw new IOException("Unable to create parent directory: " + parent.getPath());
}
@@ -246,41 +244,20 @@ private static void nioCopy(File source, File dest) throws IOException {
log.debug("Performing force copy-and-delete of source '" + source + "' to '"
+ dest + "'");
- boolean success_in = false;
try {
f_in = new FileInputStream(source);
- boolean success_out = false;
try {
f_out = new FileOutputStream(dest);
FileChannel in = f_in.getChannel();
FileChannel out = f_out.getChannel();
in.transferTo(0, source.length(), out);
-
- success_out = true;
} finally {
- if (f_out != null) {
- try {
- f_out.close();
- } catch (IOException io) {
- if (success_out)
- throw io;
- log.warn("Could not close destination file '" + dest + "'", io);
- }
- }
+ IOUtils.closeQuietly(f_out);
}
- success_in = true;
} finally {
- if (f_in != null) {
- try {
- f_in.close();
- } catch (IOException io) {
- if (success_in)
- throw io;
- log.warn("Could not close source file '" + source +"'", io);
- }
- }
+ IOUtils.closeQuietly(f_in);
}
if (!dest.exists()) throw new IOException("Failed to copy file to new location: " + dest);
12 findbugs_exclude.xml
View
@@ -5,13 +5,19 @@
</Match>
<Match>
+ <Bug pattern="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" />
+ <Class name="org.akubraproject.tck.BtmUtils$SimpleXAResourceProducer$1" />
+ <Method name="apply" />
+ </Match>
+
+ <Match>
<Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" />
<Class name="org.akubraproject.txn.derby.TransactionalConnection" />
<Method name="&lt;init&gt;" />
</Match>
<Match>
- <Bug pattern="OBL_UNSATISFIED_OBLIGATION" />
+ <Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE" />
<Class name="org.akubraproject.txn.derby.TransactionalStore$3" />
<Method name="run" />
</Match>
@@ -44,13 +50,13 @@
</Match>
<Match>
- <Bug pattern="OBL_UNSATISFIED_OBLIGATION"/>
+ <Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE"/>
<Class name="org.akubraproject.fs.FSBlob" />
<Method name="openOutputStream" />
</Match>
<Match>
- <Bug pattern="OBL_UNSATISFIED_OBLIGATION"/>
+ <Bug pattern="OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE"/>
<Class name="org.akubraproject.fs.FSBlob" />
<Method name="openInputStream" />
</Match>
Please sign in to comment.
Something went wrong with that request. Please try again.