Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 275d14be authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am eeb36c5c: am d88d8174: Merge "Null pointer exception in FileRotator.java"

* commit 'eeb36c5c':
  Null pointer exception in FileRotator.java
parents 0f4a5b9a eeb36c5c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -336,7 +336,12 @@ public class FileRotator {
        final long deleteBefore = currentTimeMillis - mDeleteAgeMillis;

        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.isActive()) {
+13 −0
Original line number Diff line number Diff line
@@ -43,7 +43,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

import junit.framework.Assert;

import libcore.io.IoUtils;
import libcore.io.Libcore;

/**
 * Tests for {@link FileRotator}.
@@ -367,6 +370,16 @@ public class FileRotatorTest extends AndroidTestCase {
        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 {
        for (String name : names) {
            final OutputStream out = new FileOutputStream(new File(mBasePath, name));