Skip to content

Commit 7510ff9

Browse files
committed
server: Catching more specific exception and improving the warning message
1 parent 16fac79 commit 7510ff9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

java/server/src/org/openqa/grid/common/RegistrationRequest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class RegistrationRequest {
6262

6363
private String[] args;
6464

65-
private static final Logger log = Logger.getLogger(RegistrationRequest.class.getName());
65+
private static final Logger LOG = Logger.getLogger(RegistrationRequest.class.getName());
6666

6767
// some special param for capability
6868
public static final String APP = "applicationName";
@@ -195,8 +195,10 @@ public int getConfigAsInt(String param, int defaultValue) {
195195
}
196196
try {
197197
return Integer.parseInt(o.toString());
198-
} catch (Throwable t) {
199-
log.warning("Error. " + param + " is supposed to be an int. Keeping default of " + defaultValue);
198+
} catch (NumberFormatException t) {
199+
LOG.warning(String.format(
200+
"Parameter %s has value '%s', but it is supposed to be an int. Keeping default of %s",
201+
param, o, defaultValue));
200202
return defaultValue;
201203
}
202204

@@ -321,7 +323,7 @@ private static RegistrationRequest parseGrid1Request(String clientRequest) {
321323
registrationInfo.put(URLDecoder.decode(configItem[0], "UTF-8"),
322324
URLDecoder.decode(configItem[1], "UTF-8"));
323325
} catch (UnsupportedEncodingException e) {
324-
log.warning(String.format("Unable to decode registration request portion: %s", part));
326+
LOG.warning(String.format("Unable to decode registration request portion: %s", part));
325327
}
326328
}
327329

@@ -499,7 +501,7 @@ private void loadFromCommandLine(String[] args) {
499501
}
500502

501503
private DesiredCapabilities addCapabilityFromString(String capability) {
502-
log.info("Adding " + capability);
504+
LOG.info("Adding " + capability);
503505
String[] s = capability.split(",");
504506
if (s.length == 0) {
505507
throw new GridConfigurationException("-browser must be followed by a browser description");

0 commit comments

Comments
 (0)