From 4f724f14d361e15a14428d9805b1b79bb78db774 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 10 Feb 2022 15:23:55 +0000 Subject: [PATCH] Polish "Override available() in RandomAccessDataFile's InputStream" See gh-29295 --- .../boot/loader/data/RandomAccessDataFile.java | 2 +- .../boot/loader/data/RandomAccessDataFileTests.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index 635818c8e82..06d9abcda51 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java index fd567134f4c..28427cd1dab 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/data/RandomAccessDataFileTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -199,6 +199,15 @@ class RandomAccessDataFileTests { assertThat(amountSkipped).isEqualTo(0L); } + @Test + void inputStreamAvailable() throws Exception { + assertThat(this.inputStream.available()).isEqualTo(256); + this.inputStream.skip(56); + assertThat(this.inputStream.available()).isEqualTo(200); + this.inputStream.skip(200); + assertThat(this.inputStream.available()).isEqualTo(0); + } + @Test void subsectionNegativeOffset() { assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> this.file.getSubsection(-1, 1));