Source:
<code>public List<Attribute> getRequiredAttributes(PerunSession sess, Resource resourceToGetServicesFrom, Host host) throws InternalErrorException { List<Attribute> attributesCache = null; if(!CacheManager.isCacheDisabled() && !perun.getCacheManager().wasCacheUpdatedInTransaction()) { List<Integer> attrIds = getRequiredAttributeIds(resourceToGetServicesFrom); List<Attribute> attrs = perun.getCacheManager().getAttributesByIds(attrIds, new Holder(host.getId(), Holder.HolderType.HOST)); attributesCache = this.setValuesOfAttributes(sess, attrs, host, null); } try { List<Attribute> attributesDB = jdbc.query("select " + getAttributeMappingSelectQuery("host") + " from attr_names " + "left join host_attr_values host on attr_names.id=host.attr_id and host_id=? " + "where namespace in (?,?,?) " + "and attr_names.id in (select distinct service_required_attrs.attr_id from service_required_attrs " + "join resource_services on service_required_attrs.service_id=resource_services.service_id and resource_services.resource_id=?)", new SingleBeanAttributeRowMapper<>(sess, this, host), host.getId(), AttributesManager.NS_HOST_ATTR_CORE, AttributesManager.NS_HOST_ATTR_DEF, AttributesManager.NS_HOST_ATTR_OPT, resourceToGetServicesFrom.getId()); <START> String message = "The attributes do not match, attributes from cache are: " + attributesCache + " while attributes from db are: " + attributesDB + " the attributes belong to " + host + " from service with resource: " + resourceToGetServicesFrom; <END> compareAttributesFromCacheAndDB(attributesCache, attributesDB, message); return attributesDB; } catch (EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException ex) { throw new InternalErrorException(ex); } }</code><technical_language>resource specify, services required attributes retrieved for host. need log that. complicate idea generic message in private method passed params, need number. check length create placeholders in message accordingly. I it, more interesting print stack trace, identify method failed this check. sure, if is other way, throwing catching exception private method get stack trace</technical_language>

Target:
public List<Attribute> getRequiredAttributes(PerunSession sess, Resource resourceToGetServicesFrom, Host host) throws InternalErrorException { List<Attribute> attributesCache = null; if(!CacheManager.isCacheDisabled() && !perun.getCacheManager().wasCacheUpdatedInTransaction()) { List<Integer> attrIds = getRequiredAttributeIds(resourceToGetServicesFrom); List<Attribute> attrs = perun.getCacheManager().getAttributesByIds(attrIds, new Holder(host.getId(), Holder.HolderType.HOST)); attributesCache = this.setValuesOfAttributes(sess, attrs, host, null); } try { List<Attribute> attributesDB = jdbc.query("select " + getAttributeMappingSelectQuery("host") + " from attr_names " + "left join host_attr_values host on attr_names.id=host.attr_id and host_id=? " + "where namespace in (?,?,?) " + "and attr_names.id in (select distinct service_required_attrs.attr_id from service_required_attrs " + "join resource_services on service_required_attrs.service_id=resource_services.service_id and resource_services.resource_id=?)", new SingleBeanAttributeRowMapper<>(sess, this, host), host.getId(), AttributesManager.NS_HOST_ATTR_CORE, AttributesManager.NS_HOST_ATTR_DEF, AttributesManager.NS_HOST_ATTR_OPT, resourceToGetServicesFrom.getId()); compareAttributesFromCacheAndDB(attributesCache, attributesDB, host, null); return attributesDB; } catch (EmptyResultDataAccessException ex) { return new ArrayList<>(); } catch (RuntimeException ex) { throw new InternalErrorException(ex); } }