Bug 860815 - Agent updating resources from null to empty string version
Agent updating resources from null to empty string version
Status: ON_QA
Product: RHQ Project
Classification: Other
Component: Agent (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: John Mazzitelli
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2012-09-26 15:07 EDT by Elias Ross
Modified: 2013-07-01 12:11 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Elias Ross 2012-09-26 15:07:31 EDT
Description of problem:

If there is no component version, in other words an empty string, this is stored as ''. Oracle translates this value into null when read.

Then the RHQ agent thinks the version was changed for this resource.

2012-09-26 18:57:07,396 INFO  [InventoryManager.discovery-1] (rhq.core.pc.inventory.InventoryManager)- Version of [Resource[id=59062, type=Script, key=twiddle.sh, name=twiddle.sh, parent=AS default8180]] changed from [null] to []

The change is fairly straightforward

diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq
index b3f7fa9..8745971 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -2683,7 +2683,7 @@ private InventoryContext getInventoryContext(Resource resource) {
     private void updateResourceVersion(Resource resource, String version) {
         String existingVersion = resource.getVersion();
-        boolean versionChanged = (existingVersion != null) ? !existingVersion.equals(version) : version != null;
+        boolean versionChanged = (existingVersion != null) ? !existingVersion.equals(version) : version != null && !version.isEmpty();
         if (versionChanged) {
             if (log.isDebugEnabled()) {
                 log.debug("Discovery reported that version of [" + resource + "] changed from [" + existingVersion
Comment 1 Elias Ross 2012-09-26 15:21:19 EDT
Alternatively, the server could convert null strings into empty strings when loading from Oracle. I have done this before using Hibernate/JPA by annotating a @PostLoad method.
Comment 2 Heiko W. Rupp 2013-07-01 08:05:28 EDT
Mazz I think this makes sense - those change messages are annoying. What do you think?
Comment 3 John Mazzitelli 2013-07-01 08:49:46 EDT
i'll take a look. it seems to make sense to change this.
Comment 4 John Mazzitelli 2013-07-01 12:11:05 EDT
I made that change to master branch. git commit 6ee04e0

Note You need to log in before you can comment on or make changes to this bug.