Hello,

I found another issue with the custom data values: It's a known and fixed bug 
(889633)
that the indexing job will crash when initially *not* setting the 
lastModifiedBy column.
This column can still get null whenever a creator or modifier is deleted since 
there is
a ON DELETE SET NULL on these columns. We therefore have to allow null there, 
please see
and apply my attached patch.

This can also be problematic when there is values that were created before 
installing
the fix for 889633. These will have null as lastModifiedBy as long as they have 
never
been edited. Even after installing that fix, the old values will make the 
indexer crash.
The attached patch will also fix such cases.

Otherwise what we see is the same exception as with the above bug and no custom 
data
values are being indexed:

INFO   | jvm 1    | 2014/01/16 08:47:51 | --- Cause: 
java.lang.RuntimeException: Error setting
property 'setLastModifiedBy' of 
'com.redhat.satellite.search.db.models.ServerCustomInfo@75807580'.
Cause: java.lang.IllegalArgumentException]
INFO   | jvm 1    | 2014/01/16 08:47:51 |       at
com.redhat.satellite.search.scheduler.tasks.GenericIndexTask.execute(GenericIndexTask.java:91)

Regards,
Johannes

-- 
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
>From 910d1db851a485ec5657777f7e59f6b1d0d89c29 Mon Sep 17 00:00:00 2001
From: Johannes Renner <jren...@suse.de>
Date: Fri, 17 Jan 2014 12:01:45 +0100
Subject: [PATCH] Allow null as createdBy and lastModifiedBy

These can get null when a creator or modifier is being deleted
(ON DELETE SET NULL).
---
 .../redhat/satellite/search/db/models/ServerCustomInfo.java  | 12 ++++++------
 .../search/scheduler/tasks/IndexServerCustomInfoTask.java    |  8 ++++++--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/search-server/spacewalk-search/src/java/com/redhat/satellite/search/db/models/ServerCustomInfo.java b/search-server/spacewalk-search/src/java/com/redhat/satellite/search/db/models/ServerCustomInfo.java
index 3b0b53f..084898f 100644
--- a/search-server/spacewalk-search/src/java/com/redhat/satellite/search/db/models/ServerCustomInfo.java
+++ b/search-server/spacewalk-search/src/java/com/redhat/satellite/search/db/models/ServerCustomInfo.java
@@ -24,8 +24,8 @@ public class ServerCustomInfo extends GenericRecord {
     private long serverId;
     private String label;
     private String value;
-    private long createdBy;
-    private long lastModifiedBy;
+    private Long createdBy;
+    private Long lastModifiedBy;
     private String created;
     private String modified;
 
@@ -121,25 +121,25 @@ public class ServerCustomInfo extends GenericRecord {
     /**
      * @return the createdBy
      */
-    public long getCreatedBy() {
+    public Long getCreatedBy() {
         return createdBy;
     }
     /**
      * @param createdByIn the createdBy to set
      */
-    public void setCreatedBy(long createdByIn) {
+    public void setCreatedBy(Long createdByIn) {
         this.createdBy = createdByIn;
     }
     /**
      * @return the lastModifiedBy
      */
-    public long getLastModifiedBy() {
+    public Long getLastModifiedBy() {
         return lastModifiedBy;
     }
     /**
      * @param lastModifiedByIn the lastModifiedBy to set
      */
-    public void setLastModifiedBy(long lastModifiedByIn) {
+    public void setLastModifiedBy(Long lastModifiedByIn) {
         this.lastModifiedBy = lastModifiedByIn;
     }
 
diff --git a/search-server/spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexServerCustomInfoTask.java b/search-server/spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexServerCustomInfoTask.java
index 412b598..57d109a 100644
--- a/search-server/spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexServerCustomInfoTask.java
+++ b/search-server/spacewalk-search/src/java/com/redhat/satellite/search/scheduler/tasks/IndexServerCustomInfoTask.java
@@ -97,8 +97,12 @@ public class IndexServerCustomInfoTask extends GenericIndexTask {
         attrs.put("serverId", new Long(scInfo.getServerId()).toString());
         attrs.put("value", scInfo.getValue());
         attrs.put("label", scInfo.getLabel());
-        attrs.put("createdBy", new Long(scInfo.getCreatedBy()).toString());
-        attrs.put("lastModifiedBy", new Long(scInfo.getLastModifiedBy()).toString());
+        if (scInfo.getCreatedBy() != null) {
+            attrs.put("createdBy", scInfo.getCreatedBy().toString());
+        }
+        if (scInfo.getLastModifiedBy() != null) {
+            attrs.put("lastModifiedBy", scInfo.getLastModifiedBy().toString());
+        }
         attrs.put("created", scInfo.getCreated());
         attrs.put("modified", scInfo.getModified());
         return attrs;
-- 
1.8.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to