This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 2cd3c6b620 Revert "Refactor AmbiguousBean test after seeing failures in CI" 2cd3c6b620 is described below commit 2cd3c6b620e9485694ed42e66896fa7f07885602 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Mar 31 00:09:16 2023 +0100 Revert "Refactor AmbiguousBean test after seeing failures in CI" This reverts commit ffb5ef2de0f161b2d4c1ca92452e478ef4fcc13b. JavaBeans has a fixed algorithm when mehtods appear to be ambiguous. This needs to be replicated in the standalone support --- test/jakarta/el/TestBeanSupport.java | 18 +++++++ test/jakarta/el/TestBeanSupportAmbiguous.java | 77 --------------------------- 2 files changed, 18 insertions(+), 77 deletions(-) diff --git a/test/jakarta/el/TestBeanSupport.java b/test/jakarta/el/TestBeanSupport.java index 1f87d37bec..0807a90dce 100644 --- a/test/jakarta/el/TestBeanSupport.java +++ b/test/jakarta/el/TestBeanSupport.java @@ -74,6 +74,15 @@ public class TestBeanSupport extends ELBaseTest { doTest(MismatchBean.class, "value", TypeA.class, TypeA.class, null); } + /* + * The first setter found "wins". + */ + @Test + public void testAmbiguousBean() { + doTest(AmbiguousBean.class, "value", TypeA.class, null, TypeA.class); + } + + private void doTest(Class<?> clazz, String propertyName, Class<?> type, Class<?> typeGet, Class<?> typeSet) { BeanProperties beanProperties = BeanSupport.getInstance().getBeanProperties(clazz); BeanProperty beanProperty = beanProperties.properties.get(propertyName); @@ -213,6 +222,15 @@ public class TestBeanSupport extends ELBaseTest { } + public static class AmbiguousBean { + public void setValue(@SuppressWarnings("unused") TypeA value) { + } + + public void setValue(@SuppressWarnings("unused") String value) { + } + } + + public static class TypeA { } diff --git a/test/jakarta/el/TestBeanSupportAmbiguous.java b/test/jakarta/el/TestBeanSupportAmbiguous.java deleted file mode 100644 index 2f19020063..0000000000 --- a/test/jakarta/el/TestBeanSupportAmbiguous.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package jakarta.el; - -import jakarta.el.BeanELResolver.BeanProperties; -import jakarta.el.BeanELResolver.BeanProperty; -import jakarta.el.TestBeanSupport.TypeA; - -import org.junit.Assert; -import org.junit.Test; - -public class TestBeanSupportAmbiguous { - - /* - * Different JREs appear to call different methods on AmbiguousBean. This test ensures that the behaviour is - * consistent across BeanSupport implementations within any single JRE, - */ - @Test - public void testAmbiguousBean() { - // Disable caching so we can switch implementations within a JVM instance. - System.setProperty("jakarta.el.BeanSupport.doNotCacheInstance", "true"); - - // First test the stand-alone type - System.setProperty("jakarta.el.BeanSupport.useStandalone", Boolean.TRUE.toString()); - Class<?> standaloneType = doTest(); - - // Then test the full JavaBeans implementation - System.setProperty("jakarta.el.BeanSupport.useStandalone", Boolean.FALSE.toString()); - Class<?> javaBeansType = doTest(); - - Assert.assertEquals(standaloneType, javaBeansType); - } - - - private Class<?> doTest() { - BeanProperties beanProperties = BeanSupport.getInstance().getBeanProperties(AmbiguousBean.class); - BeanProperty beanProperty = beanProperties.properties.get("value"); - - // Property type - Assert.assertNotNull(beanProperty); - Class<?> propertyType = beanProperty.getPropertyType(); - Assert.assertNotNull(propertyType); - - // There is no getter - Assert.assertNull(beanProperty.getReadMethod()); - - // Check setter - Assert.assertEquals(void.class, beanProperty.getWriteMethod().getReturnType()); - Assert.assertEquals(1, beanProperty.getWriteMethod().getParameterCount()); - Assert.assertEquals(propertyType, beanProperty.getWriteMethod().getParameterTypes()[0]); - - return propertyType; - } - - - public static class AmbiguousBean { - public void setValue(@SuppressWarnings("unused") TypeA value) { - } - - public void setValue(@SuppressWarnings("unused") String value) { - } - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org