map.get()上的NullPointer异常

时间:2016-03-18 09:28:21

标签: java hadoop dictionary nullpointerexception hashmap

   private void doConnect() {
            Log.d(TAG, "doConnect()");
            IMqttToken token;
            MqttConnectOptions options = new MqttConnectOptions();
            options.setCleanSession(false);
            options.setKeepAliveInterval(30);
            try {
            mqttClient = new MqttAsyncClient(tcp_server_URL, deviceId, new MemoryPersistence());

            token = mqttClient.connect(options);
            token.waitForCompletion(3500);
            mqttClient.setCallback(new MqttEventCallback());
            //changed single subscription of each topic to mass subscription
            // using String [] of Topics and int [] of QoS

            if (channelList != null) {
            channelListStringArray= new String[channelList.size()];
            channelListQosStringArray= new int[channelList.size()];
            for (int i = 0; i < channelList.size(); i++) {
            // creating String Array of topics and int Array of QoS
            channelListStringArray [i] = "account/" + channelList.get(i);
            channelListQosStringArray [i] = 1;
            }
            //subscribe all channels by passing all topics as String Array and QoS int array
            token = mqttClient.subscribe(channelListStringArray, channelListQosStringArray);
            token.waitForCompletion(3500);
            }

            } catch (MqttSecurityException e) {
            e.printStackTrace();
            } catch (MqttException e) {
            switch (e.getReasonCode()) {
            case MqttException.REASON_CODE_BROKER_UNAVAILABLE:
            case MqttException.REASON_CODE_CLIENT_TIMEOUT:
            case MqttException.REASON_CODE_CONNECTION_LOST:
            case MqttException.REASON_CODE_SERVER_CONNECT_ERROR:
            Log.v(TAG, "c" + e.getMessage());
            e.printStackTrace();
            break;
            case MqttException.REASON_CODE_FAILED_AUTHENTICATION:
            Intent i = new Intent("RAISEALLARM");
            i.putExtra("ALLARM", e);
            Log.e(TAG, "b" + e.getMessage());
            break;
            default:
            Log.e(TAG, "a" + e.getMessage());
            }
            }
            }

此代码在java中运行完美,但在mapreduce中抛出NULL指针异常。 l3(list)的值根本没有初始化。我正在尝试使用强力算法来查找派系。该程序具有静态输入,图中的5个节点都相互连接。 这不是整个程序,只是显示错误的代码片段。

0 个答案:

没有答案