question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible problem with JavalinVue when using Location.EXTERNAL - not closing files?

See original GitHub issue

Actual behavior/steps to reproduce (the bug)

  1. Set external location
JavalinVue.rootDirectory("/vue", Location.EXTERNAL)
  1. (have a large number of .vue files in /vue folder)

  2. Run something that produces a lot of requests, e.g. scenario tests

  3. Produces java.nio.file.FileSystemException: [...]/src/main/resources/vue: Too many open files exception

https://gist.github.com/jorunfa/4278f4d0c231d7b54d3348464689d94d

I’ll try to investigate the issue myself.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
maxemann96commented, Sep 11, 2019

In the last days I saw something in the code base.

fun Path.readText(): String {
    val s = Scanner(Files.newInputStream(this), "UTF-8").useDelimiter("\\A")
    return if (s.hasNext()) s.next() else ""
}

The scanner is never closed, could this be the problem? What about Files.readAllBytes()?

0reactions
jorunfacommented, Sep 12, 2019

readAllBytes seems to work fine in distroless Java container (which was where we had a problem before).

I have very little experience with the Scanner class, so I’m not sure, but it seems like one of its primary purposes is scanning for input, i.e. from user input through System.in, but of course other sources are also possible. E.g.:

Scanner sc = new Scanner(System.in);
int i = sc.nextInt(); 

https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html

We always read the full .vue file. readAllBytes makes sense to me. Not my area of expertise though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible problem with JavalinVue when using Location.EXTERNAL ...
(have a large number of .vue files in /vue folder). Run something that produces a lot of requests, e.g. scenario tests. Produces java.nio.file....
Read more >
Documentation - A lightweight Java and Kotlin web framework
Javalin - A lightweight Java and Kotlin web framework. Create REST APIs in Java or Kotlin easily.
Read more >
Why doesn't java.io.File have a close method? - Stack Overflow
Streams can be opened and closed, files cannot. (My personal opinion is that it's rather unfortunate that Sun then went on to create ......
Read more >
Fixed: External Hard Drive Recognized But Not Accessible
External hard drive recognized by not opening in computer File Explorer? This article offers 6 fixes to recognized but not accessible ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found