This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 138448 - URLMapper.findFileObject() fails for a valid url on Windows
Summary: URLMapper.findFileObject() fails for a valid url on Windows
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P1 blocker (vote)
Assignee: Tomasz Slota
URL:
Keywords: SPACE_IN_PATH
Depends on:
Blocks:
 
Reported: 2008-06-27 09:35 UTC by carentrica
Modified: 2008-07-01 17:43 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
message log file (65.45 KB, text/plain)
2008-06-27 09:36 UTC, carentrica
Details
message log (IllegalArgumentException) (65.45 KB, text/plain)
2008-06-27 15:05 UTC, carentrica
Details

Note You need to log in before you can comment on or make changes to this bug.
Description carentrica 2008-06-27 09:35:48 UTC
I have code completion switched off in Options.

When I invoke it with Ctrl-Space, e.g.:

    $s = substr(/* do Ctrl-Space here */)

I get a NullPointerException every time.
Comment 1 carentrica 2008-06-27 09:36:37 UTC
Created attachment 63580 [details]
message log file
Comment 2 Tomasz Slota 2008-06-27 13:12:28 UTC
Interesting issue. If it is always reproducible on the default installation in Windows it is a P1. Setting P2 for now.
Comment 3 Tomasz Slota 2008-06-27 14:22:20 UTC
I cannot reproduce it on my machine. I tried it on Windows Vista, both my NB project as well as the user dir were placed in a directory with spaces. 

Can you reproduce it every time, or is it random? I don't think the fact that CC auto popup is off is relevant (obviously I tried both settings)
Comment 4 Tomasz Slota 2008-06-27 14:26:19 UTC
I am asking Tor for opinion. I copied the code where the exception is thrown from his sources ;-)
Comment 5 carentrica 2008-06-27 14:54:20 UTC
I haven't tried it yet. I will do that next. But other relevant info is:
The CC options I have are:
  Auto Popup Copmpletion Window (off)
  Auto Popup Completion Documentation Window (on)
  Insert Single Proposals Automatically (on)
  Guess Filled Method Arguments (off)
  Case Sensitive Code Completion (off)
  Show Deprecated Members in Code Completion (on)
  Insert Closing Barckets Automatically (on)

Also, the following type of CC works:-

  // looking for is_numeric() here
  if (is<Ctrl-Space> //CC works OK

It only seems to NPE if I Ctrl-Space within "()".

I'll try Auto CC on next.
Comment 6 carentrica 2008-06-27 15:04:50 UTC
I have an even bigger problem with Auto Code Completion on.

I want to $s = substr(...)
I get as far as typing $ and I get an IllegalArgumentException - every time. I'm attaching the log for that.
Comment 7 carentrica 2008-06-27 15:05:50 UTC
Created attachment 63601 [details]
message log (IllegalArgumentException)
Comment 8 carentrica 2008-06-27 16:00:31 UTC
Looking at the first message log I attached, it wasn't an NPE but an IAE.

I now can't seem to Auto Code Completion work. I have to manually invoke with Ctrl-Space.

I also had to delete my netbeans userdir as it seems that something to do with this problem had caused a corruption.
Comment 9 Tomasz Slota 2008-06-27 16:08:14 UTC
I am now able to reproduce a different exception (an NPE) with your steps, hopefully it is the same problem

java.lang.NullPointerException: The file parameter cannot be null
	at org.openide.util.Parameters.notNull(Parameters.java:86)
	at org.netbeans.modules.php.project.api.PhpSourcePath.getFileType(PhpSourcePath.java:87)
	at org.netbeans.modules.php.editor.index.IndexedElement.getFile(IndexedElement.java:171)
	at org.netbeans.modules.php.editor.PHPCompletionItem.getRhsHtml(PHPCompletionItem.java:154)
	at org.netbeans.modules.gsfret.editor.completion.GsfCompletionItem$DelegatedItem.getRightHtmlText(GsfCompletionItem.java:155)
Comment 10 Torbjorn Norbye 2008-06-27 17:06:51 UTC
It sounds like there are several problems here:

(1) You've turned off auto completion, yet somehow code completion is getting invoked automatically as well.  That was a
bug in 6.0 and 6.1, but should be fixed now in 6.5 with Vita's editor settings rewrite (issue 90403).

(2) You're getting an exception during code completion when formatting a code completion item. Is there a good reason
you need the actual -file object- here? That seems like a slow thing to do. In the JavaScript code completion for
example, I call getFileNameUrl() - but that just accesses the URL. I pull out the basename of the file from the URL
itself; I don't actually parse the URL and reconsistitute the path.

(3) The URL has spaces in it, but it isn't a correct URL;  URLs should have %20 instead of spaces.  I'm not sure how
that happened. But the correct way to create a URL string from a file is this:

   file.toURI().toURL().toExternalForm();

In particular, do NOT use file.getURL(). (See http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#toURL() ).
Comment 11 Tomasz Slota 2008-06-27 18:18:45 UTC
Actually my URL seems properly encoded: 

file:/C:/Users/Tomasz%20Slota/.netbeans/dev/config/PHP/RuntimeLibraries/runtime.php

The problem seems to be in the URLMapper.findFileObject() method. Please reassign it to the right component.
Comment 12 Torbjorn Norbye 2008-06-27 18:22:13 UTC
Really? In the earlier IllegalArgumentException stacktrace I saw this:

java.lang.IllegalArgumentException: Illegal character in path at index 18: file:/C:/Documents and Settings/Ian Carter/My
Documents/NetBeansProjects/phpLibs/wwwroot/classes/class.string_lib.php [file:/C:/Documents and Settings/Ian Carter/My
Documents/NetBeansProjects/phpLibs/wwwroot/classes/class.string_lib.php]
[catch] at org.netbeans.modules.masterfs.filebasedfs.FileBasedURLMapper.getFileObjects(FileBasedURLMapper.java:122)
	at org.netbeans.modules.masterfs.MasterURLMapper.getFileObjects(MasterURLMapper.java:61)
	at org.openide.filesystems.URLMapper.findFileObject(URLMapper.java:213)
	at org.netbeans.modules.php.editor.index.PHPIndex.getFileObject(PHPIndex.java:140)

Here there are spaces instead of %20's, for example at offset 18.  Or are you saying that the URL passed into URLMapper
is correct (with %20's) and that it's somehow translated into something else inside of there before the argument
exception is thrown?
Comment 13 Tomasz Slota 2008-06-27 20:15:34 UTC
yes, it looks like a correctly encoded URL gets descrambled in the way
Comment 14 Quality Engineering 2008-06-28 04:16:00 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #286 build
Changeset: http://hg.netbeans.org/main/rev/48ffe4d0aa53
User: Tomasz Slota <tslota@netbeans.org>
Log: #138448: Invoking CC when off by default gives NPE
Comment 15 Jana Maleckova 2008-06-30 09:48:32 UTC
reassign to openide
Comment 16 Jiri Skrivanek 2008-06-30 14:46:46 UTC
I tried the code below and it works. With spaces instead of %20 it throws IllegalArgumentException. Please, give me a
test case or steps how to reproduce.

        String urlPath = "file:/C:/Documents%20and%20Settings/admin/My%20Documents/test.php";
        URL url = new URL(urlPath);
        FileObject fo = URLMapper.findFileObject(url);
Comment 17 Tomasz Slota 2008-06-30 17:57:15 UTC
Yes, it was on my side after all. Should be finally fixed.

Change log:
http://hg.netbeans.org/main/rev/820e749b6845
Comment 18 Quality Engineering 2008-07-01 04:46:46 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #292 build
Changeset: http://hg.netbeans.org/main/rev/820e749b6845
User: Tomasz Slota <tslota@netbeans.org>
Log: #138448: URLMapper.findFileObject() fails for a valid url on Windows
Comment 19 Tomasz Slota 2008-07-01 16:39:59 UTC
Updating to P1, the fix should get into M1 if only possible
Comment 20 Martin Schovanek 2008-07-01 16:55:17 UTC
verified
Comment 21 Martin Schovanek 2008-07-01 16:55:32 UTC
v
Comment 22 Tomasz Slota 2008-07-01 17:43:56 UTC
Fix integrated into the release65_m1 branch.

http://hg.netbeans.org/release65_m1/rev/0e1d269d7093