### Runnable samples with jbang and mise Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Commands to run the sample applications using jbang and mise. Docker is the only prerequisite; mise installs Java and jbang. The demo command starts MinIO, creates the bucket, and runs all three samples; individual samples can be run with demo:jdk, demo:commons-vfs, or demo:spring. ```shell cd samples mise trust mise run demo # start MinIO, create the bucket, run all three samples mise run demo:jdk # … or just one of them (jdk / commons-vfs / spring) mise run down # stop and remove the container ``` -------------------------------- ### S3 URI Usage Examples Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/adr/006-jdk-module-s3-uri-contract.md Shows how to create a filesystem or path with the S3 URI. The first example uses the default region and credentials chain. The second pins the region in the URI. The third sets the endpoint and region in the URI while supplying credentials via the env map. The last demonstrates that the env map value takes precedence over the URI query parameter. ```java // Real AWS, region + credentials from the environment / default chain: FileSystems.newFileSystem(URI.create("s3://my-bucket"), Map.of()); ``` ```java // Real AWS, region pinned in the URI (self-contained for Paths.get): Path p = Path.of(URI.create("s3://my-bucket/reports/q3.csv?region=eu-central-1")); ``` ```java // Local MinIO — endpoint in the URI, credentials (only) in the env map: FileSystems.newFileSystem( URI.create("s3://my-bucket?endpoint=http://localhost:9000®ion=us-east-1"), Map.of("credentialsProvider", staticProvider)); ``` ```java // env map wins over the URI when both set the same key: FileSystems.newFileSystem( URI.create("s3://my-bucket?region=eu-central-1"), Map.of("region", "eu-west-1")); // → eu-west-1 ``` -------------------------------- ### Setup: Create test folders and files Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/test-cases/g-concurrent-access.md Creates the base folders and files under /concurrent/ needed for the concurrent access tests. Run before executing the test steps. ```text Create folder /concurrent/folders/ Create folder /concurrent/read-test/ Create file /concurrent/read-test/file1 Create file /concurrent/read-test/file2 ``` -------------------------------- ### URL scheme examples Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Examples of the canonical secret-free s3:// URL scheme. The bucket is the host; optional region and endpoint parameters are in the query string. Credentials are never in the URL. ```text s3://my-bucket s3://my-bucket/reports/q3.csv?region=eu-central-1 s3://my-bucket?region=ru-central1&endpoint=https://storage.yandexcloud.net ``` -------------------------------- ### Use --no-optional-locks for read-only git commands Source: https://github.com/abashev/vfs-s3/blob/17.0/CONTRIBUTING.md Use `--no-optional-locks` for read-only git commands to avoid taking locks. Examples: status and diff. ```sh git --no-optional-locks status git --no-optional-locks diff ``` -------------------------------- ### JDK NIO.2 FileSystem usage Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Open an S3 bucket as a java.nio.file.FileSystem using the secret-free s3:// scheme. Credentials come from the AWS SDK default chain; region can be provided via the ?region= query parameter or the environment map. The example writes and reads a file and lists a directory. ```java import java.net.URI; import java.nio.file.*; import java.util.Map; // Region can ride in the URL (?region=…) or in the env map; credentials come from the SDK chain. URI bucket = URI.create("s3://my-bucket?region=eu-central-1"); try (FileSystem fs = FileSystems.newFileSystem(bucket, Map.of())) { Path file = fs.getPath("/reports/q3.csv"); Files.writeString(file, "hello,world\n"); String csv = Files.readString(file); try (var dir = Files.newDirectoryStream(fs.getPath("/reports"))) { dir.forEach(System.out::println); } } ``` -------------------------------- ### S3ResourcePatternResolver with Ant-style wildcards Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Uses S3ResourcePatternResolver to list resources matching Ant-style wildcards. The '?' wildcard is not available because the first '?' in a location starts the query component. ```java try (var resolver = new S3ResourcePatternResolver()) { Resource[] reports = resolver.getResources("s3://my-bucket/reports/*.csv"); } ``` -------------------------------- ### Gradle dependencies for vfs modules Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Add the required vfs module dependencies to your Gradle build. The jdk module provides a JDK NIO.2 FileSystemProvider, commons-vfs provides an Apache Commons VFS provider, and spring provides Spring Resource/ResourceLoader support. Version 17.0.1 is used in the example. ```gradle implementation 'com.github.abashev:vfs-jdk:17.0.1' // JDK NIO.2 FileSystemProvider implementation 'com.github.abashev:vfs-commons:17.0.1' // Apache Commons VFS provider implementation 'com.github.abashev:vfs-spring:17.0.1' // Spring Resource / ResourceLoader ``` -------------------------------- ### Spring Resource usage Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Access an S3 object through the Spring Resource API using the same secret-free s3:// scheme. The example uses S3ResourceLoader to get a WritableResource and writes to it. Credentials come from the AWS SDK default chain. ```java // package: com.github.vfss3.spring try (S3ResourceLoader loader = new S3ResourceLoader()) { WritableResource resource = (WritableResource) loader.getResource("s3://my-bucket/path/object.txt"); try (OutputStream out = resource.getOutputStream()) { out.write("hello".getBytes()); } } ``` -------------------------------- ### Apache Commons VFS usage Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Resolve an S3 object using the Apache Commons VFS provider with the legacy dialect, where region and endpoint are encoded in the host. The example writes to the file's content output stream. ```java FileSystemManager fs = VFS.getManager(); FileObject file = fs.resolveFile("s3://my-bucket.s3.eu-central-1.amazonaws.com/reports/q3.csv"); try (OutputStream out = file.getContent().getOutputStream()) { out.write("hello,world\n".getBytes()); } ``` -------------------------------- ### CI Gradle Commands Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/multi-agent-development.md Run compile, test, and check plus integrationTest in CI without mise exec. ```sh ./gradlew compile ./gradlew test ./gradlew check integrationTest ``` -------------------------------- ### Local build commands with mise Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Commands to trust mise and run Gradle builds and tests. The build compiles, runs unit tests, and checks formatting/lint. ```bash mise trust mise exec -- ./gradlew build # compile + unit tests + formatting/lint checks mise exec -- ./gradlew :modules:jdk:test # one module's unit tests ``` -------------------------------- ### JDK FileSystemProvider: open S3 bucket with credentials and endpoint Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Opens a JDK NIO.2 FileSystem for an S3 bucket using a pre-built AwsCredentialsProvider and URL query parameters for endpoint and region. The env map can also carry region/endpoint; when both are set, the env map wins over the URL. ```java import software.amazon.awssdk.auth.credentials.*; var creds = StaticCredentialsProvider.create(AwsBasicCredentials.create("key", "secret")); URI bucket = URI.create("s3://my-bucket?endpoint=https://storage.yandexcloud.net®ion=ru-central1"); try (FileSystem fs = FileSystems.newFileSystem(bucket, Map.of("credentialsProvider", creds))) { Files.copy(Path.of("/tmp/backup.zip"), fs.getPath("/backups/backup.zip")); } ``` -------------------------------- ### Local Development Gradle Commands Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/multi-agent-development.md Run compile, test, integrationTest, and check locally using mise exec. Integration tests are split from unit tests; remote integration tests may require AWS credentials and external S3-compatible resources. ```sh mise exec -- ./gradlew compile mise exec -- ./gradlew test mise exec -- ./gradlew integrationTest mise exec -- ./gradlew check ``` -------------------------------- ### Test steps: Concurrent create/delete, read, and deadlock detection Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/test-cases/g-concurrent-access.md Describes the three test steps: concurrent create/delete (200 iterations), concurrent read (200 iterations), and deadlock detection. Steps 1 and 2 are independent; step 3 depends on step 1 completing and reuses the same prefix. ```text 1. Concurrent create/delete (200 iterations, parallel threads): Each iteration: → create folder /concurrent/folders/folder--/ → assert: exists → refresh → assert: still exists → delete → refresh → assert: does not exist 2. Concurrent read (200 iterations, parallel threads): Each iteration: → resolve /concurrent/read-test → getParent → assert: not null → refresh → getChildren → assert: not null → assert: exists 3. Deadlock detection: → delete children of /concurrent/folders/ → create 10 files: deadlock-0 through deadlock-9 → start 1 thread: continuously getParent() for each file → start 3 threads: continuously getChildren(), verify count == 10 → run 5 seconds, check for deadlocks every 1 second → assert: no deadlocks detected, 0 wrong results → clean up children ``` -------------------------------- ### Legacy commons-vfs URL format Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md The legacy commons-vfs dialect packs all settings into the URL, with region in the host and optional credentials in the userinfo. The commons-vfs module still parses this format for backward compatibility, but new code should prefer the secret-free scheme. ```text s3://[[access-key:secret-key]:sign-region]@endpoint-url/folder-or-bucket/ ``` -------------------------------- ### S3ResourceLoader with custom S3Client Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Creates an S3ResourceLoader with a pre-configured S3Client for DI, metrics, or custom retries. The loader never closes the provided client. ```java S3ResourceLoader loader = new S3ResourceLoader(myS3Client); ``` -------------------------------- ### Commons VFS: resolve s3:// URLs with virtual-hosted and path-style Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Uses the Apache Commons VFS provider to resolve s3:// URLs in its legacy dialect. Supports virtual-hosted (bucket in host) and path-style (bucket in path) formats; credentials come from the AWS SDK default chain or S3FileSystemOptions.setCredentialsProvider. ```java FileSystemManager fs = VFS.getManager(); // virtual-hosted (bucket in the host) … FileObject a = fs.resolveFile("s3://my-bucket.storage.yandexcloud.net/dir/file.txt"); // … or path-style (bucket in the path) FileObject b = fs.resolveFile("s3://s3.eu-central-1.amazonaws.com/my-bucket/dir/file.txt"); ``` -------------------------------- ### Suggested Branch Names Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/multi-agent-development.md Suggested branch naming conventions for feature branches. ```text feature/issue-N-short-description feature/short-description ``` -------------------------------- ### S3 URI Grammar Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/adr/006-jdk-module-s3-uri-contract.md Defines the accepted URI format for the S3 filesystem. The scheme must be 's3', the host is the bucket name, and the path is the object key. Query parameters 'region' and 'endpoint' are recognized; userinfo is rejected, and port/fragment are ignored. ```plaintext s3://[/][?region=&endpoint=] ``` -------------------------------- ### Set remote test environment variables Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Shell environment variables required for remote test suites. BASE_URL follows the URL scheme and includes region and optional endpoint. ```bash export AWS_ACCESS_KEY_ID=AAAAAAA export AWS_SECRET_KEY=SSSSSSS export BASE_URL='s3://?region=[&endpoint=]' ``` -------------------------------- ### JDK FileSystemProvider: env map overrides URL region and endpoint Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Shows precedence when the same key is set in both the env map and the URL: env map wins over URL query, which wins over AWS default. The URL sets region=eu-central-1 but the map overrides it to eu-west-1 and supplies the endpoint. ```java // The URL sets region=eu-central-1, but the env map overrides it. URI bucket = URI.create("s3://my-bucket?region=eu-central-1"); var env = Map.of( "region", "eu-west-1", // wins over the URL's eu-central-1 "endpoint", "https://storage.yandexcloud.net"); // endpoint supplied via the map try (FileSystem fs = FileSystems.newFileSystem(bucket, env)) { // effective config: region = eu-west-1, endpoint = storage.yandexcloud.net (credentials from the SDK chain) Files.writeString(fs.getPath("/reports/q3.csv"), "hello,world\n"); } ``` -------------------------------- ### Maven dependency for vfs-jdk Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Add the vfs-jdk module as a Maven dependency. This is the Maven equivalent of the Gradle dependency shown above. ```xml com.github.abashev vfs-jdk 17.0.1 ``` -------------------------------- ### S3ResourceLoader with explicit region/endpoint Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Creates an S3ResourceLoader with explicit region and endpoint for any S3-compatible backend, using default credential chain. The loader is AutoCloseable and should be used in a try-with-resources block. ```java var config = S3ClientConfig.defaults() .withRegion("ru-central1") .withEndpoint("https://storage.yandexcloud.net"); try (S3ResourceLoader loader = new S3ResourceLoader(config)) { /* … */ } ``` -------------------------------- ### PR Description Template Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/multi-agent-development.md Markdown template for pull request descriptions, including summary, related issue, changes, and testing checklist. ```markdown ## Summary Brief description of what this PR does. ## Related Issue Closes #123 ## Changes - What was added, changed, or removed ## Testing - [ ] `mise exec -- ./gradlew test` - [ ] `mise exec -- ./gradlew integrationTest` (if integration behavior changed) - [ ] Other relevant checks ``` -------------------------------- ### Register S3ProtocolResolver in Spring context Source: https://github.com/abashev/vfs-s3/blob/17.0/README.md Registers an S3ProtocolResolver with an AnnotationConfigApplicationContext before refresh to enable s3:// resource resolution throughout the application, including @Value and @PropertySource. ```java var s3Loader = new S3ResourceLoader(); var context = new AnnotationConfigApplicationContext(); context.addProtocolResolver(new S3ProtocolResolver(s3Loader)); // before refresh() context.register(AppConfig.class); context.refresh(); // anywhere in the app now: @Value("s3://my-bucket/config/app.properties") Resource configFile; ``` -------------------------------- ### Workflow: update-pr-branch.yml Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/adr/002-merge-automation-and-release-strategy.md GitHub Actions workflow that updates PR branches on push to 17.0 and nightly at 3:00 AM UTC. Requires one approval and passed checks. ```yaml name: Update PR branches on: push: branches: [17.0] schedule: # Run every night at 3:00 AM UTC to catch any stuck PRs - cron: '0 3 * * *' jobs: update: runs-on: ubuntu-latest steps: - uses: adRise/update-pr-branch@v0.10 with: token: ${{ secrets.GITHUB_TOKEN }} base: '17.0' required_approval_count: 1 require_passed_checks: true ``` -------------------------------- ### Rewrite BaseIntegrationTest with LocalStack container Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/issues/migrate-to-testcontainers.md Replaces EnvironmentConfiguration and env var loading with a shared LocalStack S3 container. Uses @Testcontainers and @Container annotations, and configures S3FileSystemOptions to point at the container endpoint. ```java @Testcontainers public abstract class BaseIntegrationTest { @Container static LocalStackContainer localstack = new LocalStackContainer( DockerImageName.parse("localstack/localstack:3")) .withServices(LocalStackContainer.Service.S3); @BeforeAll public final void initBucket() { // Configure S3FileSystemOptions to point at localstack.getEndpoint() // Use localstack.getAccessKey() / localstack.getSecretKey() // No more EnvironmentConfiguration or .envrc parsing } } ``` -------------------------------- ### Add Testcontainers and LocalStack dependencies to pom.xml Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/issues/migrate-to-testcontainers.md Adds Testcontainers core and LocalStack modules as test-scoped dependencies for self-contained integration tests. ```xml org.testcontainers testcontainers test org.testcontainers localstack test ``` -------------------------------- ### Pin GitHub Action to commit SHA with version comment Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/adr/003-github-actions-supply-chain-security.md Use a full 40-character commit SHA in the `uses:` reference to prevent tag hijacking attacks. The version comment (e.g., `# v6`) maintains readability. This is required for every third-party action in the project's workflows. ```yaml - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 ``` -------------------------------- ### Teardown: Delete /concurrent/ recursively Source: https://github.com/abashev/vfs-s3/blob/17.0/docs/test-cases/g-concurrent-access.md Cleans up the test environment by recursively deleting the /concurrent/ directory after tests complete. ```text Delete `/concurrent/` recursively. ```