Skip to content

FakeStorageRpc: Consider filtering by bucket *and* prefix. #207

@yuri-sergiichuk

Description

@yuri-sergiichuk

Environment details

  1. FakeStorageRpc
  2. OS type and version: Win 10
  3. Java version: java 8
  4. google-cloud-nio version(s): 0.121.2

Steps to reproduce

  1. Add object with name "test-object" to bucket "first-bucket",
  2. Add object with name "test-object" to bucket "second-bucket".
  3. List objects in "first-bucket" with "test-" prefix.
  4. Both "test-object" files from "first-bucket" and "second-bucket" are returned.

Any additional information below

The list method in the FakeStorageRpc does not take into account the bucket metadata:

    for (StorageObject so : metadata.values()) {
      if (!so.getName().startsWith(prefix)) {                       // <---------- here's the problem
        continue;
      }
      if (processedAsFolder(so, delimiter, prefix, folders)) {
        continue;
      }
      so.setSize(size(so));
      values.add(so);
    }

Technically, just adding an extra check to compare the so.getBucket() with bucket should be enough to resolve the issue.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage-nio API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions