From: <pn...@hy...> - 2010-04-02 04:54:46
|
Author: pnguyen Date: 2010-04-01 21:54:36 -0700 (Thu, 01 Apr 2010) New Revision: 14466 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14466 Modified: trunk/src/org/hyperic/hq/appdef/server/session/ConfigManagerEJBImpl.java trunk/src/org/hyperic/hq/appdef/server/session/ConfigResponseDAO.java trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java Log: [HHQ-3706] Use get() instead of findById() to minimize ObjectNotFoundException Modified: trunk/src/org/hyperic/hq/appdef/server/session/ConfigManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ConfigManagerEJBImpl.java 2010-04-02 00:07:28 UTC (rev 14465) +++ trunk/src/org/hyperic/hq/appdef/server/session/ConfigManagerEJBImpl.java 2010-04-02 04:54:36 UTC (rev 14466) @@ -124,7 +124,7 @@ private ConfigResponseDB getConfigResponse(ConfigResponseDAO dao, AppdefEntityID id) { - ConfigResponseDB config; + ConfigResponseDB config = null; switch(id.getType()){ case AppdefEntityConstants.APPDEF_TYPE_PLATFORM: @@ -138,11 +138,18 @@ break; case AppdefEntityConstants.APPDEF_TYPE_APPLICATION: default: - throw new IllegalArgumentException("The passed entity type " + - "does not support config " + + throw new IllegalArgumentException("The resource[ " + id + + "] does not support config " + "responses"); } + // Platforms, servers, and services should have a config response record. + // A null config response could indicate that the resource has been deleted. + if (config == null) { + throw new IllegalArgumentException( + "No config response found for resource[" + id + "]"); + } + return config; } Modified: trunk/src/org/hyperic/hq/appdef/server/session/ConfigResponseDAO.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ConfigResponseDAO.java 2010-04-02 00:07:28 UTC (rev 14465) +++ trunk/src/org/hyperic/hq/appdef/server/session/ConfigResponseDAO.java 2010-04-02 04:54:36 UTC (rev 14466) @@ -80,20 +80,20 @@ ConfigResponseDB findByPlatformId(Integer id) { PlatformDAO dao = new PlatformDAO(getFactory()); - Platform plat = dao.findById(id); - return plat.getConfigResponse(); + Platform plat = dao.get(id); + return (plat == null ? null : plat.getConfigResponse()); } public ConfigResponseDB findByServerId(Integer id) { ServerDAO dao = new ServerDAO(getFactory()); - Server server = dao.findById(id); - return server.getConfigResponse(); + Server server = dao.get(id); + return (server == null ? null : server.getConfigResponse()); } public ConfigResponseDB findByServiceId(Integer id) { ServiceDAO dao = new ServiceDAO(getFactory()); - Service service = dao.findById(id); - return service.getConfigResponse(); + Service service = dao.get(id); + return (service == null ? null : service.getConfigResponse()); } /** Modified: trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java 2010-04-02 00:07:28 UTC (rev 14465) +++ trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java 2010-04-02 04:54:36 UTC (rev 14466) @@ -1581,7 +1581,9 @@ getMergedConfigResponse(subject, ProductPlugin.TYPE_MEASUREMENT, id, true); - } catch (Exception e) { + } catch (Throwable t) { + log.debug("Unable to get config response: " + t.getMessage(), t); + // If anything goes wrong getting the config, just move // along. The plugins will be removed on the next agent // restart. |