Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 138448 - URLMapper.findFileObject() fails for a valid url on Windows
URLMapper.findFileObject() fails for a valid url on Windows
Product: php
Classification: Unclassified
Component: Editor
All Windows XP
: P1 (vote)
: 6.x
Assigned To: Tomasz Slota
Depends on:
  Show dependency treegraph
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

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

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(
	at org.netbeans.modules.php.project.api.PhpSourcePath.getFileType(
	at org.netbeans.modules.php.editor.index.IndexedElement.getFile(
	at org.netbeans.modules.php.editor.PHPCompletionItem.getRhsHtml(
	at org.netbeans.modules.gsfret.editor.completion.GsfCompletionItem$DelegatedItem.getRightHtmlText(
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:


In particular, do NOT use file.getURL(). (See ).
Comment 11 Tomasz Slota 2008-06-27 18:18:45 UTC
Actually my URL seems properly encoded: 


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
[catch] at org.netbeans.modules.masterfs.filebasedfs.FileBasedURLMapper.getFileObjects(
	at org.netbeans.modules.masterfs.MasterURLMapper.getFileObjects(
	at org.openide.filesystems.URLMapper.findFileObject(
	at org.netbeans.modules.php.editor.index.PHPIndex.getFileObject(

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
User: Tomasz Slota <>
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:
Comment 18 Quality Engineering 2008-07-01 04:46:46 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #292 build
User: Tomasz Slota <>
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
Comment 21 Martin Schovanek 2008-07-01 16:55:32 UTC
Comment 22 Tomasz Slota 2008-07-01 17:43:56 UTC
Fix integrated into the release65_m1 branch.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo