Преглед изворни кода

Merge pull request #91 from greboid/dev

Narrow some scopes for some variables.
pull/92/head
Chris Smith пре 9 година
родитељ
комит
264f93b7ae
1 измењених фајлова са 7 додато и 6 уклоњено
  1. 7
    6
      irc/src/com/dmdirc/parser/irc/IRCParser.java

+ 7
- 6
irc/src/com/dmdirc/parser/irc/IRCParser.java Прегледај датотеку

@@ -195,15 +195,13 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
195 195
     /** Hashtable storing all information gathered from 005. */
196 196
     public final Map<String, String> h005Info = new HashMap<>();
197 197
     /** difference in ms between our time and the servers time (used for timestampedIRC). */
198
-    long tsdiff;
198
+    private long tsdiff;
199 199
     /** Reference to the Processing Manager. */
200 200
     private final ProcessingManager myProcessingManager;
201 201
     /** Should we automatically disconnect on fatal errors?. */
202 202
     private boolean disconnectOnFatal = true;
203 203
     /** Current Socket State. */
204 204
     protected SocketState currentSocketState = SocketState.NULL;
205
-    /** This is the socket used for reading from/writing to the IRC server. */
206
-    private Socket socket;
207 205
     /**
208 206
      * The underlying socket used for reading/writing to the IRC server.
209 207
      * For normal sockets this will be the same as {@link #socket} but for SSL
@@ -727,10 +725,10 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
727 725
         currentSocketState = SocketState.OPENING;
728 726
 
729 727
         final URI connectUri = getConnectURI(getURI());
730
-        socket = getSocketFactory().createSocket(connectUri.getHost(), connectUri.getPort());
731 728
 
732
-        rawSocket = socket;
729
+        rawSocket = getSocketFactory().createSocket(connectUri.getHost(), connectUri.getPort());
733 730
 
731
+        final Socket socket;
734 732
         if (getURI().getScheme().endsWith("s")) {
735 733
             callDebugInfo(DEBUG_SOCKET, "Server is SSL.");
736 734
 
@@ -742,7 +740,8 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
742 740
             sc.init(myKeyManagers, myTrustManager, new SecureRandom());
743 741
 
744 742
             final SSLSocketFactory socketFactory = sc.getSocketFactory();
745
-            socket = socketFactory.createSocket(socket, getURI().getHost(), getURI().getPort(), false);
743
+            socket = socketFactory.createSocket(rawSocket, getURI().getHost(), getURI()
744
+                    .getPort(), false);
746 745
 
747 746
             // Manually start a handshake so we get proper SSL errors here,
748 747
             // and so that we can control the connection timeout
@@ -752,6 +751,8 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
752 751
             socket.setSoTimeout(timeout);
753 752
 
754 753
             currentSocketState = SocketState.OPENING;
754
+        } else {
755
+            socket = rawSocket;
755 756
         }
756 757
 
757 758
         callDebugInfo(DEBUG_SOCKET, "\t-> Opening socket output stream PrintWriter");

Loading…
Откажи
Сачувај