Bug 790495

Summary: jbpm-console: IllegalArgumentException: must be positive
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Jiri Locker <jlocker>
Component: jBPM ConsoleAssignee: Kris Verlaenen <kverlaen>
Status: MODIFIED --- QA Contact: Jiri Locker <jlocker>
Severity: low Docs Contact:
Priority: unspecified    
Version: BRMS 5.3.0.GA   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
When using the Business Central Console a bug in org.jboss.errai.bus.client.framework.ClientMessageBusImpl class causes the console to log an 'illegalArgumentException: must be positive' error to be logged in the message window.
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:
Attachments:
Description Flags
mustBePositive.png none

Description Jiri Locker 2012-02-14 16:55:20 UTC
Created attachment 561973 [details]
mustBePositive.png

Description of problem:
When I leave jbpm-console without touching it for some time it logs this exception in the sliding Messages window. I do not know exactly how to reproduce but I hope someone recognizes the problem after seeing it.

Version-Release number of selected component (if applicable):
BRMS 5.3.0 ER3

How reproducible:
uncertain

Steps to Reproduce:
1. make sure there are some processes in Guvnor repository
2. go to jbpm-console and list some processes in the Process Overview
3. leave the window open, do something else and return to it after a few minutes
  
Actual results:
the exception is logged, the reason is not clear

Expected results:
the exception should not occur

Additional info:
screenshot

Comment 3 Geoffrey De Smet 2012-04-25 11:44:37 UTC
This is a bug in errai-bus-1.1.Final in org.jboss.errai.bus.client.framework.ClientMessageBusImpl at line 959:


        heartBeatTimer =
                new Timer() {
                    @Override
                    public void run() {
                        if (System.currentTimeMillis() - lastTransmit >= HEARTBEAT_DELAY) {
                            encodeAndTransmit(MessageBuilder.createMessage().toSubject("ServerBus")
                                    .command(BusCommands.Heartbeat).noErrorHandling().getMessage());
                            schedule(HEARTBEAT_DELAY);
                        } else {
                            long win = System.currentTimeMillis() - lastTransmit; // BUG
                            int diff = HEARTBEAT_DELAY - (int) win;
                            schedule(diff);
                        }
                    }
                };


In the code above, "long win" might be bigger then HEARTBEAT_DELAY because the System.currentTimeMillis() might have changed between the first and second call to it. The solution would be to calculate the "long win" before the if, just once. This also explains why this problem occurs easier on linux based platforms then windows based platforms as the former uses a more fine-grained currentTimeMillis().

Comment 4 Geoffrey De Smet 2012-04-25 12:15:44 UTC
Won't fix (on the branch).

The bug is still there in errai-bus 1.3.2.Final, the last version of 1.x:
http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.errai/errai-bus/1.3.2.Final/org/jboss/errai/bus/client/framework/ClientMessageBusImpl.java#1144

Upgrading to an errai 2.x is unrealistic and very risky because it's backwards incompatible. Even that version upgrade 1.1 -> 1.3  would have been risky.

I see no plausible workaround at this point: I see no way of replacing the current ClientMessageBusImpl with an extended ClientMessageBusImpl that fixes the problem.

On master, Toni's been looking at integrating bpm-console with guvnor which would imply upgrading to errai 2.x, which hopefully fixes this issue. We 'll definitely want to recheck this issue then.

Comment 5 Geoffrey De Smet 2012-04-25 12:22:15 UTC
Errai 2.0.CR1 (the last released version of errai at this moment) does no longer seem to suffer from this problem.

Comment 6 lcarlon 2012-06-08 03:46:30 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When using the Business Central Console A bug in org.jboss.errai.bus.client.framework.ClientMessageBusImpl class causes the console to log an 'illegalArgumentException: must be positive' error to be logged in the message window.

Comment 7 lcarlon 2012-06-08 03:46:55 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-When using the Business Central Console A bug in org.jboss.errai.bus.client.framework.ClientMessageBusImpl class causes the console to log an 'illegalArgumentException: must be positive' error to be logged in the message window.+When using the Business Central Console a bug in org.jboss.errai.bus.client.framework.ClientMessageBusImpl class causes the console to log an 'illegalArgumentException: must be positive' error to be logged in the message window.