Program: 96576
Project: 96576
Buggy source:
/** 
 * Send a notification about the session being opened. We set things up so that this is considered to be a service-level operation, but all the real data is in the session level, so for consistency and locality, we're going to process it in here, though we do check the SERVICE-level notifications-enabled flag.
 */
@Override public void doSessionCreated(final SessionManagementBean sessionBean) throws Exception {
  ServiceManagementBean serviceBean=sessionBean.getServiceManagementBean();
  if (serviceBean.areNotificationsEnabled()) {
    JSONObject sessionData=new JSONObject();
    IoSessionEx session=sessionBean.getSession();
    sessionData.put("String_Node_Str",session.getId());
    sessionData.put("String_Node_Str",serviceBean.getId());
    sessionData.put("String_Node_Str",session.getCreationTime());
    sessionData.put("String_Node_Str",session.getLocalAddress());
    sessionData.put("String_Node_Str",serviceBean.getSessionRemoteAddress(session));
    ResourceAddress address=BridgeSession.LOCAL_ADDRESS.get(session);
    sessionData.put("String_Node_Str",Utils.getSessionTypeName(address));
    sessionData.put("String_Node_Str",Utils.getSessionDirection(session));
    Map<String,String> userPrincipals=sessionBean.getUserPrincipalMap();
    if (userPrincipals != null) {
      sessionData.put("String_Node_Str",userPrincipals);
    }
    JSONObject protocolAttributes=null;
    if (session instanceof AbstractWsBridgeSession) {
      AbstractWsBridgeSession wsBridgeSession=(AbstractWsBridgeSession)session;
      protocolAttributes=new JSONObject();
      List<ExtensionHeader> extensions=wsBridgeSession.getWsExtensions().asList();
      if (extensions != null && extensions.size() > 0) {
        JSONObject jsonObj=new JSONObject();
        for (        ExtensionHeader extension : extensions) {
          String token=extension.getExtensionToken();
          JSONArray paramsArray=null;
          if (extension.hasParameters()) {
            paramsArray=new JSONArray();
            for (            ExtensionParameter param : extension.getParameters()) {
              String name=param.getName();
              String value=param.getValue();
              if (value == null) {
                paramsArray.put(name.toString());
              }
 else {
                paramsArray.put(name.toString() + "String_Node_Str" + value.toString());
              }
            }
          }
          jsonObj.put(token,paramsArray);
        }
        protocolAttributes.put("String_Node_Str",jsonObj);
      }
      if (session instanceof WsnSession) {
        WsnSession wsnSession=(WsnSession)session;
        WebSocketWireProtocol protocolVersion=wsnSession.getVersion();
        protocolAttributes.put("String_Node_Str",protocolVersion.toString());
      }
 else       if (session instanceof WsebSession) {
        WsebSession wsebSession=(WsebSession)session;
        ResourceAddress readAddr=wsebSession.getReadAddress();
        ResourceAddress writeAddr=wsebSession.getWriteAddress();
        if (readAddr != null) {
          protocolAttributes.put("String_Node_Str",readAddr);
        }
        if (writeAddr != null) {
          protocolAttributes.put("String_Node_Str",writeAddr);
        }
      }
 else       if (session instanceof WsrSession) {
        WsrSession wsrSession=(WsrSession)session;
        ResourceAddress rtmpAddress=wsrSession.getRtmpAddress();
        protocolAttributes.put("String_Node_Str",rtmpAddress);
      }
    }
    if (protocolAttributes != null) {
      sessionData.put("String_Node_Str",protocolAttributes);
    }
    OID notificationOID=MIBConstants.oidServiceConnectionNotification;
    VariableBinding[] variables=new VariableBinding[1];
    variables[0]=new VariableBinding(notificationOID,new OctetString(sessionData.toString()));
    sendNotification(notificationOID,variables);
  }
}

Fixed version (ground truth):
/** 
 * Send a notification about the session being opened. We set things up so that this is considered to be a service-level operation, but all the real data is in the session level, so for consistency and locality, we're going to process it in here, though we do check the SERVICE-level notifications-enabled flag.
 */
@Override public void doSessionCreated(final SessionManagementBean sessionBean) throws Exception {
  ServiceManagementBean serviceBean=sessionBean.getServiceManagementBean();
  if (serviceBean.areNotificationsEnabled()) {
    JSONObject sessionData=new JSONObject();
    IoSessionEx session=sessionBean.getSession();
    sessionData.put("String_Node_Str",session.getId());
    sessionData.put("String_Node_Str",serviceBean.getId());
    sessionData.put("String_Node_Str",session.getCreationTime());
    sessionData.put("String_Node_Str",session.getLocalAddress());
    sessionData.put("String_Node_Str",serviceBean.getSessionRemoteAddress(session));
    ResourceAddress address=BridgeSession.LOCAL_ADDRESS.get(session);
    sessionData.put("String_Node_Str",Utils.getSessionTypeName(address));
    sessionData.put("String_Node_Str",Utils.getSessionDirection(session));
    Map<String,String> userPrincipals=sessionBean.getUserPrincipalMap();
    if (userPrincipals != null) {
      sessionData.put("String_Node_Str",userPrincipals);
    }
    JSONObject protocolAttributes=null;
    if (session instanceof AbstractWsBridgeSession) {
      AbstractWsBridgeSession wsBridgeSession=(AbstractWsBridgeSession)session;
      protocolAttributes=new JSONObject();
      List<WebSocketExtension> extensions=wsBridgeSession.getExtensions();
      if (extensions != null && extensions.size() > 0) {
        JSONObject jsonObj=new JSONObject();
        for (        WebSocketExtension extension : extensions) {
          ExtensionHeader extensionHeader=extension.getExtensionHeader();
          String token=extensionHeader.getExtensionToken();
          JSONArray paramsArray=null;
          if (extensionHeader.hasParameters()) {
            paramsArray=new JSONArray();
            for (            ExtensionParameter param : extensionHeader.getParameters()) {
              String name=param.getName();
              String value=param.getValue();
              if (value == null) {
                paramsArray.put(name.toString());
              }
 else {
                paramsArray.put(name.toString() + "String_Node_Str" + value.toString());
              }
            }
          }
          jsonObj.put(token,paramsArray);
        }
        protocolAttributes.put("String_Node_Str",jsonObj);
      }
      if (session instanceof WsnSession) {
        WsnSession wsnSession=(WsnSession)session;
        WebSocketWireProtocol protocolVersion=wsnSession.getVersion();
        protocolAttributes.put("String_Node_Str",protocolVersion.toString());
      }
 else       if (session instanceof WsebSession) {
        WsebSession wsebSession=(WsebSession)session;
        ResourceAddress readAddr=wsebSession.getReadAddress();
        ResourceAddress writeAddr=wsebSession.getWriteAddress();
        if (readAddr != null) {
          protocolAttributes.put("String_Node_Str",readAddr);
        }
        if (writeAddr != null) {
          protocolAttributes.put("String_Node_Str",writeAddr);
        }
      }
 else       if (session instanceof WsrSession) {
        WsrSession wsrSession=(WsrSession)session;
        ResourceAddress rtmpAddress=wsrSession.getRtmpAddress();
        protocolAttributes.put("String_Node_Str",rtmpAddress);
      }
    }
    if (protocolAttributes != null) {
      sessionData.put("String_Node_Str",protocolAttributes);
    }
    OID notificationOID=MIBConstants.oidServiceConnectionNotification;
    VariableBinding[] variables=new VariableBinding[1];
    variables[0]=new VariableBinding(notificationOID,new OctetString(sessionData.toString()));
    sendNotification(notificationOID,variables);
  }
}