[ https://issues.apache.org/jira/browse/MSHARED-1290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17778395#comment-17778395 ]
ASF GitHub Bot commented on MSHARED-1290: ----------------------------------------- elharo commented on code in PR #78: URL: https://github.com/apache/maven-filtering/pull/78#discussion_r1367913545 ########## src/test/java/org/apache/maven/shared/filtering/PropertyUtilsTest.java: ########## @@ -143,32 +140,59 @@ public void testCircularReferences3Vars() throws IOException { } basicProp.createNewFile(); - try (FileWriter writer = new FileWriter(basicProp)) { + try (Writer writer = new OutputStreamWriter(new FileOutputStream(basicProp), StandardCharsets.UTF_8)) { writer.write("test=${test2}\n"); writer.write("test2=${test3}\n"); writer.write("test3=${test}\n"); writer.flush(); } Logger logger = mock(Logger.class); - Properties prop = PropertyUtils.loadPropertyFile(basicProp, null, logger); assertEquals("${test2}", prop.getProperty("test")); assertEquals("${test3}", prop.getProperty("test2")); assertEquals("${test}", prop.getProperty("test3")); - assertWarn( - logger, - "Circular reference between properties detected: test3 => test => test2 => test3", - "Circular reference between properties detected: test2 => test3 => test => test2", - "Circular reference between properties detected: test => test2 => test3 => test"); } - private void assertWarn(Logger mock, String... expected) { - ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class); - verify(mock, times(expected.length)).warn(argument.capture()); - List<String> messages = argument.getAllValues(); - for (String str : expected) { - assertTrue(messages.contains(str)); + public void testNonCircularReferences1Var3Times() throws IOException { + File basicProp = new File(testDirectory, "non-circular.properties"); Review Comment: use File.createTempFile and delete it in a finally block > PropertyUtils cycle detection results in false positives > -------------------------------------------------------- > > Key: MSHARED-1290 > URL: https://issues.apache.org/jira/browse/MSHARED-1290 > Project: Maven Shared Components > Issue Type: Bug > Components: maven-filtering > Affects Versions: maven-filtering-3.2.0, maven-filtering-3.3.0, > maven-filtering-3.3.1 > Reporter: Wouter Born > Priority: Major > > I upgraded the maven-assembly-plugin in one of my projects from 2.6 to 3.6.0 > and found that {{PropertyUtils}} was logging many false positives about > cycles between properties. > The cycle detection (introduced for MSHARED-417) reports false positives when > a variable occurs multiple times in a property, example: > {code:java} > depends=p1 >= ${version}, p2 >= ${version}, p3 >= ${version} > version=1.2.3 {code} > While writing a unit test to fix this, I also found that there are also cycle > false positives whenever one of the property values is the same as a property > name, example: > {code:java} > test1=${test2} > test2=${test3} > test3=test2{code} -- This message was sent by Atlassian Jira (v8.20.10#820010)