* commit 'da07fe64b09bbf75cf831067dfe678ed06950f8e': Null pointer exception in FileRotator.java
This commit is contained in:
@ -336,7 +336,12 @@ public class FileRotator {
|
|||||||
final long deleteBefore = currentTimeMillis - mDeleteAgeMillis;
|
final long deleteBefore = currentTimeMillis - mDeleteAgeMillis;
|
||||||
|
|
||||||
final FileInfo info = new FileInfo(mPrefix);
|
final FileInfo info = new FileInfo(mPrefix);
|
||||||
for (String name : mBasePath.list()) {
|
String[] baseFiles = mBasePath.list();
|
||||||
|
if (baseFiles == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String name : baseFiles) {
|
||||||
if (!info.parse(name)) continue;
|
if (!info.parse(name)) continue;
|
||||||
|
|
||||||
if (info.isActive()) {
|
if (info.isActive()) {
|
||||||
|
@ -43,7 +43,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
|
import libcore.io.Libcore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link FileRotator}.
|
* Tests for {@link FileRotator}.
|
||||||
@ -367,6 +370,16 @@ public class FileRotatorTest extends AndroidTestCase {
|
|||||||
assertReadAll(rotate, "bar");
|
assertReadAll(rotate, "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFileSystemInaccessible() throws Exception {
|
||||||
|
File inaccessibleDir = null;
|
||||||
|
String dirPath = getContext().getFilesDir() + File.separator + "inaccessible";
|
||||||
|
inaccessibleDir = new File(dirPath);
|
||||||
|
final FileRotator rotate = new FileRotator(inaccessibleDir, PREFIX, SECOND_IN_MILLIS, SECOND_IN_MILLIS);
|
||||||
|
|
||||||
|
// rotate should not throw on dir not mkdir-ed (or otherwise inaccessible)
|
||||||
|
rotate.maybeRotate(TEST_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
private void touch(String... names) throws IOException {
|
private void touch(String... names) throws IOException {
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
final OutputStream out = new FileOutputStream(new File(mBasePath, name));
|
final OutputStream out = new FileOutputStream(new File(mBasePath, name));
|
||||||
|
Reference in New Issue
Block a user