Bug 1110278

Summary: RHQ_EVENT tables detail field limit of 4000 character will break when using international character sets
Product: [Other] RHQ Project Reporter: Tom Fonteyne <tfonteyn>
Component: DatabaseAssignee: Jay Shaughnessy <jshaughn>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 4.12CC: hrupp, jshaughn
Target Milestone: GA   
Target Release: RHQ 4.12   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1110277 Environment:
Last Closed: 2014-12-15 11:35:48 UTC 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:
Bug Depends On: 1110277    
Bug Blocks:    

Description Tom Fonteyne 2014-06-17 11:12:14 UTC
+++ This bug was initially created as a clone of Bug #1110277 +++

JON 3.1.2 and JON 3.2.0

org/​ rhq/​ core/​ domain/​ event/​ Event.java

126     @Column(name = "DETAIL", length = 4000, nullable = false)
127     private String detail;

so the detail string is trimming the text to 4000 UTF8 characters.


org/​ rhq/​ enterprise/​ server/​ event/​ EventManagerBean.java 

is responsible to insert the event into the database:

112     public void addEventData(Map<EventSource, Set<Event>> events) {
...
167             // Then insert the "values" (i.e. the Events).
168             ps = conn.prepareStatement(statementSql);
169             try {
170                 for (EventSource eventSource : events.keySet()) {
171                     Set<Event> eventData = events.get(eventSource);
172                     for (Event event : eventData) {
....
181                         ps.setString(paramIndex++, event.getDetail());

However, then the database (oracle in our case) has not been setup to use UTF-8, but only a standard 8-bit character set then trying to insert a "detail" which has international (e.g. 16 bit) characters in it will break the 4000 limit with:

ORA-01461: can bind a LONG value only for insert into a LONG column

because the number of bytes form the "detail" will be bigger then 4000.

Solution:

- make the database being UTF-8 a requirement (JON installer to check)

or modify the above code:

  byte[] detailBytes = event.getDetail().getBytes();
  ps.setBytes(paramIndex++,Arrays.copyOf(detailBytes, 4000));

Comment 1 Jay Shaughnessy 2014-07-10 13:23:19 UTC
MASTER commit 1d836a790f8e8d2da79a31e8c796324e85ae7851

Setting to VERIFIED since the clone was verified with a master build.

Comment 2 Heiko W. Rupp 2014-12-15 11:35:48 UTC
Bulk close of items fixed in RHQ 4.12

If you think this is not solved, then please open a *new* BZ and link to this one.