Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 166327 - NullPointerException at org.netbeans.modules.java.source.save.CasualDiff.diffBreak
NullPointerException at org.netbeans.modules.java.source.save.CasualDiff.diff...
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Source
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Max Sauer
issues@java
http://statistics.netbeans.org/except...
EXCEPTIONS_REPORT 67patch1-verified
:
Depends on:
Blocks: 166324
  Show dependency treegraph
 
Reported: 2009-06-01 10:00 UTC by Max Sauer
Modified: 2009-07-20 12:42 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
stacktrace (4.53 KB, text/plain)
2009-06-01 10:00 UTC, Max Sauer
Details
proposed fix (2.16 KB, text/plain)
2009-06-06 23:24 UTC, fommil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Max Sauer 2009-06-01 10:00:02 UTC
Build: NetBeans IDE Dev (Build 090529)
VM: Java HotSpot(TM) Client VM, 1.5.0_16-133, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b06-284
OS: Mac OS X, 10.5.6, i386

User Comments:
msauer: Have following class:

package test;

public class Test {

    public static void test(int y) {
        for (int u = y;;) {
            if (y == 0)
                break;
            else
                y++;
        }
    }
}

Select whole if-else tree and Introduce method => NPE. This used to work until some fixes had been made on May 22 in CasualDiff and TreeMaker.



Stacktrace: 
java.lang.NullPointerException
        at org.netbeans.modules.java.source.save.CasualDiff.diffBreak(CasualDiff.java:1065)
        at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl(CasualDiff.java:2684)
        at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:2583)
        at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:2571)
        at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:3115)
        at org.netbeans.modules.java.source.save.CasualDiff.diffIf(CasualDiff.java:1029)
Comment 1 Max Sauer 2009-06-01 10:00:07 UTC
Created attachment 83055 [details]
stacktrace
Comment 2 Rastislav Komara 2009-06-03 09:59:01 UTC
@fommil: It is caused by one of patches for diff created by you. Please, try to fix it. If you are unable, please let me
know.
Comment 3 fommil 2009-06-03 12:46:42 UTC
I can certainly look at it, but can't guarantee timescales.
Comment 4 Max Sauer 2009-06-03 13:10:39 UTC
I've added org.netbeans.api.java.source.gen.BreakContinueTest.testBreak166327() to cover this.
---
http://hg.netbeans.org/jet-main/rev/05c113176b5d

Comment 5 Quality Engineering 2009-06-04 08:58:02 UTC
Integrated into 'main-golden', will be available in build *200906040201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/05c113176b5d
User: Max Sauer <msauer@netbeans.org>
Log: #166327: adding test
Comment 6 fommil 2009-06-06 23:24:23 UTC
Created attachment 83281 [details]
proposed fix
Comment 7 fommil 2009-06-06 23:27:59 UTC
Proposed fix is also a fix for 166324.

The existing code assumes that both the old and new trees have a label part. e.g. "break innerLoop;"

The patch does not make this assumption.

However, there are two things about the existing code that I do not like. They are perpetuated in the proposed fix:-

1 - There is an assumption that there is only a single space character of whitespace between the break/continue and the label.
2 - There is a lot of code duplication between diff{Break, Continue}. I thought about using a helper method, but didn't want to obfuscate the proposed fix 
in the process.
Comment 8 Max Sauer 2009-06-08 08:33:06 UTC
OK, I'll apply the fix. As for 1), I think we can live with that, since this is the typical usecase and conforms with formatter. Thanks, Sam.
Comment 9 Max Sauer 2009-06-08 13:02:11 UTC
Polished and integrated. Marking as FIXED.
---
http://hg.netbeans.org/jet-main/rev/cd0de99b63bb
Comment 10 Quality Engineering 2009-06-11 08:52:19 UTC
Integrated into 'main-golden', will be available in build *200906110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/cd0de99b63bb
User: Max Sauer <msauer@netbeans.org>
Log: #166327: NPE at o.n.m.java.source.save.CasualDiff.diffBreak
Comment 11 Petr Blaha 2009-07-02 13:23:39 UTC
v.
Comment 12 pgebauer 2009-07-09 09:49:24 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/fa32503210b0
Comment 13 pribyl 2009-07-16 11:04:15 UTC
Product Version: NetBeans IDE 6.7.1 RC (Build 200907150227)
Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

Verified in 6.7.1 RC


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