diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-06-08 16:23:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-08 16:23:17 +0200 |
commit | 3a8599c83c599032bbf708e8453a873e85488291 (patch) | |
tree | de87649d16f2574e589dc846c1eccce5232cb0ce /controller-server | |
parent | 4393f8fdfc83da555bd8dfda7e10966b68e4dccb (diff) | |
parent | 465c73b9ce675601c7805fd773b3b4677fe3cdaf (diff) |
Merge pull request #27352 from vespa-engine/jonmv/redo-truncated-app-package-streams
Keep only meta data in truncated package by default
Diffstat (limited to 'controller-server')
2 files changed, 7 insertions, 7 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageStream.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageStream.java index 3880b028eb0..7c44a3d0f5c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageStream.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageStream.java @@ -35,14 +35,14 @@ public class ApplicationPackageStream { private final AtomicReference<ApplicationPackage> truncatedPackage = new AtomicReference<>(); private final FileTime createdAt = FileTime.fromMillis(System.currentTimeMillis()); - /** Stream that effectively copies the input stream to its {@link #truncatedPackage()} when exhausted. */ + /** Stream that copies application meta and other XML files from the input stream to its {@link #truncatedPackage()} when exhausted. */ public ApplicationPackageStream(Supplier<InputStream> in) { - this(in, () -> __ -> true, Map.of()); + this(in, () -> name -> ApplicationPackage.prePopulated.contains(name) || name.endsWith(".xml"), Map.of()); } - /** Stream that replaces the indicated entries, and copies all metadata files to its {@link #truncatedPackage()} when exhausted. */ - public ApplicationPackageStream(Supplier<InputStream> in, Supplier<Replacer> replacer) { - this(in, () -> name -> ApplicationPackage.prePopulated.contains(name) || name.endsWith(".xml"), replacer); + /** Stream that copies the indicated entries from the input stream to its {@link #truncatedPackage()} when exhausted. */ + public ApplicationPackageStream(Supplier<InputStream> in, Supplier<Predicate<String>> truncation) { + this(in, truncation, Map.of()); } /** Stream that replaces the indicated entries, and copies the filtered entries to its {@link #truncatedPackage()} when exhausted. */ @@ -58,7 +58,7 @@ public class ApplicationPackageStream { } /** - * Returns a new stream continaing the zipped application package this wraps. Separate streams may exist concurrently, + * Returns a new stream containing the zipped application package this wraps. Separate streams may exist concurrently, * and the first to be exhausted will populate the truncated application package. */ public InputStream zipStream() { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java index e915a204e4b..f018b566674 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/application/pkg/ApplicationPackageTest.java @@ -229,7 +229,7 @@ public class ApplicationPackageTest { assertEquals(content, unzip(zip)); AngryStreams angry = new AngryStreams(zip); - ApplicationPackageStream identity = new ApplicationPackageStream(angry::stream); + ApplicationPackageStream identity = new ApplicationPackageStream(angry::stream, () -> __ -> true); InputStream lazy = new LazyInputStream(() -> new ByteArrayInputStream(identity.truncatedPackage().zippedContent())); assertEquals("must completely exhaust input before reading package", assertThrows(IllegalStateException.class, identity::truncatedPackage).getMessage()); |