Skip to content

Commit 51ef944

Browse files
author
Steve Powell
committed
Corrected breakage from bug23451 changes.
2 parents 3d6fc5d + 38a5d88 commit 51ef944

File tree

8 files changed

+37
-21
lines changed

8 files changed

+37
-21
lines changed

codegen.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,20 @@ def printWritePropertiesTo(c):
266266
print " }"
267267

268268
def printAppendArgumentDebugStringTo(c):
269-
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
270-
% (f.name, java_field_name(f.name))
269+
def appendValue(jField, jType):
270+
if jType == "String":
271+
return "this.%s" % (jField)
272+
else:
273+
return "String.valueOf(this.%s)" % (jField)
274+
275+
appendList = [ "%s=\")\n .append(%s)\n .append(\""
276+
% (f.name, appendValue(java_field_name(f.name), java_field_type(spec, f.domain)))
271277
for f in c.fields ]
272278
print
273-
print " public void appendArgumentDebugStringTo(StringBuffer acc) {"
274-
print " acc.append(\"(%s)\");" % (", ".join(appendList))
279+
print " public void appendArgumentDebugStringTo(Appendable acc) {"
280+
print " try {"
281+
print " acc.append(\"(%s)\");" % (", ".join(appendList))
282+
print " } catch(IOException _) { }"
275283
print " }"
276284

277285
def printPropertiesBuilderClass(c):
@@ -477,12 +485,21 @@ def trueOrFalse(truthVal):
477485
return "false"
478486

479487
def argument_debug_string():
480-
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
481-
% (a.name, java_field_name(a.name))
488+
def appendFieldValue(a):
489+
(jName, jType) = (java_field_name(a.name), java_field_type(spec, a.domain))
490+
if jType == "String":
491+
return "this.%s" % (jName)
492+
else:
493+
return "String.valueOf(this.%s)" % (jName)
494+
495+
appendList = [ "%s=\")\n .append(%s)\n .append(\""
496+
% (a.name, appendFieldValue(a))
482497
for a in m.arguments ]
483498
print
484-
print " public void appendArgumentDebugStringTo(StringBuffer acc) {"
485-
print " acc.append(\"(%s)\");" % ", ".join(appendList)
499+
print " public void appendArgumentDebugStringTo(Appendable acc) {"
500+
print " try {"
501+
print " acc.append(\"(%s)\");" % ", ".join(appendList)
502+
print " } catch(IOException _) { }"
486503
print " }"
487504

488505
def write_arguments():

src/com/rabbitmq/client/ContentHeader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ public interface ContentHeader extends Cloneable {
3838
* A debugging utility - enable properties to be appended to a string buffer for use as trace messages.
3939
* @param buffer a place to append the properties as a string
4040
*/
41-
public void appendPropertyDebugStringTo(StringBuffer buffer);
41+
public void appendPropertyDebugStringTo(Appendable buffer);
4242
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ private void writeTo(DataOutputStream out, long bodySize) throws IOException {
5858
public abstract void writePropertiesTo(ContentHeaderPropertyWriter writer) throws IOException;
5959

6060
/** Public API - {@inheritDoc} */
61-
public void appendPropertyDebugStringTo(StringBuffer acc) {
62-
acc.append("(?)");
61+
public void appendPropertyDebugStringTo(Appendable acc) {
62+
try { acc.append("(?)"); } catch(IOException ioe) { }
6363
}
6464

6565
@Override public String toString() {
66-
StringBuffer sb = new StringBuffer();
66+
StringBuilder sb = new StringBuilder();
6767
sb.append("#contentHeader<").append(getClassName()).append(">");
6868
this.appendPropertyDebugStringTo(sb);
6969
return sb.toString();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public DataOutputStream getOutputStream() {
240240
}
241241

242242
@Override public String toString() {
243-
StringBuffer sb = new StringBuffer();
243+
StringBuilder sb = new StringBuilder();
244244
sb.append("Frame(type=").append(type).append(", channel=").append(channel).append(", ");
245245
if (accumulator == null) {
246246
sb.append(payload.length).append(" bytes of payload)");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public abstract class Method implements com.rabbitmq.client.Method {
6363
* Public API - debugging utility
6464
* @param buffer the buffer to append debug data to
6565
*/
66-
public void appendArgumentDebugStringTo(StringBuffer buffer) {
67-
buffer.append("(?)");
66+
public void appendArgumentDebugStringTo(Appendable buffer) {
67+
try { buffer.append("(?)");} catch(IOException ioe) { }
6868
}
6969

7070
@Override public String toString() {
71-
StringBuffer sb = new StringBuffer();
71+
StringBuilder sb = new StringBuilder();
7272
sb.append("#method<").append(protocolMethodName()).append(">");
7373
this.appendArgumentDebugStringTo(sb);
7474
return sb.toString();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class JSONReader {
5151
private CharacterIterator it;
5252
private char c;
5353
private Object token;
54-
private StringBuffer buf = new StringBuffer();
54+
private StringBuilder buf = new StringBuilder();
5555

5656
private char next() {
5757
c = it.next();

test/src/com/rabbitmq/client/test/functional/Tables.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public void testTypes() throws IOException {
5353
table.put("t", true);
5454
table.put("x", "byte".getBytes());
5555
table.put("V", null);
56-
@SuppressWarnings("rawtypes")
57-
List fieldArray = new ArrayList();
56+
List<Object> fieldArray = new ArrayList<Object>();
5857
fieldArray.add(LongStringHelper.asLongString("foo"));
5958
fieldArray.add(123);
6059
table.put("A", fieldArray);

test/src/com/rabbitmq/tools/Host.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public class Host {
2727
private static String capture(InputStream is)
2828
throws IOException
2929
{
30-
final BufferedReader br = new BufferedReader(new InputStreamReader(is));
30+
BufferedReader br = new BufferedReader(new InputStreamReader(is));
3131
String line;
32-
final StringBuffer buff = new StringBuffer();
32+
StringBuilder buff = new StringBuilder();
3333
while ((line = br.readLine()) != null) {
3434
buff.append(line);
3535
}

0 commit comments

Comments
 (0)