Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1100635

Summary: Removing column from data provider SQL query causes ArrayIndexOutOfBoundsException when duplicating workspace
Product: [Retired] JBoss BPMS Platform 6 Reporter: Jan Hrcek <jhrcek>
Component: BAMAssignee: Roger Martínez <romartin>
Status: CLOSED EOL QA Contact: Gui Jospin <gjospin>
Severity: medium Docs Contact:
Priority: high    
Version: unspecifiedCC: kverlaen
Target Milestone: ER5   
Target Release: 6.1.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 20:09:44 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:
Attachments:
Description Flags
Video showing steps to reproduce
none
server.log showing the exception
none
Kpi reconfigures itself instead of showing error
none
Testing H2 db, username=dbUser, password=dbPassword none

Description Jan Hrcek 2014-05-23 09:18:37 UTC
Created attachment 898604 [details]
Video showing steps to reproduce

Description of problem:
The title says it all. Observe steps to reproduce in video attached.

Version-Release number of selected component (if applicable):
BPMS 6.0.2 ER2

How reproducible:
Always

Steps to Reproduce:
1. Login with root and navigate to Showcase > Administration > Data Providers
2. Click 'Edit data provider' for 'jBPMS Task sumary' provider 
3. remove 'ts.taskid' from the select clause of SQL statement.
4. Click Attempt data load  and then Save
5. Click duplicate selected workspace.

Actual results:
The following exception appears in server log:
10:53:54,656 ERROR [org.jboss.dashboard.kpi.KPIImpl] (http-localhost/127.0.0.1:8080-3) Error deserializing data provider for KPI: 2275: java.lang.ArrayIndexOutOfBoundsException: Column out of bounds: -1(must be between 0 and 8)

Expected results:
No exceptions

Additional info:
From the exception message I found, that KPI with id 2275 is 'Task duration' which is using this property.

Comment 1 Jan Hrcek 2014-05-23 09:19:45 UTC
Created attachment 898605 [details]
server.log showing the exception

Comment 2 Roger Martínez 2014-11-26 18:04:40 UTC
Just testing it i have seend that it does not happens only when duplicating portals.

When removing a property from a SQL data provider, all the KPIs that use those data provider will fail with same exception. 

After removing "ts.taskid" property, you can navigate to "jbpm dashboard" portal and click on the tab "Tasks duration". It will fail as well.

It seems that the property is not removed in the datadisplayers related to the kpi's affected. I will continue trying to find the better solution.

Comment 3 Roger Martínez 2014-12-03 22:06:10 UTC
The problem was with KPI displayers that are already configured.

These displayers are configured based on some data provider properties, if you change the data provider definition and remove some property that it's used by any displayer, it fails when rendering.

The fix consists of:

- Before rendering a data displayer, it checks if the properties used in this displayer are still present in the data provider.

- If data displayer contains a property/ies not present in the data provider, it shows a message indicating that "The KPI must be reconfigured" and the chart/table is not displayed.

- Then you have to use the edit mode of the KPI panel in order to modify the displayer configuration and set it correctly.


The fix has been applied to:
- KPI portlet
  -  Check if all used properties by the displayer are present in current data provider.
  - If not, shown an error message in order to force user to reconfigure it, as the chart or table is not displayed

- Dashboard Filter Portlet
  - Check if all visible properties by the filter are present in current data provider.
  - Check if currently being filtered properties by the filter are present in current data provider

- HTML portlet
  - It already supports as well if the property does not exist (not present in data provider ) and shows a "property not found" message. No modification needed.
Note that some interface methods has changed by adding throw an exception clause, but it was a must in order to achieve the new behavior.


Commits
*******
Commit in master -> https://github.com/droolsjbpm/dashboard-builder/commit/bbb2b273ed1ec814957c5f644bb130d89ea5832a

Commit in 6.2.x -> https://github.com/droolsjbpm/dashboard-builder/commit/ae5f596528505a5a7d513b18904097f283aeb851

Comment 4 Jan Hrcek 2015-01-05 13:32:17 UTC
Ok, now it works correctly. Verified with BPM Suite 6.1.0 ER3.

Comment 5 Jan Hrcek 2015-01-14 08:05:21 UTC
Reopening this BZ as it does not always work correctly in case of KPI panels.
Put shortly, in some cases when property is removed from the DataProvider, the KPI reconfigures itself to use different property, but then it displays nonsense data.

See video which illustrates the issue: after property is removed from the provider, the KPI reconfigures itself to use different property - but then it might end up displaying nonsense data without user noticing.

In this case I have simple testing H2 database (attached). To use it 
1) add jdbc driver of H2 db on dashbuilder's classpath (e.g. add <module name="com.h2database.h2"/> as dependency to dashbuilder.war/WEB-IN/jboss-deployment-structure.xml)
2) In dashbuilder create external connection with URL:
URL=jdbc:h2:/path/to/DataProviderManagement
username=dbUser
password=dbPassword

This DB contains 1 table (PERSON) with 4 columns (id, name, birthday, salary)

3) Create a KPI panel with domain=name, range=salary (range aggregation function = Average)
4) I edit Data provider SQL query, removing name column and reload page. I would expect the KPI to be marked as broken, but instead there seems to be some logic, that automatically changes KPI's range to different property (id in my case). So the KPI is not marked as broken, but instead it displays different data (domain=id, range=salary).
------------
What do you think? Is this behavior correct? I find it suspicious. Although it might be useful in preventing error messages being displayed, it might lead to dashboard displaying nonsense data without user noticing it.

Comment 6 Jan Hrcek 2015-01-14 08:07:07 UTC
Created attachment 979882 [details]
Kpi reconfigures itself instead of showing error

Comment 7 Jan Hrcek 2015-01-14 08:08:21 UTC
Created attachment 979883 [details]
Testing H2 db, username=dbUser, password=dbPassword

Comment 8 Roger Martínez 2015-01-22 15:52:33 UTC
Hi Jan,

I'm agree with you in that point, but it's quite impossible by the application to know how to reconfigure the displayer when a property has been removed. I don't know which of the other properties make sense for using it... so what you propose it's really difficult, I don't know how to achieve it. I have talked with David too and he says the same, there is no solution for that case.

I think that the only solution we can try, instead of auto-reconfiguring the displayer when a property has been removed, is to let the displayer "bad-configured" when a property that uses is removed. It's same as when you create a new one: It doesn't shows any information or chart, it just shows the combo selection for dataprovider and then let the user reconfigure it by itself.

What do you think?

Comment 9 Jan Hrcek 2015-01-23 05:56:00 UTC
Hello Roger,

I don't want you to implement any sophisticated logic, I understand that it's impossible to chose meaningful replacement for the property removed in general. 
I was just confused that there are 2 possible outcomes after removing the property:
(1) the KPI auto-configures itself and just uses different (random) property for domain/range instead of the one you removed
(2) the panel somehow detects the change, displays the error messages and forces user to reconfigure it (behavior implemented for this BZ).

What I'm asking is if it's possible to be consistent and do either (1) or (2) (not both) in all cases. I think it would be better to go for option (2).

Imagine this scenario: a poor IT guy is responsible for configuring bunch of KPIs for his boss. The data is constantly changing and he adds or removes a property here or there. If some KPIs behave as in (1) he might not notice that he has broken something and he'll be scolded. Whereas if it always shows error as in (2), he'll be able to notice it and fix the configuration right away.

Comment 10 Roger Martínez 2015-01-23 11:41:31 UTC
Hello Jan!

Ahh ok! np! Sure, you are right. I understand :)

I will try to apply same behaviour for all kinds of KPI displayers, as probably tables have a different behavior than charts in this aspect... so let me review it!

THanks!

Comment 12 Jan Hrcek 2015-03-10 08:05:06 UTC
Ok, now it behaves as expected: after data provider property is removed, all dependent KPIs require reconfiguration.
Verified with BPM Suite 6.1.0 ER6