mirror of https://github.com/apache/activemq.git
improved null handling after suggestions from Danielius Jurna
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@399999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b29f744014
commit
ac13202007
|
@ -34,15 +34,20 @@ class CommandParser {
|
|||
}
|
||||
|
||||
Command parse(DataInput in) throws IOException, JMSException {
|
||||
String line;
|
||||
|
||||
String line = null;
|
||||
|
||||
// skip white space to next real line
|
||||
try {
|
||||
while ((line = in.readLine()).trim().length() == 0) {
|
||||
while (true) {
|
||||
line = in.readLine();
|
||||
if (line == null) {
|
||||
throw new IOException("connection was closed");
|
||||
}
|
||||
else {
|
||||
line = line.trim();
|
||||
if (line.length() > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
throw new IOException("connection was closed");
|
||||
}
|
||||
|
||||
// figure correct command and return it
|
||||
|
|
|
@ -32,28 +32,38 @@ class HeaderParser {
|
|||
*/
|
||||
Properties parse(BufferedReader in) throws IOException {
|
||||
Properties props = new Properties();
|
||||
String line;
|
||||
while (((line = in.readLine()).trim().length() > 0)) {
|
||||
int seperator_index = line.indexOf(Stomp.Headers.SEPERATOR);
|
||||
String name = line.substring(0, seperator_index).trim();
|
||||
String value = line.substring(seperator_index + 1, line.length()).trim();
|
||||
props.setProperty(name, value);
|
||||
while (true) {
|
||||
String line = in.readLine();
|
||||
if (line != null && line.trim().length() > 0) {
|
||||
int seperator_index = line.indexOf(Stomp.Headers.SEPERATOR);
|
||||
String name = line.substring(0, seperator_index).trim();
|
||||
String value = line.substring(seperator_index + 1, line.length()).trim();
|
||||
props.setProperty(name, value);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
Properties parse(DataInput in) throws IOException {
|
||||
Properties props = new Properties();
|
||||
String line;
|
||||
while (((line = in.readLine()).trim().length() > 0)) {
|
||||
try {
|
||||
int seperator_index = line.indexOf(Stomp.Headers.SEPERATOR);
|
||||
String name = line.substring(0, seperator_index).trim();
|
||||
String value = line.substring(seperator_index + 1, line.length()).trim();
|
||||
props.setProperty(name, value);
|
||||
while (true) {
|
||||
String line = in.readLine();
|
||||
if (line != null && line.trim().length() > 0) {
|
||||
try {
|
||||
int seperator_index = line.indexOf(Stomp.Headers.SEPERATOR);
|
||||
String name = line.substring(0, seperator_index).trim();
|
||||
String value = line.substring(seperator_index + 1, line.length()).trim();
|
||||
props.setProperty(name, value);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ProtocolException("Unable to parser header line [" + line + "]");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ProtocolException("Unable to parser header line [" + line + "]");
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return props;
|
||||
|
|
Loading…
Reference in New Issue