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 202396 - Module PHP Refactoring threw java.lang.NullPointerException.
Summary: Module PHP Refactoring threw java.lang.NullPointerException.
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.0.1
Hardware: PC Linux
: P2 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-21 08:46 UTC by amit147
Modified: 2011-09-27 07:18 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
messages.log (206.45 KB, text/plain)
2011-09-21 14:18 UTC, amit147
Details
a source file with the utf-8 problem (see attachment default.tpl) (1.07 KB, application/octet-stream)
2011-09-22 10:56 UTC, amit147
Details

Note You need to log in before you can comment on or make changes to this bug.
Description amit147 2011-09-21 08:46:33 UTC
While using Find Usages (not Refactoring!) on a method, an exception is thrown:

Module PHP Refactoring threw java.lang.NullPointerException. Please report a bug against PHP Refactoring module and attach your var/log/messages.log.
Comment 1 Tomas Mysik 2011-09-21 14:09:16 UTC
(In reply to comment #0)
> Please report a bug against PHP Refactoring module

Thanks for doing that.

> attach your var/log/messages.log.

Please, do so otherwise we are not able to fix the problem.

Thanks.
Comment 2 amit147 2011-09-21 14:18:48 UTC
Created attachment 110968 [details]
messages.log

messages.log with nullpointer exception
Comment 3 amit147 2011-09-21 14:20:02 UTC
Sorry, thought already had attached it... :)
Comment 4 Tomas Mysik 2011-09-21 14:23:16 UTC
Thanks a lot, reopening.
Comment 5 Petr Pisl 2011-09-21 15:48:56 UTC
From the log file, it looks like there are files that are not in UTF-8 encoding and VM is not able to read them in UTF-8. Your project has UTF-8 encoding, i'm right? Is it possible that there are not UTF-8 files?
Comment 6 amit147 2011-09-22 06:55:22 UTC
Yes that is possible. 
Before opening some files, I got a message saying that they were not utf-8.
I do not know if it was related to the null pointer exception though.
Comment 7 Petr Pisl 2011-09-22 09:27:03 UTC
I think that this is possible, because for creating preview there is need to create a swing document. I'm afraid that the reading of the document fails, so the initialization fails and some property of the project are not initialized correctly. 

Could you please find such file and attach here if it's possible. This is my guess and I would like to confirm it.
Comment 8 Petr Pisl 2011-09-22 10:55:54 UTC
I'm sorry, I mean property of the visual element not the project from my last comment:).
Comment 9 amit147 2011-09-22 10:56:44 UTC
Created attachment 111024 [details]
a source file with the utf-8 problem (see attachment default.tpl)

I found a source file with the utf-8 problem (see attachment default.tpl)
Comment 10 Petr Pisl 2011-09-22 12:51:40 UTC
Thanks for the file. Now it's clear and I can reproduce it, that the problem is caused with the files in an encoding, which is not compatible with the project encoding. 

The right solution would be to have all files in one encoding. I will try to workaround somehow this situation on NetBeans site, but the refactoring doesn't have to work correctly for these cases, because the reading of such file will not be correct. 

It can be solved by introducing encoding property per file as well, but I'm not sure, whether we want it. 

I'm curious about your case. Why you have some files in different encoding?
Comment 11 amit147 2011-09-22 12:58:28 UTC
Hi thx for your explanation.
We have a fairly large code base, about 500K lines, some of them very old and I think those old filed were made with different IDE's maybe with different encodings...
Comment 12 Petr Pisl 2011-09-23 07:58:27 UTC
Changing back the original summary, because the issue is really about the NPE in refactoring.
Comment 13 Petr Pisl 2011-09-23 08:06:00 UTC
Fixed in web main.
http://hg.netbeans.org/web-main/rev/35c9c30aad81

The current behavior is that if the usage is find in a file, that can not be safely open for writing, the preview window contains error message for the file.
Comment 14 Quality Engineering 2011-09-24 14:03:52 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/35c9c30aad81
User: Petr Pisl <ppisl@netbeans.org>
Log: #202396 - Module PHP Refactoring threw java.lang.NullPointerException.
Comment 15 Vladimir Riha 2011-09-27 07:13:39 UTC
Verified, no problem occurred with attached tpl file


Product Version: NetBeans IDE 7.1 Beta (Build 201109252201)
Product Version: NetBeans IDE Dev (Build 201109260601)
Java: 1.7.0; Java HotSpot(TM) Client VM 21.0-b17
System: Linux version 2.6.38-11-generic running on i386; UTF-8; en_US (nb)
Comment 16 amit147 2011-09-27 07:18:45 UTC
Thank you, much appreciated!