mirror of https://github.com/apache/jclouds.git
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:
parent
0c005f8094
commit
dd3dc9790e
|
@ -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.
|
||||
|
@ -42,11 +39,7 @@ 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);
|
||||
}
|
||||
throw new IOException("Could not delete: " + 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();
|
||||
|
|
Loading…
Reference in New Issue