ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-16973 Print out configType has malformed json text as part of the ambari server startup error handling (dili)
Date Fri, 03 Jun 2016 16:12:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 881edf302 -> c126aa318


AMBARI-16973 Print out configType has malformed json text as part of the ambari server startup
error handling (dili)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c126aa31
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c126aa31
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c126aa31

Branch: refs/heads/trunk
Commit: c126aa318234ca511ea23b6ddb31da41104e5bb5
Parents: 881edf3
Author: Di Li <dili@apache.org>
Authored: Fri Jun 3 12:11:59 2016 -0400
Committer: Di Li <dili@apache.org>
Committed: Fri Jun 3 12:11:59 2016 -0400

----------------------------------------------------------------------
 .../apache/ambari/server/orm/dao/ServiceConfigDAO.java   |  2 --
 .../java/org/apache/ambari/server/state/ConfigImpl.java  | 11 ++++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c126aa31/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
index 128fef0..3a73b2d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
@@ -18,7 +18,6 @@
 
 package org.apache.ambari.server.orm.dao;
 
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -32,7 +31,6 @@ import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Root;
 
 import org.apache.ambari.server.orm.RequiresSession;
-import org.apache.ambari.server.orm.cache.ConfigGroupHostMapping;
 import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.state.StackId;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c126aa31/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
index dbdd5a2..726e49f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
@@ -38,6 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.assistedinject.Assisted;
@@ -222,7 +223,15 @@ public class ConfigImpl implements Config {
       readWriteLock.writeLock().lock();
       try {
         if (properties == null) {
-          properties = gson.<Map<String, String>>fromJson(entity.getData(), Map.class);
+          try {
+            properties = gson.<Map<String, String>>fromJson(entity.getData(),
Map.class);
+          } catch (JsonSyntaxException e){
+            String msg = String.format(
+                "Malformed JSON stored in the database for %s configuration record with config_id
%d",
+                entity.getType(), entity.getConfigId());
+            LOG.error(msg);
+            throw new JsonSyntaxException(msg, e);
+          }
         }
       } finally {
         readWriteLock.writeLock().unlock();


Mime
View raw message