Azure / Azure/azure-functions-java-worker
Java worker doesn't respect module info defined on cx code
- Dominant language
- Java
- Stars
- 103
- Forks
- 74
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 2
Description
#### 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.

#### Known workarounds
Provide a description of any known workarounds.
#### Related information
Provide any related information
* Programming language used
* Links to source
* Bindings used
Contributor guide
Assessment
This issue has not been assessed yet.