You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stian Soiland-Reyes (JIRA)" <ji...@apache.org> on 2016/09/12 16:31:20 UTC
[jira] [Commented] (BEANUTILS-496) testGetDescriptorInvalidBoolean
fails on Java 9
[ https://issues.apache.org/jira/browse/BEANUTILS-496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15484562#comment-15484562 ]
Stian Soiland-Reyes commented on BEANUTILS-496:
-----------------------------------------------
It's testing:
{code}
/**
* <p>Negative tests on an invalid property with two different boolean
* getters (which is fine, according to the JavaBeans spec) but a
* String setter instead of a boolean setter.</p>
*
* <p>Although one could logically argue that this combination of method
* signatures should not identify a property at all, there is a sentence
* in Section 8.3.1 making it clear that the behavior tested for here
* is correct: "If we find only one of these methods, then we regard
* it as defining either a read-only or write-only property called
* <em><property-name></em>.</p>
*/
public void testGetDescriptorInvalidBoolean() throws Exception {
final PropertyDescriptor pd =
PropertyUtils.getPropertyDescriptor(bean, "invalidBoolean");
assertNotNull("invalidBoolean is a property", pd);
assertNotNull("invalidBoolean has a getter method",
pd.getReadMethod());
assertNull("invalidBoolean has no write method",
pd.getWriteMethod());
assertTrue("invalidBoolean getter method is isInvalidBoolean",
"isInvalidBoolean".equals(pd.getReadMethod().getName()));
}
{code}
with TestBean having
{code}
/**
* <p>An invalid property that has two boolean getters (getInvalidBoolean
* and isInvalidBoolean) plus a String setter (setInvalidBoolean). By the
* rules described in the JavaBeans Specification, this will be considered
* a read-only boolean property, using isInvalidBoolean() as the getter.</p>
*/
private boolean invalidBoolean = false;
public boolean getInvalidBoolean() {
return (this.invalidBoolean);
}
public boolean isInvalidBoolean() {
return (this.invalidBoolean);
}
public void setInvalidBoolean(final String invalidBoolean) {
if ("true".equalsIgnoreCase(invalidBoolean) ||
"yes".equalsIgnoreCase(invalidBoolean) ||
"1".equalsIgnoreCase(invalidBoolean)) {
this.invalidBoolean = true;
} else {
this.invalidBoolean = false;
}
}
{code}
This assumption seems to no longer be true in Java 9 - I don't think we can assume that {{isInvalidBoolean}} will be preferred method, so I'll change it to:
{code}
assertTrue("invalidBoolean getter method is isInvalidBoolean or getInvalidBoolean",
Arrays.asList("isInvalidBoolean", "getInvalidBoolean")
.contains(pd.getReadMethod().getName()));
{code}
> testGetDescriptorInvalidBoolean fails on Java 9
> -----------------------------------------------
>
> Key: BEANUTILS-496
> URL: https://issues.apache.org/jira/browse/BEANUTILS-496
> Project: Commons BeanUtils
> Issue Type: Bug
> Components: Bean / Property Utils
> Affects Versions: 1.9.3
> Environment: OpenJDK 9, Ubuntu 16.04
> Reporter: Stian Soiland-Reyes
> Assignee: Stian Soiland-Reyes
> Priority: Minor
>
> {code}
> PropertyUtilsTestCase.testGetDescriptorInvalidBoolean:442 invalidBoolean getter method is isInvalidBoolean
> {code}
> Seems only to fail on JAva 9?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)