[jboss-jira] [JBoss JIRA] (WFLY-1364) Numerical properties of @DataSourceDefinition not correctly processed.

arjan tijms (JIRA) jira-events at lists.jboss.org
Fri May 17 17:39:06 EDT 2013


arjan tijms created WFLY-1364:
---------------------------------

             Summary: Numerical properties of @DataSourceDefinition not correctly processed.
                 Key: WFLY-1364
                 URL: https://issues.jboss.org/browse/WFLY-1364
             Project: WildFly
          Issue Type: Bug
          Components: EE
            Reporter: arjan tijms
            Assignee: David Lloyd


When using the {{<data-source>}} element in e.g. {{web.xml}} or {{application.xml}}, numerical properties (such as {{<port-number>}}) are not processed correctly.

With many data sources, e.g. the one from the Postgres JDBC driver, those properties are not set at all.

The problem seems to be with {{org.jboss.as.connector.deployers.datasource.DirectDataSourceInjectionSource}}. In the method {{populateProperties}} those values are passed as an {{Integer}}:

{code}
setProperty(
    deploymentReflectionIndex, dataSourceClass, properties, 
    PORT_NUMBER_PROP, Integer.valueOf(portNumber)
);
{code}

The type of this value is subsequently used to locate a setter method for the corresponding property from the data source:

{code}
// [...]
String methodName = builder.toString();
Class<?> paramType = value.getClass();
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, paramType);
Method setterMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, dataSourceClass, methodIdentifier);

if (setterMethod != null) {
    properties.put(name, value.toString());
}
{code}

The problem is that many data source implementations have a setter that takes a primitive int, and not an {{Integer}}. There will thus be no setter method found that takes an {{Integer}}. This code will then skip the property.

Down the line, when it's time to actually set the properties on the data source instance the code is written in such a way that the int/Integer distinction wouldn't matter anymore:

XAManagedConnectionFactory#createXaDataSource
{code}
Method getter = clazz.getMethod("get" + name, noClasses);
type = getter.getReturnType();

// [...]

Method setter = clazz.getMethod("set" + name, new Class<?>[]{type});
PropertyEditor editor = PropertyEditorManager.findEditor(type);

// [..]

editor.setAsText(value);
setter.invoke(xads, new Object[]{editor.getValue()});
{code}

However, at that point the numerical properties have already been removed from the properties collection because of the failing test shown above.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list