Skip to content

Commit

Permalink
snaploader-examples: applied API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pavly-gerges committed Aug 4, 2024
1 parent 55dc07f commit f1c3b09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import electrostatic.snaploader.filesystem.FileLocator;
import electrostatic.snaploader.filesystem.ZipCompressionType;
import electrostatic.snaploader.platform.util.PropertiesProvider;
import electrostatic.snaploader.util.SnapLoaderLogger;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -49,9 +51,12 @@
public class TestFilesystemMemoryLeak {
public static void main(String[] args) throws IOException {
/* Locates the image inside the Zip Compression */
SnapLoaderLogger.setLoggingEnabled(true);
final FileLocator fileLocator = new FileLocator(getZipAbsolutePath(), getFilePath(), ZipCompressionType.ZIP);
/* Extracts the image filesystem from the Zip Compression */
final FileExtractor fileExtractor = new FileExtractor(fileLocator, getExtractionPath());
fileLocator.initialize(0);
fileExtractor.initialize(0);
/* CLOSE/CLEAR I/O Resources */
fileExtractor.setExtractionListener(new FileExtractionListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import electrostatic.snaploader.LoadingCriterion;
import electrostatic.snaploader.ConcurrentNativeBinaryLoader;
import electrostatic.snaploader.UnSupportedSystemError;
import electrostatic.snaploader.throwable.UnSupportedSystemError;
import electrostatic.snaploader.platform.util.DefaultDynamicLibraries;
import electrostatic.snaploader.platform.NativeDynamicLibrary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import electrostatic.snaploader.filesystem.FileLocator;
import electrostatic.snaploader.filesystem.ZipCompressionType;
import electrostatic.snaploader.platform.util.PropertiesProvider;
import electrostatic.snaploader.throwable.FilesystemResourceScavengingException;

/**
* Tests extracting an image compression from a Zip compression type filesystem using {@link FileExtractor} API.
Expand All @@ -54,6 +55,8 @@ public static void main(String[] args) throws IOException {
final FileLocator fileLocator = new FileLocator(getZipAbsolutePath(), getFilePath(), ZipCompressionType.ZIP);
/* Extracts the image filesystem from the Zip Compression */
final FileExtractor fileExtractor = new FileExtractor(fileLocator, getExtractionPath());
fileLocator.initialize(0);
fileExtractor.initialize(0);
/* CLOSE/CLEAR I/O Resources */
fileExtractor.setExtractionListener(new FileExtractionListener() {
@Override
Expand All @@ -70,11 +73,8 @@ public void onExtractionFailure(FileExtractor fileExtractor, Throwable throwable
public void onExtractionFinalization(FileExtractor fileExtractor, FileLocator fileLocator) {
try {
fileExtractor.close();
fileLocator.close();
Logger.getLogger(TestZipExtractor.class.getName())
.log(Level.INFO, "Filesystem Resources Closed!");
} catch (IOException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new FilesystemResourceScavengingException(e);
}
}
});
Expand Down

0 comments on commit f1c3b09

Please sign in to comment.