You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ja...@apache.org on 2023/02/14 01:01:29 UTC
[linkis] branch dev-1.3.2 updated: Fix UnrecognizedPropertyException: Unrecognized field "timeOut (#4213)
This is an automated email from the ASF dual-hosted git repository.
jackxu2011 pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git
The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
new 0f7899b00 Fix UnrecognizedPropertyException: Unrecognized field "timeOut (#4213)
0f7899b00 is described below
commit 0f7899b0081142231ddb390914696158339fbd15
Author: Casion <ca...@gmail.com>
AuthorDate: Tue Feb 14 09:01:23 2023 +0800
Fix UnrecognizedPropertyException: Unrecognized field "timeOut (#4213)
* fix UnrecognizedPropertyException: Unrecognized field "timeOut
---
.../protocol/engine/EngineCreateRequest.java | 9 +++
.../protocol/engine/EngineCreateRequestTest.java | 66 ++++++++++++++++++++++
2 files changed, 75 insertions(+)
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequest.java b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequest.java
index 7d01c394e..cb8bc27e4 100644
--- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequest.java
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequest.java
@@ -21,12 +21,21 @@ import org.apache.linkis.protocol.message.RequestMethod;
import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
public class EngineCreateRequest implements EngineRequest, RequestMethod {
private Map<String, String> properties;
private Map<String, Object> labels;
+ /*
+ `timeOut` compatible with older versions
+ It is recommended to use `timeout`
+ */
+ @JsonProperty("timeOut")
+ @JsonAlias("timeout")
private long timeout;
private String user;
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/test/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequestTest.java b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/test/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequestTest.java
new file mode 100644
index 000000000..fd516c687
--- /dev/null
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/test/java/org/apache/linkis/manager/common/protocol/engine/EngineCreateRequestTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.manager.common.protocol.engine;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class EngineCreateRequestTest {
+
+ private final ObjectMapper objectMapper = new ObjectMapper();
+
+ @Test
+ void testTimeout() {
+ ObjectNode jNode = objectMapper.createObjectNode();
+ // "timeout", "properties", "createService", "user", "description", "labels", "ignoreTimeout"
+ jNode.put("timeout", 1000);
+ jNode.put("user", "hadoop");
+ jNode.put("description", "test for node");
+ jNode.put("ignoreTimeout", false);
+
+ try {
+ EngineCreateRequest engineCreateRequest =
+ objectMapper.treeToValue(jNode, EngineCreateRequest.class);
+ assertEquals(engineCreateRequest.getTimeout(), jNode.get("timeout").asLong());
+ } catch (JsonProcessingException e) {
+ fail("Should not have thrown any exception", e);
+ }
+ }
+
+ @Test
+ void testTimeOut() {
+ ObjectNode jNode = objectMapper.createObjectNode();
+ // "timeout", "properties", "createService", "user", "description", "labels", "ignoreTimeout"
+ jNode.put("timeOut", 1000);
+ jNode.put("user", "hadoop");
+ jNode.put("description", "test for node");
+ jNode.put("ignoreTimeout", false);
+
+ try {
+ EngineCreateRequest engineCreateRequest =
+ objectMapper.treeToValue(jNode, EngineCreateRequest.class);
+ assertEquals(engineCreateRequest.getTimeout(), jNode.get("timeOut").asLong());
+ } catch (JsonProcessingException e) {
+ fail("Should not have thrown any exception", e);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org