From 5777103a2b721e6d6cb28ab8139228aef524ff78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= <8082209@qq.com> Date: Sat, 1 Dec 2018 00:09:39 +0800 Subject: [PATCH] Print exception stack into console or log files because of I found some NPE message in the log files. But I don't known where are they from without exception stack. (#1986) --- .../cache/NetworkAddressInventoryCacheEsDAO.java | 10 +++++----- .../cache/ServiceInstanceInventoryCacheDAO.java | 8 ++++---- .../cache/ServiceInventoryCacheEsDAO.java | 12 ++++++------ .../elasticsearch/lock/RegisterLockDAOImpl.java | 2 +- .../jdbc/h2/dao/H2ServiceInventoryCacheDAO.java | 14 +++++--------- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java index ebec15fa1..3057dcf92 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.register.*; +import org.apache.skywalking.oap.server.core.register.NetworkAddressInventory; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; @@ -52,8 +52,8 @@ public class NetworkAddressInventoryCacheEsDAO extends EsDAO implements INetwork } else { return Const.NONE; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return Const.NONE; } } @@ -71,8 +71,8 @@ public class NetworkAddressInventoryCacheEsDAO extends EsDAO implements INetwork } else { return null; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return null; } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java index 3abc5fbe8..fa1ae8782 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInstanceInventoryCacheDAO.java @@ -56,8 +56,8 @@ public class ServiceInstanceInventoryCacheDAO extends EsDAO implements IServiceI } else { return null; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return null; } } @@ -80,8 +80,8 @@ public class ServiceInstanceInventoryCacheDAO extends EsDAO implements IServiceI } else { return Const.NONE; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return Const.NONE; } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java index e7e1ada27..b34ea8bca 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/ServiceInventoryCacheEsDAO.java @@ -63,8 +63,8 @@ public class ServiceInventoryCacheEsDAO extends EsDAO implements IServiceInvento } else { return Const.NONE; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return Const.NONE; } } @@ -82,8 +82,8 @@ public class ServiceInventoryCacheEsDAO extends EsDAO implements IServiceInvento } else { return null; } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); return null; } } @@ -106,8 +106,8 @@ public class ServiceInventoryCacheEsDAO extends EsDAO implements IServiceInvento for (SearchHit searchHit : response.getHits().getHits()) { serviceInventories.add(this.builder.map2Data(searchHit.getSourceAsMap())); } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); } return serviceInventories; diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockDAOImpl.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockDAOImpl.java index cf59d0010..d76c650b0 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockDAOImpl.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/lock/RegisterLockDAOImpl.java @@ -89,7 +89,7 @@ public class RegisterLockDAOImpl extends EsDAO implements IRegisterLockDAO { getClient().forceUpdate(RegisterLockIndex.NAME, id, source); } catch (Throwable t) { - logger.error("Release lock failure."); + logger.error("Release lock failure.", t); } } } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ServiceInventoryCacheDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ServiceInventoryCacheDAO.java index 20da50056..0334ed1ed 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ServiceInventoryCacheDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ServiceInventoryCacheDAO.java @@ -19,17 +19,13 @@ package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao; import java.io.IOException; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; +import java.sql.*; +import java.util.*; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; import org.apache.skywalking.oap.server.library.util.BooleanUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.slf4j.*; /** * @author wusheng @@ -82,8 +78,8 @@ public class H2ServiceInventoryCacheDAO extends H2SQLExecutor implements IServic } catch (SQLException e) { throw new IOException(e); } - } catch (Throwable e) { - logger.error(e.getMessage()); + } catch (Throwable t) { + logger.error(t.getMessage(), t); } return serviceInventories; }