Skip to content

Commit 38a5d88

Browse files
author
Steve Powell
committed
Merge multiple heads on bug23912.
2 parents 0db1081 + 137b32b commit 38a5d88

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

codegen.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,19 @@ def printAppendArgumentDebugStringTo(c):
293293
def optionalValueClause(jField, jType):
294294
if jType in java_scalar_types:
295295
return "this.%sIsSet ? String.valueOf(this.%s) : \"unset\"" % (jField, jField)
296-
else:
296+
elif jType == "String":
297297
return "this.%s" % (jField)
298+
else:
299+
return "String.valueOf(this.%s)" % (jField)
298300

299301
appendList = [ "%s=\")\n .append(%s)\n .append(\""
300302
% (f.name, optionalValueClause(java_field_name(f.name), java_field_type(spec, f.domain)))
301303
for f in c.fields ]
302304
print
303-
print " public void appendArgumentDebugStringTo(StringBuilder acc) {"
304-
print " acc.append(\"(%s)\");" % (", ".join(appendList))
305+
print " public void appendArgumentDebugStringTo(Appendable acc) {"
306+
print " try {"
307+
print " acc.append(\"(%s)\");" % (", ".join(appendList))
308+
print " } catch(IOException _) { }"
305309
print " }"
306310

307311
def printPropertiesBuilderClass(c):
@@ -521,12 +525,21 @@ def trueOrFalse(truthVal):
521525
return "false"
522526

523527
def argument_debug_string():
524-
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
525-
% (a.name, java_field_name(a.name))
528+
def appendFieldValue(a):
529+
(jName, jType) = (java_field_name(a.name), java_field_type(spec, a.domain))
530+
if jType == "String":
531+
return "this.%s" % (jName)
532+
else:
533+
return "String.valueOf(this.%s)" % (jName)
534+
535+
appendList = [ "%s=\")\n .append(%s)\n .append(\""
536+
% (a.name, appendFieldValue(a))
526537
for a in m.arguments ]
527538
print
528-
print " public void appendArgumentDebugStringTo(StringBuilder acc) {"
529-
print " acc.append(\"(%s)\");" % ", ".join(appendList)
539+
print " public void appendArgumentDebugStringTo(Appendable acc) {"
540+
print " try {"
541+
print " acc.append(\"(%s)\");" % ", ".join(appendList)
542+
print " } catch(IOException _) { }"
530543
print " }"
531544

532545
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(StringBuilder buffer);
41+
public void appendPropertyDebugStringTo(Appendable buffer);
4242
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ 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(StringBuilder acc) {
62-
acc.append("(?)");
61+
public void appendPropertyDebugStringTo(Appendable acc) {
62+
try { acc.append("(?)"); } catch(IOException ioe) { }
6363
}
6464

6565
@Override public String toString() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ 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(StringBuilder buffer) {
67-
buffer.append("(?)");
66+
public void appendArgumentDebugStringTo(Appendable buffer) {
67+
try { buffer.append("(?)");} catch(IOException ioe) { }
6868
}
6969

7070
@Override public String toString() {

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 StringBuilder buff = new StringBuilder();
32+
StringBuilder buff = new StringBuilder();
3333
while ((line = br.readLine()) != null) {
3434
buff.append(line);
3535
}

0 commit comments

Comments
 (0)