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

Exception when using scanner to read from System.in #1621

Open
nioerd opened this issue Nov 6, 2024 · 0 comments
Open

Exception when using scanner to read from System.in #1621

nioerd opened this issue Nov 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nioerd
Copy link

nioerd commented Nov 6, 2024

Extension Name: vscode-gradle
Extension Version: 3.16.4
OS Version: Windows 10 - 22H2
VSCode version:

Version: 1.95.1 (system setup)
Commit: 65edc4939843c90c34d61f4ce11704f09d3e5cb6
Date: 2024-10-31T05:14:54.222Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

Describe the bug
In a simple CLI application, the program crashes, with the exception attached below, if executed via the "run task" from the extension's menu when using a scanner to read from the command line.

terminal output:

Executing task: gradle: run 

<=========----> 75% EXECUTING [390ms]
> :run
Exception in thread "main" java.util.NoSuchElementException
        at java.base/java.util.Scanner.throwFor(Scanner.java:941)
        at java.base/java.util.Scanner.next(Scanner.java:1482)
        at de.buw.se.AppCLITest.main(AppCLITest.java:12)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:\Program Files\Java\jdk-19\bin\java.exe'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

> Task :run FAILED
Test output
Test input: 3 actionable tasks: 1 executed, 2 up-to-date
Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-8.10-bin.zip'.
 *  The terminal process failed to launch (exit code: 1).

To Reproduce
Run the source code provided below with the "run task" button.

Expected behavior
The application should run the same way, as if would be executed via the terminal ".\gradlew.bat run".

Screenshots
If applicable, add screenshots to help explain your problem.

Output from "Gradle for Java"

[error] [gradle-server] Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-8.10-bin.zip'.
[error] Error running build: run: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-8.10-bin.zip'.

Does the bug still exist if you disable all other extensions?
Yes

Additional context
The source code:

package de.buw.se;

import java.util.Scanner;

public class AppCLITest {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        System.out.println("Test output");
        System.out.print("Test input: ");

        String str = s.next();

        System.out.print("result: " + str);
        
        s.close();
    }
}
@nioerd nioerd added the bug Something isn't working label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant