You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by do...@apache.org on 2022/09/01 06:09:11 UTC
[inlong] branch master updated: [INLONG-5759][Manager] Fix JSON parse error for the subtype not found (#5760)
This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 3c32d5aa9 [INLONG-5759][Manager] Fix JSON parse error for the subtype not found (#5760)
3c32d5aa9 is described below
commit 3c32d5aa9b8aa5f3fb13eabaadf2a40cc3635c46
Author: healchow <he...@gmail.com>
AuthorDate: Thu Sep 1 14:09:05 2022 +0800
[INLONG-5759][Manager] Fix JSON parse error for the subtype not found (#5760)
---
.../manager/service/ApplicationInitRunner.java | 41 ----------------
.../manager/web/config/InlongGlobalConfig.java | 55 ++++++++++++++++++++++
2 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/ApplicationInitRunner.java b/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/ApplicationInitRunner.java
deleted file mode 100644
index 0735b53dd..000000000
--- a/inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/ApplicationInitRunner.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.inlong.manager.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.inlong.manager.common.util.JsonUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-
-/**
- * Init global params by Custom Command Line Runner
- */
-@Component
-public class ApplicationInitRunner implements CommandLineRunner {
-
- @Autowired
- private ObjectMapper objectMapper;
-
- @Override
- public void run(String[] args) {
- JsonUtils.initJsonTypeDefine(this.objectMapper);
- }
-
-}
-
diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/InlongGlobalConfig.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/InlongGlobalConfig.java
new file mode 100644
index 000000000..46e8a16c1
--- /dev/null
+++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/config/InlongGlobalConfig.java
@@ -0,0 +1,55 @@
+/*
+ * 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.inlong.manager.web.config;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
+import org.apache.inlong.manager.common.util.JsonUtils;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+/**
+ * Global config.
+ */
+@Configuration
+public class InlongGlobalConfig {
+
+ /**
+ * Create a global ObjectMapper, and register JSON subtype
+ */
+ @Bean
+ @Primary
+ public ObjectMapper objectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper()
+ .registerModule(new ParameterNamesModule())
+ .registerModule(new Jdk8Module())
+ .registerModule(new JavaTimeModule());
+ objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+ // register all JSON subtype
+ JsonUtils.initJsonTypeDefine(objectMapper);
+ return objectMapper;
+ }
+
+}