| Issue 167: | NPE when reading messages. | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
There was a similar issue, number 33, which is flagged as fixed. This
problem, however, is quite recent.
Here is my log (edited):
18:15:50,118 DEBUG [SMS-Thread] SEND :AT+CPMS="SM"(cr)
18:15:50,129 DEBUG [SMS-Thread] BUFFER: OK
18:15:50,129 DEBUG [SMS-Thread] RECV :OK(cr)
18:15:50,129 DEBUG [SMS-Thread] SEND :AT+CMGL=4(cr)
18:15:44,051 DEBUG [SMS-Thread] BUFFER: +CPMS: 0,20,0,20\nOK
18:15:44,052 DEBUG [SMS-Thread] RECV :+CPMS: 0,20,0,20(cr)OK(cr)
18:15:44,052 DEBUG [SMS-Thread] READ PDU: OK
18:15:44,052 ERROR [SMS-Thread] Unhandled SMS in inbox, skipping...
java.lang.NumberFormatException: For input string: "OK"
at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at org.ajwcc.pduUtils.gsm3040.PduUtils.pduToBytes(PduUtils.java:918)
at org.ajwcc.pduUtils.gsm3040.PduParser.parsePdu(PduParser.java:154)
at org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:407)
at org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:147)
at org.smslib.Service.readMessages(Service.java:435)
at org.smslib.Service.readMessages(Service.java:339)
...
18:15:44,053 ERROR [SMS-Thread] ERROR PDU: OK
java.lang.NullPointerException
at org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:497)
at org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:147)
at org.smslib.Service.readMessages(Service.java:435)
at org.smslib.Service.readMessages(Service.java:339)
...
I could fix the NPE easily, but I don't really want to break some
misunderstood logic.
Basically, the phone answers without a PDU line, which is unexpected by the
code.
There are also a few potential NPE places, and also bad error checks:
1)
for (;;)
{
line = reader.readLine().trim();
--> should check for returned value of readline
if (line == null) break;
--> line can't be null
line = line.trim();
--> line already trimmed!
if (line.length() > 0) break;
}
2+) There are other places with dangerous code like readLine().trim().
|
||||||||||||
,
Jan 14, 2009
Hi, Issue #33 first appeared as a side effect of some Siemens phones which (like yours) responded with empty lines (which is, of course, unexpected). Some questions pls: 1) What modem do you use? 2) Do these empty lines appear consistently or randomly? 3) Have you spotted the commands that trigger this error? I.e. does it always happen when you read messages or at other places as well? 4) The empty line you've seen is just an empty line between "valid" lines or is the entire response an empty line? Thanks for your observations - will scan the code and fix accordingly.
Summary: NPE when reading messages.
Status: Accepted Labels: Milestone-v3.4.0 Component-SMSLib |
|||||||||||||
,
Jan 14, 2009
Hi, 1) It's an industrial module with a Wavecom Wismo module inside. 2) Today was the very first time, however it was very consistent once it began. Right now it doesn't occur, since I fixed the NPE by letting the method create an UnknownMessage. It must have deleted it after readMessages returned, since after processing the read messages, I delete them one by one. 3) Only when I read messages. I didn't notice any other problems. I don't really use the library for anything else than read and delete them. 4) The entire response was as follows (using C style escapes): +CPMS: 0,20,0,20\rOK\r Nothing more. Thanks! |
|||||||||||||
,
Jan 16, 2009
r1695
Status: Completed
|
|||||||||||||
,
Jan 25, 2009
(No comment was entered for this change.)
Labels: Priority-Medium
|
|||||||||||||
,
Mar 29, 2009
(No comment was entered for this change.)
Status: Fixed
|
|||||||||||||
|
|
|||||||||||||