Azure / Azure/azure-functions-java-worker

Inconsistent behavior between OutputBinding<String> and OutputBinding<List<String>>

Đang mở
#343 1 bình luận 0 reaction 1 người được giao Được @shreyas-gopalakrishna nhận Xem trên GitHub
area:java-functions needs-investigation 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ả

The following code results in 2 rows in the cosmos DB

```Java
@FunctionName("CosmosDBTriggerJava1")
public void run(
@CosmosDBTrigger(
name = "items",
databaseName = "db1",
collectionName = "col3",
leaseCollectionName="leases",
connectionStringSetting = "juzhucos_DOCUMENTDB",
createLeaseCollectionIfNotExists = true
)
Object[] items,
@CosmosDBOutput(name = "database",
databaseName = "db1",
collectionName = "col2",
connectionStringSetting = "juzhucos_DOCUMENTDB")
OutputBinding outputItem, //this line caused error. It works with OutputBinding> and OutputBinding
final ExecutionContext context
) {
outputItem.setValue("[{\"name\":\"value 0\"},{\"name\":\"value 1\"}]");
}

```

While the following code results in error

```Java
@FunctionName("CosmosDBTriggerJava")
public void run(
@CosmosDBTrigger(
name = "items",
databaseName = "db1",
collectionName = "col1",
leaseCollectionName="leases",
connectionStringSetting = "juzhucos_DOCUMENTDB",
createLeaseCollectionIfNotExists = true
)
Object[] input,
@CosmosDBOutput(name = "database",
databaseName = "db1",
collectionName = "col2",
connectionStringSetting = "juzhucos_DOCUMENTDB")
OutputBinding> outputItem,
final ExecutionContext context
) {
List items = new ArrayList();

for (int i = 0; i < 2; i ++) {
items.add("{\"name\":\"value 0\"}");
}

outputItem.setValue(items);
}

```

```
[1/19/2020 8:47:13 AM] Executed 'Functions.CosmosDBTriggerJava' (Failed, Id=8e0edee5-49f5-4afc-82ff-fde57a43b67b)
[1/19/2020 8:47:13 AM] System.Private.CoreLib: Exception while executing function: Functions.CosmosDBTriggerJava. Microsoft.Azure.DocumentDB.Core: Value cannot be null.
[1/19/2020 8:47:13 AM] Parameter name: document.
```

This is because the first one is serialized to an array of 2 JSON objects, when doing RPC from the Java worker to the function host.
```Java
[{"name":"value 0"},{"name":"value 1"}]
```
While the later one is serialized to an array of 2 strings
```Java
["{\"name\":\"value 0\"}","{\"name\":\"value 1\"}"]
```

Can we make the later one support adding JSON string objects to the list, since the first one supports that.

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.