xinbc / jdiameter

Automatically exported from code.google.com/p/jdiameter
0 stars 0 forks source link

NPE in ClientRxSessionImpl for AAA with no result code #52

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Result Code AVP is optional in AAA Rx operation but Result code is checked to 
see if the message is a success.

Class - ClientRxSessionImpl 
Method - handleEventForSessionBased
Line - 331

My workaround is to assume the message is unsuccessful unless the result code 
is present.

e.g.
  private static final long DIAMETER_UNABLE_TO_COMPLY = 5012L;

                //Assume unsuccessful response unless result code specified.
                long resultCode = DIAMETER_UNABLE_TO_COMPLY;
                if (answer.getResultCodeAvp() != null) {
                    resultCode = answer.getResultCodeAvp().getUnsigned32();
                }

07:18:08,193 DEBUG  [, , ] 
[org.jdiameter.client.impl.transport.tcp.TCPClientConnection] (TCPReader-4) 
Releasing lock and finished onEvent for connection [aaa://dra-central:3868]
07:18:08,193 DEBUG  [, , ] [org.jdiameter.client.impl.fsm.PeerFSMImpl] 
(FSM-SPeer{Uri=aaa://172.16.121.36:3868; State=null; con=null; incConnull 
}_1-0) Got Event [Event{name:RECEIVE_MSG_EVENT, key:null, 
object:MessageImpl{commandCode=265, flags=96}}] from Queue
07:18:08,193 DEBUG  [, , ] 
[org.jdiameter.client.impl.transport.tcp.TCPTransportClient] (TCPReader-4) 
Finished passing message on to parent
07:18:08,194 DEBUG  [, , ] [org.jdiameter.client.impl.fsm.PeerFSMImpl] 
(FSM-SPeer{Uri=aaa://172.16.121.36:3868; State=null; con=null; incConnull 
}_1-0) Process event [Event{name:RECEIVE_MSG_EVENT, key:null, 
object:MessageImpl{commandCode=265, flags=96}}]. Peer State is [OKAY]
07:18:08,194 DEBUG  [, , ] [org.jdiameter.server.impl.PeerImpl] 
(FSM-SPeer{Uri=aaa://172.16.121.36:3868; State=null; con=null; incConnull 
}_1-0) Receiving message in server.
07:18:08,195 DEBUG  [, , ] [org.jdiameter.client.impl.controller.PeerImpl] 
(FSM-SPeer{Uri=aaa://172.16.121.36:3868; State=null; con=null; incConnull 
}_1-0) Receiving message in client.
07:18:08,195 DEBUG  [, , ] [org.jdiameter.client.impl.controller.PeerImpl] 
(FSM-SPeer{Uri=aaa://172.16.121.36:3868; State=null; con=null; incConnull 
}_1-0) Message is an answer
07:18:08,196 DEBUG  [, , ] 
[org.jdiameter.client.impl.app.rx.ClientRxSessionImpl] (ApplicationSession-0) 
Failure processing success message: org.jdiameter.api.InternalException: 
java.lang.NullPointerException
        at org.jdiameter.client.impl.app.rx.ClientRxSessionImpl.handleEventForSessionBased(ClientRxSessionImpl.java:503) [jdiameter-impl-1.6.0-SNAPSHOT.jar:1.6.0-SNAPSHOT]
        at org.jdiameter.client.impl.app.rx.ClientRxSessionImpl.handleEvent(ClientRxSessionImpl.java:195) [jdiameter-impl-1.6.0-SNAPSHOT.jar:1.6.0-SNAPSHOT]
        at org.jdiameter.client.impl.app.rx.ClientRxSessionImpl$AnswerDelivery.run(ClientRxSessionImpl.java:763) [jdiameter-impl-1.6.0-SNAPSHOT.jar:1.6.0-SNAPSHOT]
        at org.jdiameter.common.impl.concurrent.DefaultRunnable.run(DefaultRunnable.java:47) [jdiameter-impl-1.6.0-SNAPSHOT.jar:1.6.0-SNAPSHOT]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_17]
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_17]
        at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_17]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [rt.jar:1.7.0_17]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [rt.jar:1.7.0_17]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_17]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_17]
        at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_17]
Caused by: java.lang.NullPointerException
        at org.jdiameter.client.impl.app.rx.ClientRxSessionImpl.handleEventForSessionBased(ClientRxSessionImpl.java:325) [jdiameter-impl-1.6.0-SNAPSHOT.jar:1.6.0-SNAPSHOT]
        ... 11 more

Original issue reported on code.google.com by kilian.w...@gmail.com on 16 Dec 2013 at 9:54

GoogleCodeExporter commented 9 years ago
Hi,

I don't think any Diameter Answer without Result-Code or 
Experimental-Result-Code is valid, and that's what we check for. From Diameter 
Base RFC: "All Diameter answer messages defined in vendor-specific applications 
MUST include either one Result-Code AVP or one Experimental-Result AVP."

Still, I agree we could improve and reply with a DIAMETER_MISSING_AVP 5005 
result-code. An issue for that has been created: Issue #63

Original comment by brainslog on 4 Jul 2014 at 11:19