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 46436 - [tests] Unchanged resource after a move class refactoring
Summary: [tests] Unchanged resource after a move class refactoring
Status: CLOSED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 4.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Jan Becicka
URL:
Keywords: RANDOM, T9Y
Depends on:
Blocks:
 
Reported: 2004-07-22 12:13 UTC by ehucka
Modified: 2007-04-03 18:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The second exception's stacktrace. (5.61 KB, text/plain)
2004-07-23 09:21 UTC, ehucka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ehucka 2004-07-22 12:13:09 UTC
I run tests in
nbcvs:/refactoring/test/qa-functional, attribute
'move'. The 'testClass3' test is failing because
of NPE:

java.lang.NullPointerException
org.netbeans.modules.javacore.JMManager.isElementGuarded(JMManager.java:450)
org.netbeans.modules.refactoring.WhereUsedElement.<init>(WhereUsedElement.java:94)
org.netbeans.modules.refactoring.RenameUsageElement.<init>(RenameUsageElement.java:27)
org.netbeans.modules.refactoring.RenameFullNameElement.<init>(RenameFullNameElement.java:30)
org.netbeans.modules.refactoring.api.MoveClassRefactoring.checkWhereUsed(MoveClassRefactoring.java:425)
org.netbeans.modules.refactoring.api.MoveClassRefactoring.checkWhereUsed(MoveClassRefactoring.java:378)
org.netbeans.modules.refactoring.api.MoveClassRefactoring.prepare(MoveClassRefactoring.java:196)
org.netbeans.test.refactoring.move.SimpleTest.moveClass(SimpleTest.java:143)
org.netbeans.test.refactoring.move.SimpleTest.testClass3(SimpleTest.java:86)
Comment 1 Martin Matula 2004-07-22 12:18:45 UTC
is this a regression or this was the first time you were running the test?
Comment 2 ehucka 2004-07-22 12:25:19 UTC
no, I forgot to create an issue for this. I see it there for about two
weeks (since i created the tests).
Comment 3 Jan Becicka 2004-07-22 17:36:49 UTC
I don't understand why this issue is P2. I tried to run this tests and 
75% of them failing because of "Golden file differs". I cannot
reproduce it. Our unit tests works, and this issue is not reproducible
"by hand".
Comment 4 ehucka 2004-07-23 09:20:48 UTC
Yesterday, I run the test on 7 machines. Tests testClass3, testClass4
testClass5 failed in 50% by the reason of this exception. The next 50%
of their failing were caused by
javax.jmi.reflect.InvalidObjectException: Object with MOFID ... no
longer exists.
Comment 5 ehucka 2004-07-23 09:21:52 UTC
Created attachment 16405 [details]
The second exception's stacktrace.
Comment 6 Jan Becicka 2004-07-27 12:24:52 UTC
I still cannot reproduce NPE. IOE is duplicate of issue 46208.
Comment 7 ehucka 2004-07-28 11:55:33 UTC
I've seen it again in several tests. Could you catch the NPE there and
throw an exception with some debug information?
Comment 8 Jan Becicka 2004-07-28 12:00:29 UTC
We must fix reproducible InvalidObjectException first.
Comment 9 ehucka 2004-08-19 14:45:52 UTC
I made a little research about this NPE. The NPE is thrown becauseof
DataObject of resource (resource of checked element) is null.
The bad resource points to bad location, to a file which was
previously moved into default package:

a/b/c/A.java was moved to A.java bud resource name still shows
a/b/c/A.java
Comment 10 Jan Becicka 2004-08-23 10:03:22 UTC
Cannot reproduce in latest build.
Expected passes: 81, Unexpected fails: 15.

15 test failed due to AssertionFileFailedError: Golden file differs -
no NPE.
Comment 11 ehucka 2004-09-06 14:10:20 UTC
Move class tests are randomly failing by this NPE or FileNotFound
exception. I think the reason is a resource of a moved class remains
unchanged to the next testrun - it produces the NPE - DataObject of
this class is null or FNFE from tests - tests try to find source file
of moved class by its resource name to compare.
Comment 12 Jan Becicka 2004-09-06 14:48:21 UTC
What FileNotFound Exception?

Anyway, please use this pattern for access java meta model.
JavaMetamodel.getDefaultRepository().beginTrans(true);
try {
//do JMI stuff
} finally {
  JavaMetamodel.getDefaultRepository().endTrans();
}

Never call JMI outside transaction. You do that in your tests:
try {
  Resource resource = (Resource) jc.refImmediateComposite(); 
  //!!!JMI call outside transaction!!!
  FileObject targetFolder = URLMapper.findFileObject(new
File(classPathWorkDir, newPackage.replace('.','/')).toURL());
  Utility.prepareTest();
  //!!!this should be called before try statement!!!


Comment 13 ehucka 2004-09-06 15:34:33 UTC
Thank you, i'll repair it and watch for future results.
Comment 14 Jan Becicka 2004-09-09 12:33:19 UTC
Still cannot reproduce. Only one test failed probably due to issue 46669.
Comment 15 Jan Becicka 2004-09-20 16:30:05 UTC
Emane, are you able to reproduce it?
Comment 16 ehucka 2004-09-21 15:39:30 UTC
I haven't seen it for days.
Comment 17 Jan Becicka 2004-09-22 09:39:45 UTC
This issue is no more reproducible.
Comment 18 ehucka 2004-10-25 15:01:30 UTC
verified