Azure / Azure/azure-functions-java-worker

Optional route parameter without type is not correctly parsed

オープン
#293 コメント 1 件 リアクション 0 件 担当者 1 名 @kamperiadis が担当を希望しています GitHub で見る
area:java-functions New Feature reviewed
主要言語
Java
スター
103
フォーク
74
平均マージ
4日 8時間
マージ済み PR(30日)
2

説明

#### Investigative information

- Timestamp: 2019-05-26 05:43:59.033 UTC
- Invocation ID: 90a11823-2911-41aa-969c-f228f75865a0
- Region: France Central

#### Repro steps

*This behavior is only reproductible when the function app is executed on Azure, and it does not appear when running locally*

Run an Http triggered Function App which contains an optional route parameter without type specified with it, as for example : https://example.azurewebsites.net/api/functionname/{parameter?}.
By parameter with type I mean a parameter like {parameter:type} which is not used here.

#### Expected behavior

The expected behavior would be to get the actual value provided for the parameter.

#### Actual behavior

The optional parameter without type is not parsed correctly:
- if the function is executed without a value specified for this parameter, it ends with a NullPointerException :

`Result: Failure
Exception: NullPointerException:
Stack: java.lang.NullPointerException
at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:54)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:62)
at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:42)
at com.microsoft.azure.functions.worker.broker.JavaMethodExecutor.execute(JavaMethodExecutor.java:52)
at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:51)
at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:33)
at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:45)
at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
`

- if a value is given to this parameter in the triggering URL, the parameter is incorrectly parsed and the returned value is the name of the parameter until the question mark.
E.g. with the example URL I gave before, if we call :
-- https://example.azurewebsites.net/api/functionname : the NPE is thrown ;
-- https://example.azurewebsites.net/api/functionname/avalue : instead of the value, I got "{parameter".

#### Known workarounds

Optional parameters with a type (e.g. "{parameter:alpha?}") cannot be obtained with the annotation `@BindingName` as it also returns a NPE, but it is nevertheless possible to retrieve their values by parsing the URL with `request.getUri().getPath()`.
Non-optional parameters, that is, without a question mark, work fine.

#### Related information

* Programming language used = Java 8
* Bindings used = http binding

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。