ARTEMIS-493 - NullPointerException when trying a null connection remote properties are passed by client

adde a check and fixed a couple of other potential NPE's

https://issues.apache.org/jira/browse/ARTEMIS-493
This commit is contained in:
Andy Taylor 2016-04-19 11:21:14 +01:00
parent bfa3b27cf7
commit 97f3fb241c
2 changed files with 23 additions and 13 deletions

View File

@ -242,23 +242,29 @@ public class ProtonSessionIntegrationCallback implements AMQPSessionCallback, Se
@Override @Override
public void rollbackCurrentTX() throws Exception { public void rollbackCurrentTX() throws Exception {
recoverContext(); //need to check here as this can be called if init fails
try { if (serverSession != null) {
serverSession.rollback(false); recoverContext();
} try {
finally { serverSession.rollback(false);
resetContext(); }
finally {
resetContext();
}
} }
} }
@Override @Override
public void close() throws Exception { public void close() throws Exception {
recoverContext(); //need to check here as this can be called if init fails
try { if (serverSession != null) {
serverSession.close(false); recoverContext();
} try {
finally { serverSession.close(false);
resetContext(); }
finally {
resetContext();
}
} }
} }

View File

@ -182,7 +182,11 @@ public abstract class AbstractConnectionContext extends ProtonInitializable impl
connection.open(); connection.open();
} }
initialise(); initialise();
if (!connection.getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED)) { /*
* This can be null which is in effect an empty map, also we really dont need to check this for in bound connections
* but its here in case we add support for outbound connections.
* */
if (connection.getRemoteProperties() == null || !connection.getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED)) {
long nextKeepAliveTime = handler.tick(true); long nextKeepAliveTime = handler.tick(true);
flushBytes(); flushBytes();
if (nextKeepAliveTime > 0 && scheduledPool != null) { if (nextKeepAliveTime > 0 && scheduledPool != null) {