Skip to content

Commit 7a719d2

Browse files
committed
commit 9
1 parent f850dce commit 7a719d2

File tree

1 file changed

+10
-2
lines changed
  • Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests

1 file changed

+10
-2
lines changed

Libraries/test/Amazon.Lambda.RuntimeSupport.Tests/Amazon.Lambda.RuntimeSupport.UnitTests/HandlerTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ private async Task<ExecutionInfo> ExecHandlerAsync(string handler, string dataIn
388388
var userCodeLoader = new UserCodeLoader(new SystemEnvironmentVariables(), handler, _internalLogger);
389389
var handlerWrapper = HandlerWrapper.GetHandlerWrapper(userCodeLoader.Invoke);
390390
var initializer = new UserCodeInitializer(userCodeLoader, _internalLogger);
391-
var bootstrap = new LambdaBootstrap(handlerWrapper.Handler, initializer.InitializeAsync, null, _environmentVariables)
391+
// Pass null initializer to bootstrap so RunAsync won't re-invoke Init(),
392+
// which would re-register AssemblyLoad event handlers and re-construct the invoke delegate.
393+
var bootstrap = new LambdaBootstrap(handlerWrapper.Handler, null, null, _environmentVariables)
392394
{
393395
Client = testRuntimeApiClient
394396
};
@@ -403,7 +405,13 @@ private async Task<ExecutionInfo> ExecHandlerAsync(string handler, string dataIn
403405
Assert.DoesNotContain($"^^[{assertLoggedByInitialize}]^^", actionWriter.ToString());
404406
}
405407

406-
await bootstrap.InitializeAsync();
408+
await initializer.InitializeAsync();
409+
410+
// Re-set logging actions after initialization in case Init's AssemblyLoad event
411+
// handler overwrote them when loading Amazon.Lambda.Core as a handler dependency.
412+
UserCodeLoader.SetCustomerLoggerLogAction(assembly, actionWriter.ToLoggingAction(), _internalLogger);
413+
UserCodeLoader.SetCustomerLoggerLogAction(assembly, actionWriter.ToLoggingWithLevelAction(), _internalLogger);
414+
UserCodeLoader.SetCustomerLoggerLogAction(assembly, actionWriter.ToLoggingWithLevelAndExceptionAction(), _internalLogger);
407415

408416
if (assertLoggedByInitialize != null)
409417
{

0 commit comments

Comments
 (0)