Bug 860815

Summary: Agent updating resources from null to empty string version
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: AgentAssignee: John Mazzitelli <mazz>
Status: ON_QA --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.2CC: hrupp, mazz
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Elias Ross 2012-09-26 19:07:31 UTC
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 19:21:19 UTC
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 12:05:28 UTC
Mazz I think this makes sense - those change messages are annoying. What do you think?

Comment 3 John Mazzitelli 2013-07-01 12:49:46 UTC
i'll take a look. it seems to make sense to change this.

Comment 4 John Mazzitelli 2013-07-01 16:11:05 UTC
I made that change to master branch. git commit 6ee04e0