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 241884 - [regression] Incorrect navigation for exception from tests
Summary: [regression] Incorrect navigation for exception from tests
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-14 15:45 UTC by dkozorez
Modified: 2014-02-19 02:47 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test projects (30.43 KB, application/x-zip-compressed)
2014-02-14 15:47 UTC, dkozorez
Details
patch (3.71 KB, patch)
2014-02-17 13:18 UTC, Theofanis Oikonomou
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dkozorez 2014-02-14 15:45:36 UTC
Here are 2 test projects. Both of them contain classes with the same absolute name (e.g. including package names). There are fake exceptions in code. 
While running first attached app there's an exception with link to Project1.java:line 19 and while testing it the same code is called and the same exception is reported. But by clicking on trace in output it jupms to project2.
If it doesn't reproduce try vise verca.
Comment 1 dkozorez 2014-02-14 15:47:19 UTC
Created attachment 145210 [details]
test projects
Comment 2 Vladimir Voskresensky 2014-02-14 16:23:20 UTC
-J-Dlogger.max.line.length=2000
Comment 3 Vladimir Voskresensky 2014-02-14 16:36:31 UTC
Jarda, line with classpath is skipped due to:
JavaAntLogger.messageLogged
        if (line.length() >= LOGGER_MAX_LINE_LENGTH) { // too long message, probably coming from user, so do not check for stacktrace
            return null;
        }

LOGGER_MAX_LINE_LENGTH is 1000 by default
while for empty project during test run it is 1324 symbols 
shouldn't we rise default to i.e.
Comment 4 Vladimir Voskresensky 2014-02-14 16:37:33 UTC
caused by http://hg.netbeans.org/cnd-main/rev/b4fa9a93fca1

1000  symbols is too short for line where class path is printed
Comment 5 Theofanis Oikonomou 2014-02-14 17:02:29 UTC
I am on jdk7 at home but I will have a look also on Monday at the office where I have jdk8 installed. with jdk7 I cannot reproduce from Test Results Window. Tried the following:

tested project1
tried clicking the failing method node in TRW or any of the stack trace nodes and I am correctly navigated to the respective files of Project1

tested project2
tried clicking the failing method node in TRW or any of the stack trace nodes and I am correctly navigated to the respective files of Project2

There were issues though, like the one you describe in comment 1, when trying to navigate to the files from the output window.

For now setting some higher number 2000 or 3000 for the LOGGER_MAX_LINE_LENGTH I believe solves the issue. I will investigate a little bit more on Monday and if there are no more complications I can change the default value.
Comment 6 Theofanis Oikonomou 2014-02-17 13:18:37 UTC
Created attachment 145303 [details]
patch

It seems to me that this is not an issue with the size of the LOGGER_MAX_LINE_LENGTH. 

If I change project1 package name to say project2 in Project2 then I can 100% correctly navigate to the desired file from output window. 

The problem is in the way GlobalPathRegistry tries to find a specific resource.
"...
In case more than one source root contains the resource, one is chosen arbitrarily.
..."

so because project1.*.java is present in both projects one is randomly returned and so some times you can navigate to the correct file and some times not.

I believe the patch solved the issue. Could you please verify before I push it? Thank you
Comment 7 Theofanis Oikonomou 2014-02-17 13:20:11 UTC
Since this is not my area Martin, Milos any comments on that?
Comment 8 Vladimir Voskresensky 2014-02-17 15:07:52 UTC
Fanis, when I debug the test case I clear see that current class path stored in 
getCurrentSourceRootsForClasspath(data) is not found, so the following is not executed. When I increase LOGGER_MAX_LINE_LENGTH then
            Matcher m2 = CLASSPATH_ARGS.matcher(line);
            if (m2.find()) {
                String cp = m2.group(1);
                data.setClasspath(cp);
            }
start to work and getCurrentSourceRootsForClasspath(data) has needed info
Comment 9 Vladimir Voskresensky 2014-02-17 15:08:57 UTC
May be your fix for GlobalPathRegistry is needed as well, but to have fast coloring I think data.setClasspath(cp); should be executed
Comment 10 Theofanis Oikonomou 2014-02-17 17:22:57 UTC
(In reply to Vladimir Voskresensky from comment #9)
> May be your fix for GlobalPathRegistry is needed as well, 

well with the provided projects it is obvious that the specific testcase is not covered and probably my or some other patch needs to be pushed

> but to have fast
> coloring I think data.setClasspath(cp); should be executed

so there is a line of message that is logged and is more than 1000 characters long and you need to color it or something IIUC? Could you provide such message that is logged so that I understand what we are dealing with? If I am not mistaken the stacktraces are logged line by line. 

The problem I was trying to solve and I introduced this max limit was that the matcher throws exception if it tries to match against a huge string, thus 1000 characters set as max. I took as granted that such long string would probably be something the user is printing and so no need to hyperlink or color it. If no-one has any objections I could increase this to 2000 or 3000 characters.
Comment 11 Vladimir Voskresensky 2014-02-18 10:43:57 UTC
(In reply to Theofanis Oikonomou from comment #10)
> (In reply to Vladimir Voskresensky from comment #9)
> > May be your fix for GlobalPathRegistry is needed as well, 
> 
> well with the provided projects it is obvious that the specific testcase is
> not covered and probably my or some other patch needs to be pushed
> 
> > but to have fast
> > coloring I think data.setClasspath(cp); should be executed
> 
> so there is a line of message that is logged and is more than 1000
> characters long and you need to color it or something IIUC? Could you
> provide such message that is logged so that I understand what we are dealing
> with? If I am not mistaken the stacktraces are logged line by line. 
When I debug I see the following:
there is a log event of verbose level with content 
"-classpath ....."
and this line is 1324 symbols long. It is not user's line, it is ant verbose message.
This is the line analyzed by code:
            Matcher m2 = CLASSPATH_ARGS.matcher(line);
            if (m2.find()) {
                String cp = m2.group(1);
                data.setClasspath(cp);
            }
and it is not analyzed by default due to 
        if (line.length() >= LOGGER_MAX_LINE_LENGTH) { // too long message
            return null;
        }
If it would be analyzed => data.setClasspath(cp); is called and fast classpathc check is initialized =>
later on when stack trace lines are analyzed it is tried to be be colored as hyperlinkable with the code:
        if (parse != null) {
            // Check to see if the class is listed in our per-task sourcepath.
            // XXX could also look for -Xbootclasspath etc., but probably less important
            for (FileObject root : getCurrentSourceRootsForClasspath(data)) {

if getCurrentSourceRootsForClasspath(data) is not initialized before by data.setClasspath(cp); => this fast path is not executed and slow GlobalPathRegistry path is used as fallback.
Comment 12 Theofanis Oikonomou 2014-02-18 11:09:07 UTC
Changeset: dfc79aa09a87
Author:    Theofanis Oikonomou <theofanis@netbeans.org>
Date:      2014-02-18 12:10
Message:
Comment 13 Theofanis Oikonomou 2014-02-18 11:12:02 UTC
updated default LOGGER_MAX_LINE_LENGTH value to 3000 as requested and documented the system property in arch description of both ant and java.project modules.
Comment 14 Quality Engineering 2014-02-19 02:47:36 UTC
Integrated into 'main-silver', will be available in build *201402190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/dfc79aa09a87
User: Theofanis Oikonomou <theofanis@netbeans.org>
Log: Task #241884 - [regression] Incorrect navigation for exception from tests