Skip to content

Commit 0d5c063

Browse files
author
Steve Powell
committed
Merge in default
2 parents 80db3ba + bb55960 commit 0d5c063

26 files changed

+1797
-472
lines changed

src/com/rabbitmq/client/AlreadyClosedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.rabbitmq.client;
1919

20-
/*
20+
/**
2121
* Thrown when application tries to perform an action on connection/channel
2222
* which was already closed
2323
*/

src/com/rabbitmq/client/impl/DefaultExceptionHandler.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
import java.io.IOException;
2020

2121
import com.rabbitmq.client.AMQP;
22+
import com.rabbitmq.client.AlreadyClosedException;
2223
import com.rabbitmq.client.Channel;
2324
import com.rabbitmq.client.Connection;
2425
import com.rabbitmq.client.Consumer;
2526

27+
/**
28+
* Default implementation of {@link ExceptionHandler} used by {@link AMQConnection}.
29+
*/
2630
public class DefaultExceptionHandler implements ExceptionHandler {
2731
public void handleUnexpectedConnectionDriverException(Connection conn, Throwable exception) {
2832
// TODO: Log this somewhere, just in case we have a bug like
@@ -55,23 +59,21 @@ public void handleConsumerException(Channel channel, Throwable exception,
5559
+ " for channel " + channel);
5660
}
5761

58-
protected void handleChannelKiller(Channel channel,
59-
Throwable exception,
60-
String what)
61-
{
62-
// TODO: Convert to logging framework
63-
System.err.println(what + " threw an exception for channel " +
64-
channel + ":");
62+
protected void handleChannelKiller(Channel channel, Throwable exception, String what) {
63+
// TODO: log the exception
64+
System.err.println("DefaultExceptionHandler: " + what + " threw an exception for channel "
65+
+ channel + ":");
6566
exception.printStackTrace();
6667
try {
67-
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR,
68-
"Internal error in " + what,
69-
false,
70-
exception);
68+
channel.close(AMQP.REPLY_SUCCESS, "Closed due to exception from " + what);
69+
} catch (AlreadyClosedException ace) {
70+
// noop
7171
} catch (IOException ioe) {
72-
// Man, this clearly isn't our day.
73-
// Ignore the exception? TODO: Log the nested failure
72+
// TODO: log the failure
73+
System.err.println("Failure during close of channel " + channel + " after " + exception
74+
+ ":");
75+
ioe.printStackTrace();
76+
channel.getConnection().abort(AMQP.INTERNAL_ERROR, "Internal error closing channel for " + what);
7477
}
75-
7678
}
7779
}

src/com/rabbitmq/tools/json/JSONReader.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,22 @@ private char next() {
5959
}
6060

6161
private void skipWhiteSpace() {
62-
while (Character.isWhitespace(c)) {
63-
next();
64-
}
62+
boolean cont;
63+
64+
do {
65+
cont = true;
66+
if (Character.isWhitespace(c)) {
67+
next();
68+
}
69+
else if (c == '/' && next() == '/') {
70+
while (c != '\n') {
71+
next();
72+
}
73+
}
74+
else {
75+
cont = false;
76+
}
77+
} while (cont);
6578
}
6679

6780
public Object read(String string) {
@@ -74,7 +87,7 @@ private Object read() {
7487
Object ret = null;
7588
skipWhiteSpace();
7689

77-
if (c == '"') {
90+
if (c == '"' || c == '\'') {
7891
next();
7992
ret = string();
8093
} else if (c == '[') {
@@ -168,7 +181,7 @@ private Object number() {
168181

169182
private Object string() {
170183
buf.setLength(0);
171-
while (c != '"') {
184+
while (c != '"' && c != '\'') {
172185
if (c == '\\') {
173186
next();
174187
if (c == 'u') {

0 commit comments

Comments
 (0)