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

REPL gets stuck when result's "message" is a very long String #120

Open
livinssharma opened this issue Jun 16, 2017 · 0 comments
Open

REPL gets stuck when result's "message" is a very long String #120

livinssharma opened this issue Jun 16, 2017 · 0 comments

Comments

@livinssharma
Copy link

The REPL becomes unresponsive (indefinitely) when result of a computation is something whose "message" is a huge string.

May be simulated by reading lines of a large file in a manner similar to this:
java> java.util.List<String> listOfPrintables = java.nio.file.Files.lines(java.nio.file.Paths.get(NAME_OF_SOME_LARGE_FILE)).collect(java.util.stream.Collectors.toList())

The size (heap memory-footprint of result) itself is not the problem - large enough "-Xmx" was used.

Further confirmed that if, instead of gathering into a List reference, we simply determine the size of the list and save into an "int" variable, the equivalent command terminates within a few seconds and the result (length of List) is printed and control returns to console (remains responsive).

That is, the following works in contrast to above, even though the same amount of data is being read:
.....collect(java.util.stream.Collectors.toList()).size()

Finally, as an experiment and debugging client and server (jdb),
I could work around the problem by making such a change in 'java-repl' source on the server (Repl) side:

2017-06-13/java-repl-master/src/javarepl/console/ConsoleLog.java

public static ConsoleLog consoleLog(ConsoleLog.Type type, String message) {
    final int MAX_LEN = 512; // let us trim long messages within the server
    int len = message.length();
    if (len > MAX_LEN) {
        message = message.substring(0, MAX_LEN);
    }

    return new ConsoleLog(type, message);
}
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

1 participant