Skip to content

Commit

Permalink
#417 OutOfMemoryError reproduced
Browse files Browse the repository at this point in the history
  • Loading branch information
kazurayam committed Apr 30, 2023
1 parent 6569444 commit af1c7cc
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions src/test/java/issues/Issue417Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package issues;

import com.kazurayam.materialstore.base.reduce.MaterialProductGroup;
import com.kazurayam.materialstore.base.reduce.differ.ImageDifferToPNG;
import com.kazurayam.materialstore.base.reduce.zipper.MaterialProduct;
import com.kazurayam.materialstore.core.FileType;
import com.kazurayam.materialstore.core.IFileType;
import com.kazurayam.materialstore.core.JobName;
import com.kazurayam.materialstore.core.JobTimestamp;
import com.kazurayam.materialstore.core.MaterialList;
import com.kazurayam.materialstore.core.MaterialstoreException;
import com.kazurayam.materialstore.core.Metadata;
import com.kazurayam.materialstore.core.QueryOnMetadata;
import com.kazurayam.materialstore.core.Store;
import com.kazurayam.materialstore.core.Stores;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* Reproducing the issue https://github.com/kazurayam/materialstore/issues/417
*
* com.kazurayam.materialstore.base.reduce.differ.ImageDifferToPNG.stuffDiff(ImageDifferToPNG.java:41 
* caused OutOfMemoryError
*/
public class Issue417Test {

private static Path fixtureDir =
Paths.get(".").resolve("src/test/fixtures/issue417");

private static Path workDir =
Paths.get(".").resolve("build/tmp/testOutput")
.resolve(Issue417Test.class.getSimpleName());
private static Store store;
private static JobName jobName = new JobName("NISA_Chronos");
private static JobTimestamp jobTimestamp;

@BeforeAll
public static void beforeAll() throws MaterialstoreException {
Path rootDir = workDir.resolve("store");
store = Stores.newInstance(rootDir);
jobTimestamp = JobTimestamp.now();
Metadata metadata = Metadata.builder().build();
Path pngFile = fixtureDir.resolve("3a98c4ba471f11462d06a4c94ef4daa4010a466a.png");
store.write(jobName, jobTimestamp, FileType.PNG, metadata, pngFile);
}

@Test
public void test_reproduce() throws MaterialstoreException {
MaterialList left = store.select(jobName, jobTimestamp,
FileType.PNG, QueryOnMetadata.ANY);
MaterialList right = store.select(jobName, JobTimestamp.laterThan(jobTimestamp),
FileType.PNG, QueryOnMetadata.ANY);
MaterialProductGroup mpg = MaterialProductGroup.builder(left, right).build();
MaterialProduct stuffed = new ImageDifferToPNG(store).stuffDiff(mpg.get(0));
assertNotNull(stuffed);
// OutOfMemoryError will occur
}


}

0 comments on commit af1c7cc

Please sign in to comment.