java.lang.IllegalStateException: Duplicate key
Closed this issue · 2 comments
mraalex commented
On Android I get a duplicate key exception when I want to list the countries. I can also provide a sample project in case you can not reproduce it.
System.setProperty("jakarta.ws.rs.client.ClientBuilder", "org.glassfish.jersey.client.JerseyClientBuilder");
RadioBrowser browser = new RadioBrowser(5000, "Demo agent/1.0");
browser.listCountries();
java.lang.IllegalStateException: Duplicate key 226
2023-07-10 15:10:59.772 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)
2023-07-10 15:10:59.773 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.Collectors$$ExternalSyntheticLambda45.apply(Unknown Source:0)
2023-07-10 15:10:59.773 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.HashMap.merge(HashMap.java:1256)
2023-07-10 15:10:59.774 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
2023-07-10 15:10:59.775 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.Collectors$$ExternalSyntheticLambda4.accept(Unknown Source:8)
2023-07-10 15:10:59.775 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
2023-07-10 15:10:59.776 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1390)
2023-07-10 15:10:59.777 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
2023-07-10 15:10:59.777 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:475)
2023-07-10 15:10:59.778 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
2023-07-10 15:10:59.779 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:236)
2023-07-10 15:10:59.779 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:517)
2023-07-10 15:10:59.780 17729-17780 System.err com.example.radiobrowser4jtest2 W at de.sfuhrm.radiobrowser4j.RadioBrowser.retrieveValueStationCountList(RadioBrowser.java:181)
2023-07-10 15:10:59.780 17729-17780 System.err com.example.radiobrowser4jtest2 W at de.sfuhrm.radiobrowser4j.RadioBrowser.listCountries(RadioBrowser.java:195)
2023-07-10 15:10:59.781 17729-17780 System.err com.example.radiobrowser4jtest2 W at com.example.radiobrowser4jtest2.FullscreenActivity$6.run(FullscreenActivity.java:157)
2023-07-10 15:10:59.782 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
2023-07-10 15:10:59.782 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2023-07-10 15:10:59.783 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2023-07-10 15:10:59.783 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2023-07-10 15:10:59.784 17729-17780 System.err com.example.radiobrowser4jtest2 W at java.lang.Thread.run(Thread.java:920)
sfuhrm commented
I can reproduce.
Exception in thread "main" java.lang.IllegalStateException: Duplicate key France (attempted merging values 2056 and 1)
at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:133)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
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:578)
at de.sfuhrm.radiobrowser4j.RadioBrowser.retrieveValueStationCountList(RadioBrowser.java:181)
at de.sfuhrm.radiobrowser4j.RadioBrowser.listCountries(RadioBrowser.java:195)
at de.sfuhrm.radiobrowser4j.demo.ListDemo.main(ListDemo.java:46)
sfuhrm commented
New release 2.3.1 fixing this should be in maven repos soon:
https://github.com/sfuhrm/radiobrowser4j/releases/tag/radiobrowser4j-parent-2.3.1