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

Fix issues using DummyGameLocator with libraries #175

Merged
merged 4 commits into from
Jul 1, 2024
Merged

Fix issues using DummyGameLocator with libraries #175

merged 4 commits into from
Jul 1, 2024

Conversation

colinmcdonald22
Copy link
Contributor

@colinmcdonald22 colinmcdonald22 commented Jun 30, 2024

Issue #1: DummyGameLocator#gameLibraries() returns a closed Stream

As Stream is AutoCloseable, the stream returned by DummyGameLocator's gameLibraries() method was getting closed immediately after the try-catch block. This resulted in the following error:

[11:00:03] [main/INFO]: Preparing the game...
Exception in thread "main" java.lang.IllegalStateException
	at java.base/java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:102)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at space.vectrix.ignite.IgniteBootstrap.run(IgniteBootstrap.java:157)
	at space.vectrix.ignite.IgniteBootstrap.main(IgniteBootstrap.java:74)

This IllegalStateException is being thrown here: https://github.com/JetBrains/jdk8u_jdk/blob/master/src/share/classes/java/nio/file/FileTreeIterator.java#L102-L103, as the stream is already closed.

Issue #2: Incorrect .jar extension check

.endsWith() on Path has some interesting semantics, and doesn't just match a suffix on the file name like we're expecting it to. Changing to .toString().endsWith() fixes this.

@colinmcdonald22 colinmcdonald22 changed the title Fix/dummy locator closed stream Fix DummyGameLocator#gameLibraries() returning a closed Stream Jun 30, 2024
@colinmcdonald22 colinmcdonald22 changed the title Fix DummyGameLocator#gameLibraries() returning a closed Stream Fix issues using DummyGameLocator with libraries Jun 30, 2024
@vectrixdevelops vectrixdevelops merged commit 612e4dd into vectrix-space:main/1.0.0 Jul 1, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants