Browse Source

Fixes issue 3515: Twitter parser NPEs in the ctor if you dont give it a user

Change-Id: I754c511f161c0ba4ef1b1cba36e0c8a6d9e9e717
Reviewed-on: http://gerrit.dmdirc.com/743
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.6.3
Gregory Holmes 14 years ago
parent
commit
16b869a995
1 changed files with 13 additions and 2 deletions
  1. 13
    2
      src/com/dmdirc/addons/parser_twitter/Twitter.java

+ 13
- 2
src/com/dmdirc/addons/parser_twitter/Twitter.java View File

176
      * @param myPlugin Plugin that created this parser
176
      * @param myPlugin Plugin that created this parser
177
      */
177
      */
178
     protected Twitter(final MyInfo myInfo, final URI address, final TwitterPlugin myPlugin) {
178
     protected Twitter(final MyInfo myInfo, final URI address, final TwitterPlugin myPlugin) {
179
-        final String[] bits = address.getUserInfo().split(":");
180
-        this.myUsername = bits[0];
179
+        final String[] bits;
180
+        if (address.getUserInfo() == null) {
181
+            bits = new String[]{};
182
+        } else {
183
+            bits = address.getUserInfo().split(":");
184
+        }
185
+        this.myUsername = bits.length == 0 ? "" : bits[0];
181
         this.myPassword = (bits.length > 1) ? bits[1] : "";
186
         this.myPassword = (bits.length > 1) ? bits[1] : "";
182
 
187
 
183
         this.myPlugin = myPlugin;
188
         this.myPlugin = myPlugin;
872
     public void run() {
877
     public void run() {
873
         resetState();
878
         resetState();
874
 
879
 
880
+        if (myUsername.isEmpty()) {
881
+            sendPrivateNotice("Unable to connect to "+myServerName+" without a username. Disconnecting.");
882
+            getCallbackManager().getCallbackType(SocketCloseListener.class).call();
883
+            return;
884
+        }
885
+
875
         // Get the consumerKey and consumerSecret for this server if known
886
         // Get the consumerKey and consumerSecret for this server if known
876
         // else default to our twitter key and secret
887
         // else default to our twitter key and secret
877
         final String consumerKey;
888
         final String consumerKey;

Loading…
Cancel
Save