GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug: duplicate --config key reported but value shown · Issue #1308 · junit-team/junit-framework

Bug: duplicate --config key reported but value shown #1308

New issue
Copy link
New issue
Copy link
Closed
Closed
Bug: duplicate --config key reported but value shown#1308
Copy link
Assignees
sormuras
Labels
component: Platformtheme: modules
Milestone
5.2 M1

Description

@robstoll
robstoll
opened on Feb 24, 2018
Issue body actions

Overview

I am using the platform-version 1.0.2. The bug happens when I use the ConsoleLauncher (from a gradle JavaExec Task, but I doubt that matters).
I accidentally provided twice the same key for --config as follows:
'--config', 'forgive=".*spec:ch.tutteli.atrium.api.cc.en_UK.Iterable.error cases."',
'--config', 'forgive=".*spec:ch.tutteli.atrium.api.cc.en_UK.Iterable.failing cases."',

The following Exception was thrown

Exception in thread "main" java.lang.IllegalStateException: Duplicate key .*spec:ch.tutteli.atrium.api.cc.en_UK.Iterable.*error
	at java.util.stream.Collectors.lambda$throwingMerger$114(Collectors.java:133)
	at java.util.HashMap.merge(HashMap.java:1245)
	at java.util.stream.Collectors.lambda$toMap$172(Collectors.java:1320)
	at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
	at org.junit.platform.console.options.AvailableOptions.toCommandLineOptions(AvailableOptions.java:237)
	at org.junit.platform.console.options.JOptSimpleCommandLineOptionsParser.parse(JOptSimpleCommandLineOptionsParser.java:41)
	at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:68)
	at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:47)
	at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:39)

The error as such is fine, but I would have expected it reports that forgive was duplicated. I am not entirely sure if this a junit5 bug or a JDK8 bug but I guess you will find out quickly.

Activity

  1. sormuras commented on Feb 24, 2018

    @sormuras
    sormuras
    on Feb 24, 2018
    Member
    More actions

    Can you please try version 1.1.0 please?

    Tried it locally with "--config foo=bar --config foo=baz" and results in the expected exception message:

    java.lang.IllegalStateException: Duplicate key foo (attempted merging values bar and baz)
    
    	at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:131)
    	at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:178)
    	at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1494)
    	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
    	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:511)
    	at org.junit.platform.console.options.AvailableOptions.toCommandLineOptions(AvailableOptions.java:257)
    	at org.junit.platform.console.options.JOptSimpleCommandLineOptionsParser.parse(JOptSimpleCommandLineOptionsParser.java:41)
    [...]
    
  2. sormuras
    added
    status: waiting-for-feedback
    on Feb 24, 2018
  3. sormuras commented on Feb 24, 2018

    @sormuras
    sormuras
    on Feb 24, 2018
    Member
    More actions

    Nevertheless, it should be an instance of JUnitException with a message of Error parsing command-line arguments and an atttached cause: java.lang.IllegalStateException: Duplicate key foo (attempted merging values bar and baz).

    Addressing this in master.

  4. sormuras
    added a commit that references this issue on Feb 24, 2018

    Improve excepting handling while parsing command line options

    57b23a3
  5. sormuras
    added this to the 5.2 M1 milestone on Feb 25, 2018
  6. sormuras
    self-assigned this
    on Feb 25, 2018
  7. sormuras
    added
    component: Platform
    on Feb 25, 2018
  8. robstoll commented on Feb 25, 2018

    @robstoll
    robstoll
    on Feb 25, 2018
    Author
    More actions

    Nope, looks still the same. You can reproduce it as follows:

    1. git clone https://github.com/robstoll/atrium.git
    2. open misc/atrium-bc-test/build.gradle
    3. add '--config', 'forgive=test', to line 69
    4. gr :atrium-bc-test:build

    Following the Exception message I got:

    Exception in thread "main" java.lang.IllegalStateException: Duplicate key .*spec:ch.tutteli.atrium.api.cc.de_CH.Iterable.*(error cases|failing cases|context empty collection).*
    
  9. sormuras commented on Feb 26, 2018

    @sormuras
    sormuras
    on Feb 26, 2018
    Member
    More actions

    Will try later. But reading the initial error message carefully, I guess the command line configuration you use in the Gradle script is not correct. Your value is interpreted as a key -- see the "missing" tail of your value after the first space character: .*spec:ch.tutteli.atrium.api.cc.de_CH.Iterable.*(error

    Perhaps, you have wrap the value string into an extra "?

  10. robstoll commented on Feb 26, 2018

    @robstoll
    robstoll
    on Feb 26, 2018
    Author
    More actions

    That's actually what I figured at the beginning. In the first output in the description of this task I wrapped it in " and that was actually the reason why my argument got chopped into two parts (see also gradle/gradle#4510).
    See the output in my last comment #1308 (comment), the argument is not split up. The error message is wrong nonetheless.

  11. sormuras commented on Feb 26, 2018

    @sormuras
    sormuras
    on Feb 26, 2018
    Member
    More actions

    It's a bug in Java 8. See https://bugs.openjdk.java.net/browse/JDK-8040892 for details. It was fixed in Java 9.

    @junit-team/junit-lambda shall we roll our own toMap helper and always emit a helpful error message?

    	private Map<String, String> map(List<KeyValuePair> pairs) {
    		Map<String, String> map = new HashMap<>();
    		for (KeyValuePair pair : pairs) {
    			String key = pair.key;
    			if (map.containsKey(key)) {
    				Exception cause = new IllegalStateException("Duplicate key " + key + " in: " + pairs);
    				throw new JUnitException("Error parsing command-line arguments", cause);
    			}
    			map.put(key, pair.value);
    		}
    		return map;
    	}
    
  12. sormuras
    added
    status: team discussion
    theme: modules
    and removed
    status: waiting-for-feedback
    on Feb 26, 2018
  13. robstoll commented on Feb 26, 2018

    @robstoll
    robstoll
    on Feb 26, 2018
    Author
    More actions

    Fair enough, I had a quick glance a the source code of junit5 before I reported the issue and thought it could be a bug in JDK8. I keep the issue open as it seems you want to discuss a few things. Close the issue whenever you want, for me it is done.

  14. sbrannen commented on Feb 26, 2018

    @sbrannen
    sbrannen
    on Feb 26, 2018
    Member
    More actions

    @junit-team/junit-lambda shall we roll our own toMap helper and always emit the a helpful error message?

    SGTM

  15. sormuras
    added 2 commits that reference this issue on Feb 26, 2018

    Emit helpful message when a configuration key is not unique

    This issue will close once commit 73a5926 is merged into the 'main' branch.
    73a5926

    Emit helpful message when a configuration key is not unique

    This issue will close once commit bcec6fa is merged into the 'main' branch.
    bcec6fa
  16. ghost added
    status: in progress
    on Feb 27, 2018
  17. sormuras
    closed this as completedin #1316on Feb 28, 2018
  18. ghost removed
    status: in progress
    on Feb 28, 2018
  19. sormuras
    added a commit that references this issue on Feb 28, 2018

    Emit helpful message when a configuration key is not unique

    This issue will close once commit b3cec57 is merged into the 'main' branch.
    b3cec57
  20. sbrannen
    removed
    status: team discussion
    on Apr 15, 2018
  21. Andrei94
    added 2 commits that reference this issue on Jun 23, 2018

    Improve excepting handling while parsing command line options

    dd34202

    Emit helpful message when a configuration key is not unique

    3137639
  22. github-actions
    locked as resolved and limited conversation to collaborators on May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sormuras
    sormuras

Labels

component: Platformtheme: modules

Type

No type

Projects

No projects

    Milestone

    • 5.2 M1

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.