Closed UncleThaodan closed 2 years ago
Thank you for contributing! Everything seems to be working. Just one question: should't ConsoleReader
be blocking already?
It returns early if conditions are not met, apparently - I got a 40% CPU utilization before i added the timeout. I'm not sure how you'd debug a third party library like that, given that the issue seems to only appear in a docker container, but I suspect one of the following section of the ConsoleReader.readLine()
function is responsible (though there are a total of 10 different return
statements to consider in that almost 600 line long function 🙃):
String originalPrompt;
if (!this.terminal.isSupported()) {
originalPrompt = this.readLineSimple();
return originalPrompt;
}
while(true) {
Object o = this.readBinding(this.getKeys());
if (o == null) {
Object var23 = null;
return (String)var23;
}
...
Incidentally, both readLineSimple()
and readBinding()
can also return null very early.
This leads to an expensive, fast running loop if it keeps failing without delay.
Dockerfile:
FROM openjdk:16-bullseye
WORKDIR /votifier/
EXPOSE 8752
COPY ./ ./
CMD ["java", "-jar", "VanillaVotifier.jar"]
Docker-compose:
version: '3.9'
services:
votifier:
command: 'java -jar VanillaVotifier.jar'
build:
dockerfile: Dockerfile
ports:
- 8752:8752
volumes:
- ./logs:/votifier/logs:rw
networks:
public: {}
networks:
public:
Command used:
docker-compose up --build votifier
Error with original 4.2.1 version:
votifier_1 | [10:15:49] Loading config...
votifier_1 | [10:15:49] Config loaded.
votifier_1 | [10:15:49] Starting VanillaVotifier server...
votifier_1 | [10:15:49] VanillaVotifier server started.
votifier_1 | [10:15:49] Unexpected exception while reading user input: java.lang.NullPointerException: Cannot invoke "String.length()" because "command" is null
votifier_1 | at mamo.vanillaVotifier.VanillaVotifier.main(VanillaVotifier.java:105)
votifier_1 |
votifier_1 | [10:15:49] Stopping VanillaVotifier server...
votifier_1 | [10:15:49] VanillaVotifier server stopped.
votifier_votifier_1 exited with code 0
That’s actually quite interesting! readLine
returning null
is quite some unexpected behaviour. Thank you again. I’ll merge the pull request :)
More detail in the commit messages.