Bug 550175 - MalformedURLException launching plugin JUnit test for debug
Summary: MalformedURLException launching plugin JUnit test for debug
Status: CLOSED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 4.12   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2019-08-18 09:59 EDT by Ed Willink CLA
Modified: 2023-10-16 09:52 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2019-08-18 09:59:30 EDT
4.12: When launching

org.eclipse.qvtd.xtext.qvtrelation.tests.QVTrDebuggerTests.testDebugger_Run_hstm2fstm_CG

by selecting the test in the JUNit View for the 

\org.eclipse.qvtd.all.tests\.launches\All QVTd Tests (Plugin)

launch, I get

	Thread [main] (Suspended (breakpoint at line 54 in MalformedURLException))	
		MalformedURLException.<init>(String) line: 54	
		URL.<init>(URL, String, URLStreamHandler) line: 593	
		URL.<init>(URL, String) line: 490	
		URL.<init>(String) line: 439	
		Main.addBaseJars(URL, ArrayList<URL>) line: 929	
		Main.getDevPath(URL) line: 797	
		Main.getBootPath(String) line: 995	
		Main.basicRun(String[]) line: 577	
		Main.run(String[]) line: 1468	
		Main.main(String[]) line: 1441	
C:\Program Files\Java\jdk1.8.0_211\bin\javaw.exe (18 Aug 2019, 14:51:47)	

Investigating, it appears that in Main.addBaseJars

		String baseJarList = System.getProperty(PROP_CLASSPATH);

returns null, but that

			readFrameworkExtensions(base, result);
			baseJarList = System.getProperty(PROP_CLASSPATH);


changes baseJarList to

., file:E:/Tools/Eclipse/4.12/plugins/org.eclipse.osgi.compatibility.state_1.1.500.v20190516-1407.jar

and that it is the "." that provokes the MalformedURLException
Comment 1 Sarika Sinha CLA 2019-08-19 01:28:36 EDT
Moving to JDT UI.
Comment 2 Noopur Gupta CLA 2019-10-31 07:27:48 EDT
(In reply to Ed Willink from comment #0)
> Investigating, it appears that in Main.addBaseJars
> 
> 		String baseJarList = System.getProperty(PROP_CLASSPATH);
> 
> returns null, but that
> 
> 			readFrameworkExtensions(base, result);
> 			baseJarList = System.getProperty(PROP_CLASSPATH);
> 
> 
> changes baseJarList to
> 
> .,
> file:E:/Tools/Eclipse/4.12/plugins/org.eclipse.osgi.compatibility.state_1.1.500.v20190516-1407.jar
> 
> 
> and that it is the "." that provokes the MalformedURLException

The referenced code is from Equinox.
Comment 3 Thomas Watson CLA 2019-10-31 08:54:13 EDT
Outside of a breakpoint hit on MalformedURLException, what is the observed error to the end user of Eclipse?
Comment 4 Ed Willink CLA 2019-10-31 09:24:43 EDT
Probably only the fractional difference in speed for a guarded rather than caught problem.

It's just really naff that Eclipse/Java seems to have an extra warmup problem for a debug user to navigate with each release.
Comment 5 Thomas Watson CLA 2019-10-31 09:38:26 EDT
(In reply to Ed Willink from comment #4)
> Probably only the fractional difference in speed for a guarded rather than
> caught problem.

If you can observe a few nanoseconds in a debug session I am impressed.

> 
> It's just really naff that Eclipse/Java seems to have an extra warmup
> problem for a debug user to navigate with each release.

I don't understand this comment, this code has been this way for more than 10 years.  I also don't understand understand how this is a warmup problem at all because the code catches and handles the exception itself.  Not sure why that has to affect a debug user.

IIRC this code has a pattern of trying the value out as a URL and intentionally catches the MalformedURLException and then falls back to using the value as a relative path to the base.

Moving to Launcher since this is not a framework issue.
Comment 6 Ed Willink CLA 2019-10-31 10:36:58 EDT
(In reply to Thomas Watson from comment #5)
> (In reply to Ed Willink from comment #4)
> > Probably only the fractional difference in speed for a guarded rather than
> > caught problem.
> 
> If you can observe a few nanoseconds in a debug session I am impressed.

I suspect it's actually nearly microseconds since probably there is a MalformedURLException class load.

> > 
> > It's just really naff that Eclipse/Java seems to have an extra warmup
> > problem for a debug user to navigate with each release.
> 
> I don't understand this comment, this code has been this way for more than
> 10 years.  I also don't understand understand how this is a warmup problem
> at all because the code catches and handles the exception itself.  Not sure
> why that has to affect a debug user.
> 
> IIRC this code has a pattern of trying the value out as a URL and
> intentionally catches the MalformedURLException and then falls back to using
> the value as a relative path to the base.
> 
> Moving to Launcher since this is not a framework issue.

MalformedURLException, UnsupportedOperationException, NullPointerException, IllegalStateException, AssertionFailedError are ones I have learned to always debug since they invariably lie at the heart of more confusing downstream behaviour.

In some cases a URL try and fail may be necessary, but "." is a guaranteed failure from an internally created definitely-not-URL. In practice the try-and-fail need only fail for genuinely bad URLs.
Comment 7 Thomas Watson CLA 2019-10-31 11:30:11 EDT
(In reply to Ed Willink from comment #6)
> In some cases a URL try and fail may be necessary, but "." is a guaranteed
> failure from an internally created definitely-not-URL. In practice the
> try-and-fail need only fail for genuinely bad URLs.

Sure, but the value currently supports both URL values and non-URL values, so you either need to do some check before calling new URL or just handling the non-URL values when catching the exception that we need to be prepared to catch anyway.  I suppose we could do some check like indexOf(':') != -1 before calling new URL which would probably handing most all cases I can think of.
Comment 8 Ed Willink CLA 2019-11-01 04:26:48 EDT
The check is already there. Currently

	if (string.equals(".")) { //$NON-NLS-1$
		addEntry(base, result);
	}

detects the problem path, special cases it then continues in the main flow where the known bad case causes a guaranteed exception for new URL(".").

Surely

	URL url;
	if (string.equals(".")) { //$NON-NLS-1$
		addEntry(base, result);
		url = new URL(base, string);
	}
	else if (string.startsWith(FILE_SCHEME))
		url = new File(string.substring(5)).toURL();
	else
		url = new URL(string);
	addEntry(url, result);

avoids the gratuitous exception?
Comment 9 Eclipse Genie CLA 2021-10-22 14:27:46 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.
Comment 10 Ed Willink CLA 2021-10-23 00:42:44 EDT
Still waiting for a response to comment 8
Comment 11 Thomas Watson CLA 2021-10-25 08:51:11 EDT
(In reply to Ed Willink from comment #10)
> Still waiting for a response to comment 8

I've lost sight of what this bug report is trying to fix.  Is there some end user observable issue here?
Comment 12 Ed Willink CLA 2021-10-25 08:55:55 EDT
There is a gratuitous Exception, caused by poor programming, that makes the debugging user's life harder by causing problem breakpoints to be hit when actually there was no problem at all.

Comment #8 suggests a trivial rewrite.
Comment 13 Thomas Watson CLA 2021-10-25 10:04:39 EDT
(In reply to Ed Willink from comment #12)
> There is a gratuitous Exception, caused by poor programming,

Lovely

> that makes the
> debugging user's life harder by causing problem breakpoints to be hit when
> actually there was no problem at all.
> 
> Comment #8 suggests a trivial rewrite.

Not sure how trivial it is.  This code path appears to be when you have some equinox specific framework extensions present and are in dev mode.  That is a rather complicated scenario.  I have to admit I don't have a full memory of all the inputs PDE sets for such a scenario when you have framework extensions contributing to the classpath of the framework and the launcher has to discover all of the paths to put on the class loader for the framework.  That in addition to being in devmode so now the launcher also has to look for all the dev paths from framework extensions that may be contained in the workspace.

All of this is to say, I don't think we have adequate test coverage for such a complicated scenario to make sure this "trivial" change doesn't break stuff.  That makes this change non-trivial.
Comment 14 Eclipse Genie CLA 2023-10-16 09:52:02 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.