03-01-2011 09:02 AM
I'm having a problem with URLEncodedPostData.getBytes() generating Illegal State Exception in a specific situation. Although I did get around it by opting for a completely different way of encoding my data, but was still curious as to why I was having the original issue in the first place.
The exception is generated only when the device has Encryption enabled and is also in locked mode. Following is a snippet of my code involved:
URLEncodedPostData encodedData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHAR
byte postData = encodedData.getBytes();
The last line is where the exception occurs. Odd thing is, no exception is generated if the Encryption is disabled for the device/simulator or if it's not in a locked mode. Any insight into this will be appreciated.
03-01-2011 10:22 AM
It's simply returning null.
The IllegalStateException must be related to the fact that device is in LOCKED mode since that's the only situation where the exception occurs. It also has to do with the Encryption being enabled for the device since without it, it doesn't occur. I find that odd since I don't see why those conditions should matter to URLEncodedPostData.getBytes() call.
03-01-2011 10:40 AM
I've had it happen to me before that the debugger claims that I have an exception on a certain line of code and it ended up being something like forgetting to put a UI update on the event thread from a separate thread. Is it possible that you have some UI update occurring while it's in that state?
03-01-2011 10:49 AM
I'm familiar with the situation you're describing (happend to me also in the past), but this one is definitely a different animal. It's such a simple line of code and the fact that it's occurring only in a specific situationi is what confuses me. That's why I'm interested in finding out the reason even though I have found a work-around for the issue.
The closest reason I could find while searching on this forum is that this might be related to the following link:
Since URLEncodedPostData.getBytes() routine is defined within the net.rim.blackberry.api.browser package, internal implementation could be calling something that requires User confirmation (based on Encryption being enabled). If so, I suppose there could be some UI issue conflict while being in LOCKED mode. If this is indeed the case, then it's very counter-intuitive given that one would normally expect URLEncodedPostData.getBytes() to be used without considering such situation.
03-02-2011 09:55 PM
Calling Mark Sohm on this issue...
Nothing urgent, but very curious since this issue has caused me plenty of sleep-less hours trying to debug it, let alone identifying the exact config settings where the error occurs.