Thursday, May 2, 2019

Strange problem with casting an object to Comparable in GWT 2.8.2

I'm having a problem with Date objects in GWT 2.8.2.
 
As part of a GUI component to create query objects for searching through our database I have this piece of code that tries to compare from/to objects (Object types are normally Date/BigDecimal/Integer/...)
 
I have this piece of code:
 
if (fromValue instanceof Comparable && toValue != null) {
 
final Comparable fromCompare = (Comparable)from;
 
if (fromCompare.compareTo( toValue) >= 0) {
    notifications
.add(Notification.error().text(messages.fromMustBeSmallerThanTo(getConfiguration().getSubject())));
 
}
}

when running in super dev mode I get a runtime error, which is really not very helpful because the stack does not contain anything useful.

 
Uncaught Error: com.google.web.bindery.event.shared.UmbrellaException: Exception caught: null
    at X$e_g$
.Fm_g$ [as createError_0_g$] (Throwable.java:120)
    at X$e_g$
.Pm_g$ [as initializeBackingError_0_g$] (Throwable.java:112)
    at X$e_g$
.zm_g$ (Throwable.java:73)
    at X$e_g$
.dn_g$ (Exception.java:33)
    at X$e_g$
.ln_g$ (RuntimeException.java:33)
    at
new X$e_g$ (UmbrellaException.java:65)
    at l$e_g$
.s$e_g$ [as doFire_0_g$] (SimpleEventBus.java:203)
    at l$e_g$
.z$e_g$ [as fireEventFromSource_0_g$] (SimpleEventBus.java:96)
    at
TDl_g$.S6g_g$ [as fireEvent_0_g$] (PresenterWidget.java:321)
    at
TDl_g$.R6g_g$ [as fireEvent_1_g$] (PresenterWidget.java:307)
    at
CZe_g$ (ValueChangeEvent.java:43)
    at
TDl_g$.DVk_g$ [as onDateChanged_0_g$] (DatePicker.java:115)
    at eWk_g$
.fWk_g$ [as accept_2_g$] (DatePickerViewImpl.java:50)
    at
UVk_g$.VVk_g$ [as fireEventWhenNotUpdating_0_g$] (DatePickerViewImpl.java:92)
    at
UVk_g$.YVk_g$ [as lambda$0_20_g$] (DatePickerViewImpl.java:50)
    at
Function.nWk_g$ (DatePickerViewImpl.java:50)
    at
HTMLDivElement.lambda_0_g$ (Runtime.java:166)
    at
HTMLDivElement.dispatch (jquery.js:5206)
    at
HTMLDivElement.q.handle (jquery.js:5014)
    at
Object.trigger (jquery.js:8201)
    at
HTMLDivElement.<anonymous> (jquery.js:8269)
    at
Function.each (jquery.js:362)
    at r
.fn.init.each (jquery.js:157)
    at r
.fn.init.trigger (jquery.js:8268)
    at J
(bootstrap-datetimepicker.min.js:51)
    at aa
(bootstrap-datetimepicker.min.js:56)
    at ga
(bootstrap-datetimepicker.min.js:74)
    at
HTMLDivElement.ha (bootstrap-datetimepicker.min.js:77)
    at
HTMLDivElement.dispatch (jquery.js:5206)
    at
HTMLDivElement.q.handle (jquery.js:5014)


When debugging I noticed that the failure actally happens on the second line when actually casting to Comparable (after I checked right before that it was a Comparable).
final Comparable fromCompare = (Comparable)from;

I first thought it only happened with Date objects, but I have the same behavior with BigDecimal for example.
Is this a known issue ? Is there a fix or workaround available ?




 

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment