You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/10/18 15:14:00 UTC
[jira] [Commented] (COLLECTIONS-863) Bug - comparators.FixedOrderComparator.setUnknownObjectBehavior(UnknownObjectBehavior)
[ https://issues.apache.org/jira/browse/COLLECTIONS-863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17890984#comment-17890984 ]
Gary D. Gregory commented on COLLECTIONS-863:
---------------------------------------------
[~ferra]
The test you include:
public void testSetUnknownObjectBehavior_NullPointerException_UnknownObjectBehaviorIsNull() throws Throwable {
FixedOrderComparator<Object> fixedOrderComparator0 = new FixedOrderComparator<Object>();
FixedOrderComparator.UnknownObjectBehavior fixedOrderComparator_UnknownObjectBehavior0 = FixedOrderComparator.UnknownObjectBehavior.BEFORE;
fixedOrderComparator0.setUnknownObjectBehavior(fixedOrderComparator_UnknownObjectBehavior0);
try {
fixedOrderComparator0.setUnknownObjectBehavior((FixedOrderComparator.UnknownObjectBehavior) null);
org.junit.Assert.fail();
} catch (UnsupportedOperationException e) \{
}
}
This does not make sense, it fails, when the behavior correct. The code already checks for null input and throws an NPE.
A test calls `assertThrows()` to validate that an exception is thrown.
Why would you catch and ignore UnsupportedOperationException?
Is this AI or machine generated slop?
Closing.
> Bug - comparators.FixedOrderComparator.setUnknownObjectBehavior(UnknownObjectBehavior)
> --------------------------------------------------------------------------------------
>
> Key: COLLECTIONS-863
> URL: https://issues.apache.org/jira/browse/COLLECTIONS-863
> Project: Commons Collections
> Issue Type: Bug
> Reporter: Daniele
> Priority: Minor
>
> *comparators.FixedOrderComparator.setUnknownObjectBehavior(UnknownObjectBehavior):*
> UnsupportedOperationException is raised instead of the specified NullPointerException for "null" parameter.
> *Test Used:*
> {code:java}
> public class FixedOrderComparator_5_failure_Test{
>
> public void testSetUnknownObjectBehavior_NullPointerException_UnknownObjectBehaviorIsNull() throws Throwable {
> FixedOrderComparator<Object> fixedOrderComparator0 = new FixedOrderComparator<Object>();
> FixedOrderComparator.UnknownObjectBehavior fixedOrderComparator_UnknownObjectBehavior0 = FixedOrderComparator.UnknownObjectBehavior.BEFORE;
> fixedOrderComparator0.setUnknownObjectBehavior(fixedOrderComparator_UnknownObjectBehavior0);
> try {
> fixedOrderComparator0.setUnknownObjectBehavior((FixedOrderComparator.UnknownObjectBehavior) null);
> org.junit.Assert.fail();
> } catch (UnsupportedOperationException e) {
> }
> }
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)