Issue 1:
Andreas Loew opened SPR-5026 and commented

Summary:

When creating the underlying physical JMS connection, SingleConnectionFactory should call the appropriate createXXXConnection method properly reflecting the type of the target XXXConnectionFactory:

for a target QueueConnectionFactory, call createQueueConnection()

for a target TopicConnectionFactory, call createTopicConnection()

for a target ConnectionFactory, call createTopicConnection()

Details:

The exception I get looks like the following:

22.07.2008 12:14:52 org.springframework.jms.connection.SingleConnectionFactory initConnection

INFO: Established shared JMS Connection: com.spirit.wave.jms.WaveConnection@e79839

Exception in thread "main" javax.jms.IllegalStateException: This SingleConnectionFactory does not hold a QueueConnection but rather: com.spirit.wave.jms.WaveConnection@e79839

at org.springframework.jms.connection.SingleConnectionFactory.createQueueConnection(SingleConnectionFactory.java:229)

at testcase.MessageRequestor.main(MessageRequestor.java:47)

But my targetConnectionFactory indeed is a JMS 1.1-compliant com.spirit.wave.jms.WaveQueueConnectionFactory.

The real root cause for seeing this issue is that, with "my" JMS provider, calling qcf.createConnection() on a WaveQueueConnectionFactory instance qcf only creates a WaveConnection (which only implements connection, but not QueueConnection), but calling qcf.createQueueConnection() creates a WaveQueueConnection (which implements both).

I would propose to fix this with the following if ... then ... else in SingleConnectionFactory#doCreateConnection() that ensures that the appropriate create method is being called:

protected Connection doCreateConnection() throws JMSException {
ConnectionFactory connfac = getTargetConnectionFactory();
Connection conn = null;
if (connfac instanceof QueueConnectionFactory) {
conn = ((QueueConnectionFactory) connfac).createQueueConnection();
} else if (connfac instanceof TopicConnectionFactory) {
conn = ((TopicConnectionFactory) connfac).createTopicConnection();
} else {
conn = connfac.createConnection();
}
return conn;
}

I do perfectly know that a SingleConnectionFactory102 exists which properly handles this, but (a) my provider is JMS 1.1 compliant and (b) I would rather like to use CachedConnectionFactory (not directly SingleConnectionFactory).

I admit that, if you prefer, this issue could also be resolved by adding a CachedConnectionFactory102 that extends SingleConnectionFactory102.

Many thanks for considering this fix for the Spring 2.5.x series! :-)

Best regards,

Andreas

Affects: 2.5.3, 2.5.4, 2.5.5

Issue 2:
Josef Vychtrle opened SPR-8600 and commented

There are two major means of data binding initialization, but there is a drawback in the oldschool xml one.

In short, you can do this :

@InitBinder("order")public void initBinder(WebDataBinder binder) {
binder.setAllowedFields(allowedFields.split(","));
}

but it can't be done with ConfigurableWebBindingInitializer. First off, the binder instance is created in AnnotationMethodHandlerAdapter and initializer is passed the binder instance somewhere in HandlerMethodInvoker so it can't be set up... :

<bean id="webBindingInitializer" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="messageCodesResolver" ref="codesResolver" />
<!-- missing allowed / disallowed / required properties -->
</bean>

FIX :ConfigurableWebBindingInitializer.java

public void initBinder(WebDataBinder binder, WebRequest request) {if(this.allowedFields != null) {
binder.setAllowedFields(allowedFields);
}
if(this.disallowedFields != null) {
binder.setDisallowedFields(disallowedFields);
}
if(this.allowedFields != null) {
binder.setRequiredFields(requiredFields);
}
if (this.directFieldAccess) {
binder.initDirectFieldAccess();
}if (this.messageCodesResolver != null) {
binder.setMessageCodesResolver(this.messageCodesResolver);
}if (this.bindingErrorProcessor != null) {
binder.setBindingErrorProcessor(this.bindingErrorProcessor);
}if (this.validator != null && binder.getTarget() != null &&this.validator.supports(binder.getTarget().getClass())) {
binder.setValidator(this.validator);
}if (this.conversionService != null) {
binder.setConversionService(this.conversionService);
}if (this.propertyEditorRegistrars != null) {for (PropertyEditorRegistrar propertyEditorRegistrar : this.propertyEditorRegistrars) {
propertyEditorRegistrar.registerCustomEditors(binder);
}
}
}

Affects: 3.1 M2

Reference URL: http://stackoverflow.com/q/7014245/306488

Issue Links:

#13245 ConfigurableWebBindingInitializer should have allowed / disallowed / required fields for DataBinder initialization ("is duplicated by")