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

Bug 333239

Summary: [console] Console redirection treats file name as regular expression
Product: [Eclipse Project] Platform Reporter: Darko Cerepnalkoski <darko.cerepnalkoski>
Component: DebugAssignee: Paul Pazderski <paul-eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie, paul-eclipse, remy.suen, sarika.sinha
Version: 3.6.1   
Target Milestone: 4.16 M3   
Hardware: PC   
OS: Windows 7   
See Also: https://git.eclipse.org/r/158136
https://git.eclipse.org/c/platform/eclipse.platform.debug.git/commit/?id=79c7833392ac1e85adf0f48e5808998c6f3a1caf
Whiteboard:
Bug Depends on: 566336    
Bug Blocks:    

Description Darko Cerepnalkoski CLA 2010-12-27 08:03:44 EST
Build Identifier: M20100909-0800

When redirecting the console output to a file in the workspace, if there are characters like '[' and ']' in the file name, the redirection will fail, and eclipse would not print the output neither to console nor to file. In the Error 

Log these two exceptions can be spotted:

eclipse.buildId=M20100909-0800
java.version=1.6.0_22
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64


Error
Mon Dec 27 12:26:13 CET 2010
An exception occurred during launch change notification.

java.util.regex.PatternSyntaxException: Illegal character range near index 55
D:\\Workspace\\Eclipse Workspace\\Test\\exhaustive[128-32].out
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.range(Unknown Source)
at java.util.regex.Pattern.clazz(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at org.eclipse.ui.internal.console.ConsolePatternMatcher.addPatternMatchListener(ConsolePatternMatcher.java:222)
at org.eclipse.ui.console.TextConsole.addPatternMatchListener(TextConsole.java:401)
at org.eclipse.debug.internal.ui.views.console.ProcessConsole.<init>(ProcessConsole.java:163)
at org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager.launchChanged(ProcessConsoleManager.java:145)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.run(LaunchManager.java:454)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.notify(LaunchManager.java:435)
at org.eclipse.debug.internal.core.LaunchManager.fireUpdate(LaunchManager.java:997)
at org.eclipse.debug.core.Launch.fireChanged(Launch.java:388)
at org.eclipse.debug.core.Launch.addProcess(Launch.java:351)
at org.eclipse.debug.core.model.RuntimeProcess.<init>(RuntimeProcess.java:125)
at org.eclipse.debug.core.DebugPlugin.newProcess(DebugPlugin.java:724)
at org.eclipse.jdt.launching.AbstractVMRunner.newProcess(AbstractVMRunner.java:113)
at org.eclipse.jdt.internal.launching.StandardVMRunner.run(StandardVMRunner.java:328)
at org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:101)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

-----------------

eclipse.buildId=M20100909-0800
java.version=1.6.0_22
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64


Error
Mon Dec 27 12:26:13 CET 2010
Problems occurred when invoking code from plug-in: "org.eclipse.debug.core".

java.util.regex.PatternSyntaxException: Illegal character range near index 55
D:\\Workspace\\Eclipse Workspace\\Test\\exhaustive[128-32].out
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.range(Unknown Source)
at java.util.regex.Pattern.clazz(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at org.eclipse.ui.internal.console.ConsolePatternMatcher.addPatternMatchListener(ConsolePatternMatcher.java:222)
at org.eclipse.ui.console.TextConsole.addPatternMatchListener(TextConsole.java:401)
at org.eclipse.debug.internal.ui.views.console.ProcessConsole.<init>(ProcessConsole.java:163)
at org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager.launchChanged(ProcessConsoleManager.java:145)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.run(LaunchManager.java:454)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.debug.internal.core.LaunchManager$LaunchNotifier.notify(LaunchManager.java:435)
at org.eclipse.debug.internal.core.LaunchManager.fireUpdate(LaunchManager.java:997)
at org.eclipse.debug.core.Launch.fireChanged(Launch.java:388)
at org.eclipse.debug.core.Launch.addProcess(Launch.java:351)
at org.eclipse.debug.core.model.RuntimeProcess.<init>(RuntimeProcess.java:125)
at org.eclipse.debug.core.DebugPlugin.newProcess(DebugPlugin.java:724)
at org.eclipse.jdt.launching.AbstractVMRunner.newProcess(AbstractVMRunner.java:113)
at org.eclipse.jdt.internal.launching.StandardVMRunner.run(StandardVMRunner.java:328)
at org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:101)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


It seems that the file path is treated as a regular expression. The file name should probably be escaped before doing so in order to allow 'special' characters like '[' and ']'


Reproducible: Always

Steps to Reproduce:
1. Open Run Configurations
2. Choose a Java Application
3. Go to the Common tab
4. Select a file from the workspace for redirection. In my case the file name was exhaustive[128-32].out
Comment 1 Darko Cerepnalkoski CLA 2011-03-23 13:35:39 EDT
This bug has existed for some time now. Are there any news about it, any plans to publish a fix for it?
Comment 2 Michael Rennie CLA 2011-03-23 14:12:22 EDT
(In reply to comment #1)
> This bug has existed for some time now. Are there any news about it, any plans
> to publish a fix for it?

There are no plans to fix it currently (during 3.7)
Comment 3 Eclipse Genie CLA 2020-02-22 15:53:30 EST
New Gerrit change created: https://git.eclipse.org/r/158136
Comment 5 Sarika Sinha CLA 2020-05-19 07:07:42 EDT
@Paul,
Please verify the fix in the build.
Comment 6 Paul Pazderski CLA 2020-05-19 10:06:20 EDT
Works in Eclipse SDK

Version: 2020-06 (4.16)
Build id: I20200518-2220
Comment 7 Sarika Sinha CLA 2020-07-20 01:36:40 EDT
Test failed randomly on Windows, can we safe guard it ?

https://download.eclipse.org/eclipse/downloads/drops4/I20200717-1800/testresults/html/org.eclipse.debug.tests_ep417I-unit-win32-java11_win32.win32.x86_64_11.html

testAppendOutputToFile	Failure	Output not found in console. expected:<[Hello World!]> but was:<[]>

org.junit.ComparisonFailure: Output not found in console. expected:<[Hello World!]> but was:<[]>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.eclipse.debug.tests.console.ProcessConsoleTests.doConsoleOutputTest(ProcessConsoleTests.java:400)
at org.eclipse.debug.tests.console.ProcessConsoleTests.testAppendOutputToFile(ProcessConsoleTests.java:317)