Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command list does not always sort the entries correctly #54

Closed
adoble opened this issue Jul 12, 2024 · 10 comments
Closed

Command list does not always sort the entries correctly #54

adoble opened this issue Jul 12, 2024 · 10 comments

Comments

@adoble
Copy link
Owner

adoble commented Jul 12, 2024

As noticed here adr list does not always sort the entries correctly although a sort is explicity called in the code (see CommandList.java)

@sdavids
Copy link
Contributor

sdavids commented Aug 20, 2024

Verified on macOS:

$ adr version
Version 3.2.3
$ mkdir /tmp/test && cd "$_"
$ adr init
Creating ADR directory at /private/tmp/test/doc/adr
$ adr new a
Creating ADR
Created ADR at /private/tmp/test/doc/adr/0002-a.md
Opening Editor on /private/tmp/test/doc/adr/0002-a.md ...
/private/tmp/test/doc/adr/0002-a.md
$ adr new b
Creating ADR
Created ADR at /private/tmp/test/doc/adr/0003-b.md
Opening Editor on /private/tmp/test/doc/adr/0003-b.md ...
$ adr new c
Creating ADR
Created ADR at /private/tmp/test/doc/adr/0004-c.md
Opening Editor on /private/tmp/test/doc/adr/0004-c.md ...
/private/tmp/test/doc/adr/0004-c.md
$ adr list
0001-record-architecture-decisions.md
0002-a.md
0004-c.md
0003-b.md

@sdavids
Copy link
Contributor

sdavids commented Aug 20, 2024

$ jshell --feedback=silent -  <<< 'Files.list(Path.of("doc", "adr")).forEachOrdered(System.out::println)'
doc/adr/0001-record-architecture-decisions.md
doc/adr/0002-a.md
doc/adr/0004-c.md
doc/adr/0003-b.md
$ jshell --feedback=silent -  <<< 'Files.list(Path.of("doc", "adr")).map(Path::getFileName).forEachOrdered(System.out::println)'
0001-record-architecture-decisions.md
0002-a.md
0004-c.md
0003-b.md
$ jshell --feedback=silent - <<< 'Files.list(Path.of("doc", "adr")).map(Path::getFileName).sorted().forEach(System.out::println)'
0001-record-architecture-decisions.md
0002-a.md
0003-b.md
0004-c.md

forEachOrdered does not sort—use sorted instead.

FileSystemProvider#newDirectoryStream does not specify the order of the directory entries in the stream.

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/Stream.html#forEachOrdered(java.util.function.Consumer)

in the encounter order of the stream if the stream has a defined encounter order.

https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/stream/Stream.html#sorted()

@sdavids
Copy link
Contributor

sdavids commented Aug 20, 2024

google/jimfs#362

@adoble
Copy link
Owner Author

adoble commented Aug 21, 2024

Thanks for figuring this out. I'll change the code to use sorted.

@adoble
Copy link
Owner Author

adoble commented Aug 22, 2024

Issue 54

@adoble
Copy link
Owner Author

adoble commented Aug 22, 2024

I've changed to code as suggested and pushed it to the main branch. Still not released as yet.

@sdavids
Copy link
Contributor

sdavids commented Aug 22, 2024

Reviewed the code but have not verified runtime behavior—hope to have time this weekend.

@adoble
Copy link
Owner Author

adoble commented Aug 24, 2024

Kein Stress

@sdavids
Copy link
Contributor

sdavids commented Aug 24, 2024

Verified 9a2e0a2 with macOS 12.7.6.

@adoble
Copy link
Owner Author

adoble commented Aug 27, 2024

Thanks. I'm closing the issue.

@adoble adoble closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants