Skip to content
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

fix: AzureFunction implements AutoCloseable #67

Merged
merged 1 commit into from Sep 14, 2020
Merged

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Sep 14, 2020

A Micronaut application with azure-function-http function generates a test such as:

package com.example;
import com.microsoft.azure.functions.HttpStatus;
import io.micronaut.azure.function.http.HttpRequestMessageBuilder;
import io.micronaut.http.HttpMethod;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class DemoFunctionTest {

    @Test
    public void testFunction() throws Exception {
        try (Function function = new Function()) {
            HttpRequestMessageBuilder.AzureHttpResponseMessage response =
                function.request(HttpMethod.GET, "/demo")
                        .invoke();

            assertEquals(HttpStatus.OK, response.getStatus());
        }
    }
}

Function is a class which extends from AzureHttpFunction. AzureHttpFunction extends from AzureFunction. Since none implement AutoCloseable, the try with resources block does not compile.

AzureFunction registers a shutdownHook. However, I think we should also implement both Closeable and ApplicationContextProvider for AzureFunction.

@sdelamo sdelamo added the type: improvement A minor improvement to an existing feature label Sep 14, 2020
@sdelamo sdelamo self-assigned this Sep 14, 2020
@sdelamo sdelamo merged commit e9c3a44 into 1.0.x Sep 14, 2020
@sdelamo sdelamo deleted the implement-closeable branch September 14, 2020 09:04
sdelamo added a commit that referenced this pull request Sep 14, 2020
* [azure] Update common files for branch 1.0.x (#58)

* ci: set github core branch to 2.0.x (#60)

* fix: AzureFunction implements AutoCloseable (#67)

* refactor: remove wildcards imports (#70)

* checkstyle: constructor wrong order (#69)

Co-authored-by: micronaut-build <65172877+micronaut-build@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants