Azure / Azure/azure-functions-java-worker

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

Đang mở
#580 1 bình luận 0 reaction 1 người được giao Được @kaibocai nhận Xem trên GitHub
area:java-functions Needs: Triage (Functions) New Feature reviewed
Ngôn ngữ chính
Java
Star
103
Fork
74
Merge trung bình
4 ngày 8 giờ
Pull request đã merge (30 ngày)
2

Mô tả

#### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.