parseParams throws exception on bad formatting, and its perfectly valid to have params with 0 values (e.g. DEST GENERATE\n)

This commit is contained in:
jrandom
2004-05-04 01:35:09 +00:00
committed by zzz
parent 5aa680fc93
commit 141902b86d
2 changed files with 6 additions and 9 deletions

View File

@ -108,9 +108,10 @@ public class SAMUtils {
*
* @param tok A StringTokenizer pointing to the SAM parameters
*
* @return Properties with the parsed SAM params, or null if none is found
* @throws SAMException if the data was formatted incorrectly
* @return Properties with the parsed SAM params
*/
public static Properties parseParams(StringTokenizer tok) {
public static Properties parseParams(StringTokenizer tok) throws SAMException {
int pos, nprops = 0, ntoks = tok.countTokens();
String token, param, value;
Properties props = new Properties();
@ -121,7 +122,7 @@ public class SAMUtils {
pos = token.indexOf("=");
if (pos == -1) {
_log.debug("Error in params format");
return null;
throw new SAMException("Bad formatting for param [" + token + "]");
}
param = token.substring(0, pos);
value = token.substring(pos + 1);
@ -134,11 +135,7 @@ public class SAMUtils {
_log.debug("Parsed properties: " + dumpProperties(props));
}
if (nprops != 0) {
return props;
} else {
return null;
}
return props;
}
/* Dump a Properties object in an human-readable form */

View File

@ -281,7 +281,7 @@ public class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatag
private boolean execDestMessage(String opcode, Properties props) {
if (opcode.equals("GENERATE")) {
if (props != null) {
if (props.size() > 0) {
_log.debug("Properties specified in DEST GENERATE message");
return false;
}