Skip to content

Commit c4ad41b

Browse files
author
Steve Powell
committed
Removed Appendable from generated code and reverted usage. Merged default back in.
2 parents 4c606d4 + 1c510c2 commit c4ad41b

File tree

3 files changed

+45
-39
lines changed

3 files changed

+45
-39
lines changed

codegen.py

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,21 @@ def java_field_name(name):
9595
def java_field_type(spec, domain):
9696
return javaTypeMap[spec.resolveDomain(domain)]
9797

98-
def java_field_default_value(type, value):
99-
if type == 'int':
98+
def java_field_default_value(jtype, value):
99+
if jtype == 'int':
100100
return value
101-
elif type == 'boolean':
102-
return "{0}".format(value).lower()
103-
elif type == 'String':
104-
return "\"{0}\"".format(value)
105-
elif type == 'LongString':
106-
return "LongStringHelper.asLongString(\"{0}\")".format(value)
107-
elif type == 'long':
108-
return "{0}L".format(value)
109-
elif type == 'Map<String,Object>':
101+
elif jtype == 'boolean':
102+
return ('%s'% (value)).lower()
103+
elif jtype == 'String':
104+
return '"%s"' % (value)
105+
elif jtype == 'LongString':
106+
return 'LongStringHelper.asLongString("%s")' % (value)
107+
elif jtype == 'long':
108+
return '%sL' % (value)
109+
elif jtype == 'Map<String,Object>':
110110
return "null"
111111
else:
112-
raise BogusDefaultValue("JSON provided default value {0} for suspicious type {1}".format(value, type))
112+
raise BogusDefaultValue("JSON provided default value %s for suspicious type %s" % (value, jtype))
113113

114114
def typeNameDefault(spec, a):
115115
fieldType = java_field_type(spec, a.domain)
@@ -266,20 +266,12 @@ def printWritePropertiesTo(c):
266266
print " }"
267267

268268
def printAppendArgumentDebugStringTo(c):
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)))
269+
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
270+
% (f.name, java_field_name(f.name))
277271
for f in c.fields ]
278272
print
279-
print " public void appendArgumentDebugStringTo(Appendable acc) {"
280-
print " try {"
281-
print " acc.append(\"(%s)\");" % (", ".join(appendList))
282-
print " } catch(IOException _) { }"
273+
print " public void appendArgumentDebugStringTo(StringBuilder acc) {"
274+
print " acc.append(\"(%s)\");" % (", ".join(appendList))
283275
print " }"
284276

285277
def printPropertiesBuilderClass(c):
@@ -485,21 +477,12 @@ def trueOrFalse(truthVal):
485477
return "false"
486478

487479
def argument_debug_string():
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))
480+
appendList = [ "%s=\")\n .append(this.%s)\n .append(\""
481+
% (a.name, java_field_name(a.name))
497482
for a in m.arguments ]
498483
print
499-
print " public void appendArgumentDebugStringTo(Appendable acc) {"
500-
print " try {"
501-
print " acc.append(\"(%s)\");" % ", ".join(appendList)
502-
print " } catch(IOException _) { }"
484+
print " public void appendArgumentDebugStringTo(StringBuilder acc) {"
485+
print " acc.append(\"(%s)\");" % ", ".join(appendList)
503486
print " }"
504487

505488
def write_arguments():

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import com.rabbitmq.client.QueueingConsumer;
3636
import com.rabbitmq.client.QueueingConsumer.Delivery;
3737

38-
import com.rabbitmq.client.Envelope;
39-
4038
public class QosTests extends BrokerTestCase
4139
{
4240

test/src/com/rabbitmq/client/test/server/DurableBindingLifecycle.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ protected void restart() throws IOException {
4646

4747
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
4848
}
49+
restartPrimary();
50+
}
51+
52+
private void restartPrimary() throws IOException {
4953
tearDown();
5054
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
5155
setUp();
@@ -129,5 +133,26 @@ public void testDefaultBindingRecovery() throws IOException {
129133
deleteQueue(Q);
130134
}
131135

136+
/**
137+
* Test that when we have a transient exchange bound to a durable
138+
* queue and the durable queue is on a cluster node that restarts,
139+
* we do not lose the binding. See bug 24009.
140+
*/
141+
public void testTransientExchangeDurableQueue() throws IOException {
142+
// This test depends on the second node in the cluster to keep
143+
// the transient X alive
144+
if (clusteredConnection != null) {
145+
channel.exchangeDeclare("transientX", "fanout", false);
146+
channel.queueDeclare("durableQ", true, false, false, null);
147+
channel.queueBind("durableQ", "transientX", "");
132148

149+
restartPrimary();
150+
151+
basicPublishVolatile("transientX", "");
152+
assertDelivered("durableQ", 1);
153+
154+
deleteExchange("transientX");
155+
deleteQueue("durableQ");
156+
}
157+
}
133158
}

0 commit comments

Comments
 (0)