Bug 860815 - Agent updating resources from null to empty string version
Summary: Agent updating resources from null to empty string version
Keywords:
Status: ON_QA
Alias: None
Product: RHQ Project
Classification: Other
Component: Agent
Version: 4.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-09-26 19:07 UTC by Elias Ross
Modified: 2022-03-31 04:28 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

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


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