Browse Source

Fix calls to callDebugInfo that use string concatenation not string formatting.

pull/162/head
Shane Mc Cormack 5 years ago
parent
commit
9bab62102d

+ 9
- 11
irc/src/main/java/com/dmdirc/parser/irc/IRCParser.java View File

@@ -754,7 +754,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
754 754
         }
755 755
 
756 756
         resetState();
757
-        callDebugInfo(DEBUG_SOCKET, "Connecting to " + getURI().getHost() + ':' + getURI().getPort());
757
+        callDebugInfo(DEBUG_SOCKET, "Connecting to %s:%s", getURI().getHost(), getURI().getPort());
758 758
 
759 759
         currentSocketState = SocketState.OPENING;
760 760
 
@@ -823,7 +823,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
823 823
      * @param isUserError Is this a user error?
824 824
      */
825 825
     private void handleConnectException(final Exception e, final boolean isUserError) {
826
-        callDebugInfo(DEBUG_SOCKET, "Error Connecting (" + e.getMessage() + "), Aborted");
826
+        callDebugInfo(DEBUG_SOCKET, "Error Connecting (%s), Aborted", e.getMessage());
827 827
         final ParserError ei = new ParserError(
828 828
                 ParserError.ERROR_ERROR + (isUserError ? ParserError.ERROR_USER : 0),
829 829
                 "Exception with server socket", getLastLine());
@@ -877,7 +877,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
877 877
                     processLine(lastLine);
878 878
                 }
879 879
             } catch (IOException e) {
880
-                callDebugInfo(DEBUG_SOCKET, "Exception in main loop (" + e.getMessage() + "), Aborted");
880
+                callDebugInfo(DEBUG_SOCKET, "Exception in main loop (%s), Aborted", e.getMessage());
881 881
 
882 882
                 if (currentSocketState != SocketState.CLOSED) {
883 883
                     currentSocketState = SocketState.CLOSED;
@@ -1084,7 +1084,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1084 1084
                 final Queue<Character> listModeQueue = channel.getListModeQueue();
1085 1085
                 for (int i = 0; i < newLine[2].length(); ++i) {
1086 1086
                     final Character mode = newLine[2].charAt(i);
1087
-                    callDebugInfo(DEBUG_LMQ, "Intercepted mode request for " + channel + " for mode " + mode);
1087
+                    callDebugInfo(DEBUG_LMQ, "Intercepted mode request for %s for mode %s", channel, mode);
1088 1088
                     if (chanModesOther.containsKey(mode) && chanModesOther.get(mode) == MODE_LIST) {
1089 1089
                         if (foundModes.contains(mode)) {
1090 1090
                             callDebugInfo(DEBUG_LMQ, "Already added to LMQ");
@@ -1650,7 +1650,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1650 1650
         // MAXLIST=bdeI:50
1651 1651
         // MAXLIST=b:60,e:60,I:60
1652 1652
         // MAXBANS=30
1653
-        callDebugInfo(DEBUG_INFO, "Looking for maxlistmodes for: " + mode);
1653
+        callDebugInfo(DEBUG_INFO, "Looking for maxlistmodes for: %s", mode);
1654 1654
         // Try in MAXLIST
1655 1655
         int result = -2;
1656 1656
         if (h005Info.get(IrcConstants.ISUPPORT_MAXIMUM_LIST_MODES) != null) {
@@ -1658,15 +1658,13 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1658 1658
                 result = 0;
1659 1659
             }
1660 1660
             final String maxlist = h005Info.get(IrcConstants.ISUPPORT_MAXIMUM_LIST_MODES);
1661
-            callDebugInfo(DEBUG_INFO, "Found maxlist (" + maxlist + ')');
1661
+            callDebugInfo(DEBUG_INFO, "Found maxlist (%s)", maxlist);
1662 1662
             final String[] bits = maxlist.split(",");
1663 1663
             for (String bit : bits) {
1664 1664
                 final String[] parts = bit.split(":", 2);
1665
-                callDebugInfo(DEBUG_INFO, "Bit: " + bit + " | parts.length = " + parts.length + " ("
1666
-                        + parts[0] + " -> " + parts[0].indexOf(mode) + ')');
1665
+                callDebugInfo(DEBUG_INFO, "Bit: %s | parts.length = %s (%s -> %s)", bit, parts.length, parts[0], parts[0].indexOf(mode));
1667 1666
                 if (parts.length == 2 && parts[0].indexOf(mode) > -1) {
1668
-                    callDebugInfo(DEBUG_INFO, "parts[0] = '" + parts[0] + "' | parts[1] = '"
1669
-                            + parts[1] + '\'');
1667
+                    callDebugInfo(DEBUG_INFO, "parts[0] = '%s' | parts[1] = '%s'", parts[0], parts[1]);
1670 1668
                     try {
1671 1669
                         result = Integer.parseInt(parts[1]);
1672 1670
                         break;
@@ -1694,7 +1692,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
1694 1692
             callDebugInfo(DEBUG_INFO, "Failed");
1695 1693
             callErrorInfo(new ParserError(ParserError.ERROR_ERROR + ParserError.ERROR_USER, "Unable to discover max list modes.", getLastLine()));
1696 1694
         }
1697
-        callDebugInfo(DEBUG_INFO, "Result: " + result);
1695
+        callDebugInfo(DEBUG_INFO, "Result: %s", result);
1698 1696
         return result;
1699 1697
     }
1700 1698
 

+ 7
- 7
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessJoin.java View File

@@ -182,11 +182,11 @@ public class ProcessJoin extends IRCProcessor {
182 182
 
183 183
             final PendingJoin pendingJoin = pendingJoins.poll();
184 184
             if (pendingJoin != null && parser.getStringConverter().equalsIgnoreCase(pendingJoin.getChannel(), channelName)) {
185
-                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Guessing channel Key: " + pendingJoin.getChannel() + " -> " + pendingJoin.getKey());
185
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Guessing channel Key: %s -> %s", pendingJoin.getChannel(), pendingJoin.getKey());
186 186
                 iChannel.setInternalPassword(pendingJoin.getKey());
187 187
             } else {
188 188
                 // Out of sync, clear
189
-                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: pending join keys out of sync (Got: " + (pendingJoin == null ? pendingJoin : pendingJoin.getChannel()) + ", Wanted: " + channelName + ") - Clearing.");
189
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: pending join keys out of sync (Got: %s, Wanted: %s) - Clearing.", (pendingJoin == null ? pendingJoin : pendingJoin.getChannel()), channelName);
190 190
                 pendingJoins.clear();
191 191
             }
192 192
 
@@ -195,10 +195,10 @@ public class ProcessJoin extends IRCProcessor {
195 195
             // Some kind of failed to join, pop the pending join queues.
196 196
             final PendingJoin pendingJoin = pendingJoins.poll();
197 197
             if (pendingJoin != null && parser.getStringConverter().equalsIgnoreCase(pendingJoin.getChannel(), sParam)) {
198
-                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - Skipping " + pendingJoin.getChannel() + " (" + pendingJoin.getKey() + ")");
198
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (%s) - Skipping %s (%s)", sParam, pendingJoin.getChannel(), pendingJoin.getKey());
199 199
             } else {
200 200
                 // Out of sync, clear
201
-                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (" + sParam + ") - pending join keys out of sync (Got: " + (pendingJoin == null ? pendingJoin : pendingJoin.getChannel()) + ", Wanted: " + sParam + ") - Clearing.");
201
+                callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Failed to join channel (%s) - pending join keys out of sync (Got: %s, Wanted: %s) - Clearing.", sParam, (pendingJoin == null ? pendingJoin : pendingJoin.getChannel()), sParam);
202 202
                 pendingJoins.clear();
203 203
             }
204 204
         }
@@ -226,12 +226,12 @@ public class ProcessJoin extends IRCProcessor {
226 226
             for (final String chan : newLine[1].split(",")) {
227 227
                 final String key = keys.poll();
228 228
                 if (chan.equals("0")) {
229
-                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Ignoring possible channel Key for part-all channel: " + chan + " -> " + key);
229
+                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Ignoring possible channel Key for part-all channel: %s -> %s", chan, key);
230 230
                 } else if (getChannel(chan) == null) {
231
-                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Intercepted possible channel Key: " + chan + " -> " + key);
231
+                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Intercepted possible channel Key: %s -> %s", chan, key);
232 232
                     pendingJoins.add(new PendingJoin(chan, key));
233 233
                 } else {
234
-                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Ignoring possible channel Key for existing channel: " + chan + " -> " + key);
234
+                    callDebugInfo(IRCParser.DEBUG_INFO, "processJoin: Ignoring possible channel Key for existing channel: %s -> %s", chan, key);
235 235
                 }
236 236
             }
237 237
         }

+ 6
- 6
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessListModes.java View File

@@ -142,20 +142,20 @@ public class ProcessListModes extends IRCProcessor {
142 142
 
143 143
         // Unknown mode.
144 144
         if (mode == ' ') {
145
-            parser.callDebugInfo(IRCParser.DEBUG_LMQ, "Unknown mode line: " + Arrays.toString(token));
145
+            parser.callDebugInfo(IRCParser.DEBUG_LMQ, "Unknown mode line: %s", Arrays.toString(token));
146 146
             return;
147 147
         }
148 148
 
149 149
         final Queue<Character> listModeQueue = channel.getListModeQueue();
150 150
         if (!isCleverMode && listModeQueue != null) {
151 151
             if ("482".equals(sParam)) {
152
-                parser.callDebugInfo(IRCParser.DEBUG_LMQ, "Dropped LMQ mode " + listModeQueue.poll());
152
+                parser.callDebugInfo(IRCParser.DEBUG_LMQ, "Dropped LMQ mode %s", listModeQueue.poll());
153 153
                 return;
154 154
             } else {
155 155
                 if (listModeQueue.peek() != null) {
156 156
                     final Character oldMode = mode;
157 157
                     mode = listModeQueue.peek();
158
-                    parser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ says this is " + mode);
158
+                    parser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ says this is %s", mode);
159 159
 
160 160
                     boolean error = true;
161 161
 
@@ -187,7 +187,7 @@ public class ProcessListModes extends IRCProcessor {
187 187
                     // freenode-specific hacks above think the mode should be
188 188
                     // something else, error.
189 189
                     if (oldMode != mode && error) {
190
-                        parser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ disagrees with guess. LMQ: " + mode + " Guess: " + oldMode);
190
+                        parser.callDebugInfo(IRCParser.DEBUG_LMQ, "LMQ disagrees with guess. LMQ: %s Guess: %s", mode, oldMode);
191 191
                     }
192 192
 
193 193
                     if (!isItem) {
@@ -215,7 +215,7 @@ public class ProcessListModes extends IRCProcessor {
215 215
             } // End Hyperian stupidness of using the same numeric for 3 different things..
216 216
 
217 217
             if (!channel.getAddState(mode)) {
218
-                callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (" + mode + "): Clearing!");
218
+                callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (%s): Clearing!", mode);
219 219
                 final Collection<ChannelListModeItem> list = channel.getListMode(mode);
220 220
                 if (list == null) {
221 221
                     parser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '" + mode + "' - but channel object doesn't agree.", parser.getLastLine()));
@@ -226,7 +226,7 @@ public class ProcessListModes extends IRCProcessor {
226 226
                         final Character otherMode = mode == 'b' ? 'q' : 'b';
227 227
 
228 228
                         if (!channel.getAddState(otherMode)) {
229
-                            callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (" + mode + "): Clearing!");
229
+                            callDebugInfo(IRCParser.DEBUG_INFO, "New List Mode Batch (%s): Clearing!", mode);
230 230
                             final Collection<ChannelListModeItem> otherList = channel.getListMode(otherMode);
231 231
                             if (otherList == null) {
232 232
                                 parser.callErrorInfo(new ParserError(ParserError.ERROR_WARNING, "Got list mode: '" + otherMode + "' - but channel object doesn't agree.", parser.getLastLine()));

+ 1
- 1
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMessage.java View File

@@ -262,7 +262,7 @@ public class ProcessMessage extends IRCProcessor {
262 262
                 }
263 263
             }
264 264
         } else {
265
-            callDebugInfo(IRCParser.DEBUG_INFO, "Message for Other (" + token[2] + ')');
265
+            callDebugInfo(IRCParser.DEBUG_INFO, "Message for Other (%s)", token[2]);
266 266
             if ("PRIVMSG".equalsIgnoreCase(sParam)) {
267 267
                 if (isAction) {
268 268
                     callUnknownAction(date, sMessage, token[2], firstToken);

+ 4
- 8
irc/src/main/java/com/dmdirc/parser/irc/processors/ProcessMode.java View File

@@ -183,24 +183,20 @@ public class ProcessMode extends IRCProcessor {
183 183
                         return;
184 184
                     }
185 185
                     sModeParam = sModestr[nParam++];
186
-                    callDebugInfo(IRCParser.DEBUG_INFO, "User Mode: %c / %s {Positive: %b}",
187
-                            cMode, sModeParam, bPositive);
186
+                    callDebugInfo(IRCParser.DEBUG_INFO, "User Mode: %c / %s {Positive: %b}", cMode, sModeParam, bPositive);
188 187
                     final IRCChannelClientInfo iChannelClientInfo = iChannel.getChannelClient(sModeParam);
189 188
                     if (iChannelClientInfo == null) {
190 189
                         // Client not known?
191
-                        callDebugInfo(IRCParser.DEBUG_INFO, "User Mode for client not on channel." +
192
-                                " Ignoring (%s)", sModeParam);
190
+                        callDebugInfo(IRCParser.DEBUG_INFO, "User Mode for client not on channel. Ignoring (%s)", sModeParam);
193 191
                         continue;
194 192
                     }
195
-                    callDebugInfo(IRCParser.DEBUG_INFO, "\tOld Mode Value: %s",
196
-                            iChannelClientInfo.getAllModes());
193
+                    callDebugInfo(IRCParser.DEBUG_INFO, "\tOld Mode Value: %s", iChannelClientInfo.getAllModes());
197 194
                     if (bPositive) {
198 195
                         iChannelClientInfo.addMode(cMode);
199 196
                     } else {
200 197
                         iChannelClientInfo.removeMode(cMode);
201 198
                     }
202
-                    callChannelUserModeChanged(date, iChannel, iChannelClientInfo, setterCCI, token[0],
203
-                            (bPositive ? "+" : "-") + cMode);
199
+                    callChannelUserModeChanged(date, iChannel, iChannelClientInfo, setterCCI, token[0], (bPositive ? "+" : "-") + cMode);
204 200
                     continue;
205 201
                 } else {
206 202
                     // unknown mode - add as boolean

Loading…
Cancel
Save