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
public void rollbackCurrentTX() throws Exception {
recoverContext();
try {
serverSession.rollback(false);
}
finally {
resetContext();
//need to check here as this can be called if init fails
if (serverSession != null) {
recoverContext();
try {
serverSession.rollback(false);
}
finally {
resetContext();
}
}
}
@Override
public void close() throws Exception {
recoverContext();
try {
serverSession.close(false);
}
finally {
resetContext();
//need to check here as this can be called if init fails
if (serverSession != null) {
recoverContext();
try {
serverSession.close(false);
}
finally {
resetContext();
}
}
}

View File

@ -182,7 +182,11 @@ public abstract class AbstractConnectionContext extends ProtonInitializable impl
connection.open();
}
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);
flushBytes();
if (nextKeepAliveTime > 0 && scheduledPool != null) {