-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
In main method:
- If number of parameters > 2, then a print usage is displayed.
if (args.length != 2) usage(); - However, if number of parameters == 2, then a null pointer is thrown
if (args[2].equals("once")) { return; }
Consequences:
- third parameter ("once") cannot be used
- An error will always be thrown
Here is a proposed modified main method:
-
When checking if arguments are well formated:
final String thirdArgumentExpectedValue = "once"; // parse arguments final boolean wrongNumberOfArguments = args.length != 2 && args.length != 3; final boolean thirdArgumentInWrongFormat = args.length >= 3 && !thirdArgumentExpectedValue.equals(args[2]); if (wrongNumberOfArguments || thirdArgumentInWrongFormat) usage();
-When checking presence of "once" third parameter
if (thirdArgumentExpectedValue.equals(args[2])) {
return;
}
Metadata
Metadata
Assignees
Labels
No labels