Skip to content

Commit

Permalink
fix: make initializeClient a pure function (#498)
Browse files Browse the repository at this point in the history
* fix: make initializeClient a pure function

* fix: make initializeClient a pure function
  • Loading branch information
maxday committed Jul 29, 2024
1 parent 70467ba commit c5e2ee3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LambdaRuntimeApiClientImpl(String hostnameAndPort) {
Objects.requireNonNull(hostnameAndPort, "hostnameAndPort cannot be null");
this.baseUrl = "http://" + hostnameAndPort;
this.invocationEndpoint = this.baseUrl + "/2018-06-01/runtime/invocation/";
NativeClient.init();
NativeClient.init(hostnameAndPort);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* interactions with the Runtime API.
*/
class NativeClient {
static void init() {
static void init(String awsLambdaRuntimeApi) {
JniHelper.load();
initializeClient(USER_AGENT.getBytes());
initializeClient(USER_AGENT.getBytes(), awsLambdaRuntimeApi.getBytes());
}

static native void initializeClient(byte[] userAgent);
static native void initializeClient(byte[] userAgent, byte[] awsLambdaRuntimeApi);

static native InvocationRequest next();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ static std::string toNativeString(JNIEnv *env, jbyteArray jArray) {
return nativeString;
}

JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_initializeClient(JNIEnv *env, jobject thisObject, jbyteArray userAgent) {
JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_initializeClient(JNIEnv *env, jobject thisObject, jbyteArray userAgent, jbyteArray awsLambdaRuntimeApi) {
std::string user_agent = toNativeString(env, userAgent);
std::string endpoint(getenv("AWS_LAMBDA_RUNTIME_API"));
std::string endpoint = toNativeString(env, awsLambdaRuntimeApi);
CLIENT = new aws::lambda_runtime::runtime(endpoint, user_agent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
#endif

JNIEXPORT void JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_initializeClient
(JNIEnv *, jobject, jbyteArray);
(JNIEnv *, jobject, jbyteArray, jbyteArray);

JNIEXPORT jobject JNICALL Java_com_amazonaws_services_lambda_runtime_api_client_runtimeapi_NativeClient_next
(JNIEnv *, jobject);
Expand Down

0 comments on commit c5e2ee3

Please sign in to comment.