Azure / Azure/azure-functions-java-worker

Java worker doesn't respect module info defined on cx code

Abierto
#580 1 comentario 0 reacciones 1 asignado Reclamado por @kaibocai Ver en GitHub
area:java-functions Needs: Triage (Functions) New Feature reviewed
Lenguaje dominante
Java
Estrellas
103
Forks
74
Merge medio
4 d 8 h
PR fusionados (30 d)
2

Descripción

#### Investigative information

Please provide the following:

- Timestamp: 06/06/2022
- Function App name: N/A
- Function name(s) (as appropriate): N/A
- Invocation ID: N/A
- Region: Local

#### Repro steps

Provide the steps required to reproduce the problem:
**Running on java11**
1. code snippet:
Function.java
```
import com.google.gson.Gson;
import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.HttpResponseMessage;
import com.microsoft.azure.functions.HttpStatus;
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;

/**
* Azure Functions with HTTP Trigger.
*/
public class Function {
/**
* This function listens at endpoint "/api/HttpExample". Two ways to invoke it using "curl" command in bash:
* 1. curl -d "HTTP Body" {your host}/api/HttpExample
* 2. curl "{your host}/api/HttpExample?name=HTTP%20Query"
*/
@FunctionName("HttpExample")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage> request,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request.");

// Parse query parameter
final String query = request.getQueryParameters().get("name");
final String name = request.getBody().orElse(query);

Gson gson = new Gson();
// String hello_gson = gson.fromJson("hello gson: ", String.class);
Optional module = ModuleLayer.boot().findModule("com.google.gson");
Optional module1 = ModuleLayer.boot().findModule("azure.functions.java.library");
return request.createResponseBuilder(HttpStatus.OK).body(module.isPresent() +": "+ module1.isPresent()).build();
}
}
```
module-info.java
```
module com.kc {
requires java.logging;
requires com.google.gson;
requires azure.functions.java.library;
requires azure.functions.java.core.library;
}
```

#### Expected behavior

Provide a description of the expected behavior.

Since the module is required by function app, expect to see "true: true" as response for the http request.

#### Actual behavior

Provide a description of the actual behavior observed.
![image](https://user-images.githubusercontent.com/89094811/172223782-0124c524-0182-49dd-8c4d-692b4b6690d4.png)

#### Known workarounds

Provide a description of any known workarounds.

#### Related information

Provide any related information

* Programming language used
* Links to source
* Bindings used

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.