Close streams in integration tests

Also remove bogus delete workaround.  Previously unclosed
FileInputStream caused test failures on Windows which cannot delete
open files.  Found with Kohsuke's file-leak-detector.
This commit is contained in:
Andrew Gaul 2014-07-18 15:36:47 -07:00
parent 0c005f8094
commit dd3dc9790e
2 changed files with 2 additions and 17 deletions

View File

@ -18,9 +18,6 @@ package org.jclouds.filesystem.util;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import com.google.common.util.concurrent.Uninterruptibles;
/**
* Utilities for the filesystem blobstore.
@ -41,12 +38,8 @@ public class Utils {
}
}
}
if (!file.delete()) {
// On windows, often the directory does not register as empty right away.
Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
if (!file.delete()) {
throw new IOException("Could not delete: " + file);
}
}
}
}

View File

@ -22,7 +22,6 @@ import static org.jclouds.reflect.Reflection2.typeToken;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import java.security.SecureRandom;
import java.util.Date;
import java.util.Map;
@ -516,14 +515,7 @@ public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreCont
public static String getContentAsStringOrNullAndClose(Blob blob) throws IOException {
checkNotNull(blob, "blob");
checkNotNull(blob.getPayload(), "blob.payload");
if (blob.getPayload().getInput() == null)
return null;
Object o = blob.getPayload().getInput();
if (o instanceof InputStream) {
return Strings2.toStringAndClose((InputStream) o);
} else {
throw new IllegalArgumentException("Object type not supported: " + o.getClass().getName());
}
return Strings2.toStringAndClose(blob.getPayload().openStream());
}
protected Module createHttpModule() {
return new JavaUrlHttpCommandExecutorServiceModule();