Buggy code:
public class GatewayServlet extends AbstractRayoServlet { private static final long serialVersionUID = 1L ; private static final Loggerf log = Loggerf . getLogger ( GatewayServlet . class ) ; private GatewayDatastore gatewayDatastore ; private Set < String > internalDomains ; private Set < String > externalDomains ; protected RayoJIDLookupService < OfferEvent > rayoLookupService ; protected JIDRegistry jidRegistry ; @ Override public void init ( ServletConfig config ) throws ServletException { } @ Override protected void doPresence ( PresenceMessage message ) throws IOException , ServletException { } private void processServerPresence ( PresenceMessage message ) throws Exception { } private void processRayoNodePresence ( PresenceMessage message ) throws Exception { } private void broadcastEndEvent ( PresenceMessage message ) { } private void registerRayoNode ( PresenceMessage message ) throws Exception { } private void processCallPresence ( PresenceMessage message ) throws Exception { } private JID createCallJid ( String callId ) { } private void processClientPresence ( PresenceMessage message ) throws Exception { JID toJid = message . getTo ( ) ; JID fromJid = message . getFrom ( ) ; <START_BUG> if ( ( message . getType ( ) ) == null ) { <END_BUG> if ( validApplicationJid ( message . getFrom ( ) ) ) { switch ( message . getShow ( ) ) { case CHAT : gatewayDatastore . registerClientResource ( message . getFrom ( ) ) ; break ; case AWAY : case DND : case XA : gatewayDatastore . unregisterClientResource ( message . getFrom ( ) ) ; break ; } } else { sendPresenceError ( message . getTo ( ) , message . getFrom ( ) , RECIPIENT_UNAVAILABLE ) ; } } else if ( message . getType ( ) . equals ( "unavailable" ) ) { gatewayDatastore . unregisterClientResource ( message . getFrom ( ) ) ; Collection < String > callIds = gatewayDatastore . getCalls ( fromJid ) ; for ( String callId : callIds ) { try { String domainName = getDomainName ( callId ) ; JID toJidInternal = getXmppFactory ( ) . createJID ( ( ( callId + "@" ) + domainName ) ) ; JID fromJidInternal = getXmppFactory ( ) . createJID ( toJid . getDomain ( ) ) ; sendPresenceError ( fromJidInternal , toJidInternal ) ; } catch ( Exception e ) { GatewayServlet . log . error ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>hang<seq2seq4repair_space>up<seq2seq4repair_space>call<seq2seq4repair_space>with<seq2seq4repair_space>id<seq2seq4repair_space>[%s]" , callId ) ; GatewayServlet . log . error ( e . getMessage ( ) , e ) ; } } } else if ( message . getType ( ) . equals ( "subscribed" ) ) { } else if ( message . getType ( ) . equals ( "subscribe" ) ) { } } private boolean validApplicationJid ( JID fromJid ) { } @ Override protected void processIQRequest ( IQRequest request , DOMElement payload ) { } private void processClientIQRequest ( IQRequest request ) throws Exception { } private void processDialRequest ( IQRequest request ) throws Exception { } private void forwardIQRequest ( JID fromJidInternal , JID toJidInternal , IQRequest originalRequest , Element payload ) throws Exception { } private boolean isDial ( IQRequest request ) { } @ Override protected void doResponse ( XmppServletResponse response ) throws IOException , ServletException { } private void forwardResponse ( XmppServletResponse response , IQRequest originalRequest ) { } @ Override protected Loggerf getLog ( ) { } private boolean isMyInternalDomain ( JID jid ) { } private boolean isMyExternalDomain ( JID jid ) { } private String getDomainName ( String callId ) { } public void setGatewayDatastore ( GatewayDatastore gatewayDatastore ) { } public void setInternalDomains ( Set < String > internalDomains ) { } public void setExternalDomains ( Set < String > externalDomains ) { } public void setRayoLookupService ( RayoJIDLookupService < OfferEvent > rayoLookupService ) { } public void setJidRegistry ( JIDRegistry jidRegistry ) { } }

Fix:
if ( ( ( message . getType ( ) ) == null ) || ( message . getType ( ) . isEmpty ( ) ) ) {