Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 519857

Summary: Scanner hangs
Product: [Eclipse Project] JDT Reporter: Kirk Freyermuth <bfordguy>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: sarika.sinha
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows 8   
Whiteboard: stalebug

Description Kirk Freyermuth CLA 2017-07-19 01:40:39 EDT
First, I am using Neon.  About says 4.6.3.

I have a simple program:

import java.util.Scanner;

public class test {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("Ready ");
		while (true) {
			boolean x = sc.hasNext();
			if (!x) break;
			String s = sc.nextLine();
			System.out.println(s);
		}
	}

}

and a simple test file: test.txt (note there is no \n after the second line

foobar
goobar

When I run this program from the command line I can enter data till EOF (ctrl-D) and the programs does whats expected.

If I run this program from command line [java test <test.txt], the program prints the two lines and ends.

If I run this program in the debugger with input set to console, it runs as it does from the command line.

If I use the Common tab in the project configuration and set the input to the test file, it prints the first line and reports x as true for the second line but the nextline() method invocation hangs the program.
Comment 1 Sarika Sinha CLA 2017-07-19 23:41:21 EDT
I am able to reproduce this on latest Photon build as well.
Comment 2 Eclipse Genie CLA 2020-03-11 19:23:19 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.