Skip to content

update to catch Throwable for execute method #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public async void HttpTriggerJavaStatic()
public async Task HttpTrigger_BindingName()
{
Assert.True(await Utilities.InvokeHttpTrigger("BindingName", "/testMessage", HttpStatusCode.OK, "testMessage"));
}

[Fact]
public async Task HttpTrigger_StaticBlockFailure()
{
Assert.True(await Utilities.InvokeHttpTrigger("StaticBlockFailure", "", HttpStatusCode.InternalServerError, ""));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.microsoft.azure.functions.endtoend;

import com.microsoft.azure.functions.*;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;

import java.util.Optional;

public class StaticBlockFailure {
static {
Optional.empty().orElseThrow(() -> new RuntimeException("exception raised in static block"));
}
@FunctionName("StaticBlockFailure")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request of function StaticBlockFailure.");
return request.createResponseBuilder(HttpStatus.OK).body("Hello, e2e test").build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public void handle() {
if (statusMessage != null) {
this.getLogger().info(statusMessage);
}
} catch (Exception ex) {
} catch (Throwable throwable) {
status = StatusResult.Status.Failure;
statusMessage = ExceptionUtils.getRootCauseMessage(ex);
rpcException = RpcException.newBuilder().setMessage(statusMessage).setStackTrace(ExceptionUtils.getStackTrace(ex)).build();
statusMessage = ExceptionUtils.getRootCauseMessage(throwable);
rpcException = RpcException.newBuilder().setMessage(statusMessage).setStackTrace(ExceptionUtils.getStackTrace(throwable)).build();
}
if (this.responseStatusMarshaller != null) {
StatusResult.Builder result = StatusResult.newBuilder().setStatus(status).setResult(statusMessage);
Expand Down