Merge branch '3.3.x'

Closes gh-41616
This commit is contained in:
Andy Wilkinson
2024-07-25 16:17:27 +01:00
67 changed files with 241 additions and 273 deletions

View File

@@ -22,6 +22,7 @@ import org.springframework.boot.configurationsample.Name;
/**
* Immutable record properties making use of {@code @Name}.
*
* @param imports some imports
* @author Andy Wilkinson
*/
@ConfigurationProperties("named")

View File

@@ -18,10 +18,6 @@ package org.springframework.boot.configurationsample.record;
import org.springframework.boot.configurationsample.ConfigurationProperties;
/**
* @author Moritz Halbritter
* @param alpha the alpha property
*/
@ConfigurationProperties("record-with-getter")
public record RecordWithGetter(String alpha) {

View File

@@ -32,7 +32,6 @@ public final class GradleVersions {
private GradleVersions() {
}
@SuppressWarnings("UnstableApiUsage")
public static List<String> allCompatible() {
if (isJavaVersion(JavaVersion.VERSION_20)) {
return Arrays.asList("8.3", "8.9");

View File

@@ -268,6 +268,12 @@ public abstract class Packager {
}
}
/**
* Writes a signature file if necessary for the given {@code writtenLibraries}.
* @param writtenLibraries the libraries
* @param writer the writer to use to write the signature file if necessary
* @throws IOException if a failure occurs when writing the signature file
*/
protected void writeSignatureFileIfNecessary(Map<String, Library> writtenLibraries, AbstractJarWriter writer)
throws IOException {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 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.
@@ -33,44 +33,49 @@ class ByteArrayDataBlockTests {
@Test
void sizeReturnsByteArrayLength() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
assertThat(dataBlock.size()).isEqualTo(this.BYTES.length);
}
}
@Test
void readPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(8);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(this.BYTES);
}
}
@Test
void readWhenLessBytesThanRemainingInBufferPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(9);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(8);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6, 7, 0);
}
}
@Test
void readWhenLessRemainingInBufferThanLengthPutsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(7);
int result = dataBlock.read(dst, 0);
assertThat(result).isEqualTo(7);
assertThat(dst.array()).containsExactly(0, 1, 2, 3, 4, 5, 6);
}
}
@Test
void readWhenHasPosOffsetReadsBytes() throws Exception {
ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES);
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
try (ByteArrayDataBlock dataBlock = new ByteArrayDataBlock(this.BYTES)) {
ByteBuffer dst = ByteBuffer.allocate(3);
int result = dataBlock.read(dst, 4);
assertThat(result).isEqualTo(3);
assertThat(dst.array()).containsExactly(4, 5, 6);
}
}
}