Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/bugfix-AWSSDKforJavav2-75d93e4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "AWS SDK for Java v2",
"description": "Include the sdk-core mime.types resource in the native-image resource configuration so default MIME type detection works in GraalVM native images. Fixes [#7063](https://github.com/aws/aws-sdk-java-v2/issues/7063)",
"contributor": "sjh9714"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"includes": [
{
"pattern": "software/amazon/awssdk/services/\\w+/execution.interceptors"
},
{
"pattern": "\\Qsoftware/amazon/awssdk/core/util/mime.types\\E"
}]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.utils.IoUtils;

public class MimetypeTest {

private static final String MIME_TYPES_RESOURCE = "software/amazon/awssdk/core/util/mime.types";
private static final String NATIVE_IMAGE_RESOURCE_CONFIG =
"META-INF/native-image/software.amazon.awssdk/sdk-core/resource-config.json";

private static Mimetype mimetype;

@BeforeAll
Expand Down Expand Up @@ -58,4 +65,14 @@ public void pathWithoutFileName_defaulttoBeStream() throws Exception {
when(mockPath.getFileName()).thenReturn(null);
assertThat(mimetype.getMimetype(mockPath)).isEqualTo(Mimetype.MIMETYPE_OCTET_STREAM);
}

@Test
public void nativeImageResourceConfig_includesMimeTypes() throws IOException {
try (InputStream resourceConfig = Mimetype.class.getClassLoader().getResourceAsStream(NATIVE_IMAGE_RESOURCE_CONFIG)) {
assertThat(resourceConfig).isNotNull();

String resourceConfigContents = IoUtils.toUtf8String(resourceConfig);
assertThat(resourceConfigContents).contains(MIME_TYPES_RESOURCE);
}
}
}
Loading