Skip to content

apache5-client ships invalid GraalVM native-image metadata (import prefix + wrong SPI class name) #7125

Description

@luneo7

Describe the bug

The software.amazon.awssdk:apache5-client module ships broken GraalVM native-image configuration. The SPI service descriptor is correct, but the reflect-config.json (and related metadata) does not register the real provider class.

Introduced with Apache5 HTTP client / making Apache5 the default (2.46.x era). Invalid metadata still present in published jars (e.g. 2.46.17, 2.47.3) and on master before a fix.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

  • META-INF/native-image metadata for apache5-client registers the real SPI implementation class:
    • software.amazon.awssdk.http.apache5.Apache5SdkHttpService (no-arg constructor)
  • ServiceLoader.load(SdkHttpService.class) can instantiate that provider in a GraalVM/Mandrel native image
  • Apache5HttpClient works for normal sync calls in native (when the rest of the app’s native config is sound)

Current Behavior

Invalid metadata in the jar

Under published apache5-client (e.g. 2.47.3):

Path (wrong — copy-pasted from apache-client):

META-INF/native-image/software.amazon.awssdk/apache-client/

reflect-config.json (invalid class name):

{
  "name": "import software.amazon.awssdk.http.apache5.ApacheSdkHttpService",
  "methods": [{ "name": "<init>", "parameterTypes": [] }]
}

Problems:

  1. Literal "import " prefix in the class name
  2. Wrong simple name: ApacheSdkHttpService instead of Apache5SdkHttpService
  3. Real class on disk is software.amazon.awssdk.http.apache5.Apache5SdkHttpService

proxy-config.json (also broken / obsolete):

[
  [
    "org.apache.http.conn.HttpClientConnectionManager",
    "org.apache.http.pool.ConnPoolControl",
    "import software.amazon.awssdk.http.apache5.internal.conn.Wrapped"
  ],
  ...
]
  • Again uses the "import " prefix
  • Uses HttpClient 4 packages (org.apache.http.*) while Apache5 uses HC5 (org.apache.hc.client5.*)
  • Apache5 wraps connection managers with concrete subclasses, not Proxy.newProxyInstance; Wrapped is unused in Java code — this file looks like a bad copy from apache-client

Reproduction Steps

Inspect the published jar (no AWS account required)

# any 2.46+ / 2.47.x apache5-client
jar xf ~/.m2/repository/software/amazon/awssdk/apache5-client/2.47.3/apache5-client-2.47.3.jar \
  META-INF/native-image META-INF/services

cat META-INF/services/software.amazon.awssdk.http.SdkHttpService
# → software.amazon.awssdk.http.apache5.Apache5SdkHttpService  (correct)

cat META-INF/native-image/software.amazon.awssdk/apache-client/reflect-config.json
# → "import software.amazon.awssdk.http.apache5.ApacheSdkHttpService"  (incorrect)

Minimal native smoke (SPI + Apache5HttpClient)

import java.util.ServiceLoader;
import software.amazon.awssdk.http.SdkHttpService;
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
import software.amazon.awssdk.http.apache5.Apache5SdkHttpService;

public class Main {
    public static void main(String[] args) {
        for (SdkHttpService s : ServiceLoader.load(SdkHttpService.class)) {
            System.out.println(s.getClass().getName());
        }
        try (var client = Apache5HttpClient.builder().build()) {
            System.out.println(client.clientName());
        }
    }
}

Compile against apache5-client + its runtime deps, then:

native-image --no-fallback -cp ... -H:Name=smoke Main
./smoke

With broken metadata (stock jar, ServiceLoaderFeature relying on reflect-config / incomplete registration), ServiceLoader instantiation of Apache5SdkHttpService fails in native.
With fixed reflect-config registering the real FQCN, the same program succeeds (verified locally).

Possible Solution

  1. Move native-image resources to
    META-INF/native-image/software.amazon.awssdk/apache5-client/

  2. Fix reflect-config.json to register:

    {
      "name": "software.amazon.awssdk.http.apache5.Apache5SdkHttpService",
      "methods": [{ "name": "<init>", "parameterTypes": [] }]
    }
  3. Remove or rewrite proxy-config.json (prefer remove: no JDK proxies for Apache5 connection managers).

  4. Keep resource-config.json aligned with other HTTP clients.

  5. Add regression coverage (e.g. exercise Apache5HttpClient in test/sdk-native-image-test).

Additional Information/Context

No response

AWS Java SDK version used

2.46.17 / 2.47.3 (repro); 2.47.4-SNAPSHOT (local fix verification)

JDK version used

openjdk 25 2025-09-16 LTS OpenJDK Runtime Environment Temurin-25+36 (build 25+36-LTS) OpenJDK 64-Bit Server VM Temurin-25+36 (build 25+36-LTS, mixed mode, sharing)

Operating System and version

MacOS 26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p1This is a high priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions