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 192537 - in case of CloneableEditorSupportRedirector files with symlink can't be opened
Summary: in case of CloneableEditorSupportRedirector files with symlink can't be opened
Status: RESOLVED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Text-Edit (show other bugs)
Version: 7.0
Hardware: All Unix
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-26 15:38 UTC by Vladimir Voskresensky
Modified: 2011-09-21 08:10 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
module with the simplest ces redirector impl (20.00 KB, application/x-tar)
2011-01-16 19:08 UTC, Vladimir Voskresensky
Details
simple java application to observe issues with ces redirector support in NB (80.00 KB, application/x-tar)
2011-01-16 19:11 UTC, Vladimir Voskresensky
Details
Patch for XML module (3.00 KB, patch)
2011-01-20 15:47 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Voskresensky 2010-11-26 15:38:11 UTC
in Studio we have CloneableEditorSupportRedirector implementation and due to this fact standard code [1] used from Go To File implementation (org.netbeans.modules.cnd.makeproject.MakeProjectFileProviderFactory) can not open such files. Opening from project view and files view works, but in big project all navigation is done through Go To File with shows only "Loading..." panel instead of editor.
Can someone evaluation this?

Thanks,
Vladimir.
[1] 
Editable ec = od.getLookup().lookup(Editable.class);
if (ec != null) {
    ec.edit();
} else {
    Openable oc = od.getLookup().lookup(Openable.class);
    if (oc != null) {
        oc.open();
    }
}

Now as workaround I have to use:
EditorCookie erc = od.getCookie(EditorCookie.class);
if (erc != null) {
    try {
        try {
            erc.openDocument();
        } catch (UserQuestionException e) {
            e.confirmed();
            erc.openDocument();
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    erc.open();
}
Comment 1 Vladimir Voskresensky 2010-11-26 15:39:38 UTC
this behavior is reproducible in both versions: trunk and 6.9.1
Comment 2 Quality Engineering 2010-11-27 06:26:55 UTC
Integrated into 'main-golden', will be available in build *201011270001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6cc95196fac1
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: workaround for #192537 -  in case of CloneableEditorSupportRedirector files with symlink can't be opened
Comment 3 Vladimir Voskresensky 2011-01-14 18:17:50 UTC
after change in ces redirector it works fine
Comment 4 Vladimir Voskresensky 2011-01-16 18:46:31 UTC
Unfortunately change in ces redirector was not enough... it cause infinite recusion for XML objects.

It looks like CES Redirector functionality doesn't work.
I will attach a simplest test.
Comment 5 Vladimir Voskresensky 2011-01-16 19:08:37 UTC
Created attachment 105045 [details]
module with the simplest ces redirector impl

install ces redirector impl from attached module into NB
Comment 6 Vladimir Voskresensky 2011-01-16 19:11:58 UTC
Created attachment 105046 [details]
simple java application to observe issues with ces redirector support in NB

extract archive and make sure, that sub folder test has symlinks
Comment 7 Vladimir Voskresensky 2011-01-16 19:18:35 UTC
steps to reproduce:
- unpack provided ces redirector impl module in your trunk source tree
- build it (to generate module in extra cluster)
- run NB with clean userdir
- unpacked JavaApplication2.tar
-- make sure subfolder "test" has symlinks after unpack
- open JavaApplication2
- expand tests and open file make_project.xml
- try to open make_project_link.xml => will be infinite "Loading..." pane
- try to open using "Go To File" file make_project_link2.xml => will be infinite "Loading..." pane

Test_link.java and file_link.cc should be opened through link correctly.
The second problem:
- close all files and collapse tests folder, restart NB
- if you run with not fresh userdir => make_project_link.xml, make_project_link.xml and make_project_link2.xml will be opened as 3 tabs (instead of one) and by making changes in two files with save symlinks are broken and files are saved as plain files (check content of tests subfolder in console)
Comment 8 Vladimir Voskresensky 2011-01-16 19:22:36 UTC
Jarda, can you evaluate, please?
Comment 9 Vladimir Voskresensky 2011-01-17 11:54:03 UTC
Btw, another strange thing is that CESRedirector is called way tooo often.
I.e. there is a scheduled task which called by timer and calls isModified which calls CESRedirector.
expanding folders in Favorites calls CESRedirector all the time for each file selected in tree. Also it is called when expand folder in favorites
Comment 10 Jaroslav Tulach 2011-01-18 19:01:48 UTC
> Behavior could be changed due to introducing "Lazy Loading..." phase 
> for documents.
> Vladimir.
Comment 11 Jaroslav Tulach 2011-01-19 17:29:22 UTC
Looks like the condition at CloneableEditor:354
  if ((support.getDocument() == null) || (support.cesKit() == null))
is not ready for redirecting. The reason why the problem affects only XML and not Java is that is using CES.asynchronousOpen() = true while XML uses false.
Comment 12 Jaroslav Tulach 2011-01-20 15:47:34 UTC
Created attachment 105203 [details]
Patch for XML module
Comment 13 Jaroslav Tulach 2011-01-20 15:49:46 UTC
The problem with XML is that it has its own implementation of edit() and this implementation does not check for redirection. I've just deleted the method and the redirector started to work OK. I leave up to owner of XML module to decide whether this is an acceptable patch.
Comment 14 Leonid Lenyashin 2011-02-02 15:12:30 UTC
Vladimir, can you please indicate if this bug is a Beta stopper or not?
I'd also ask you to contact Sergey directly if you are looking for quick resolution.
Comment 15 Vladimir Voskresensky 2011-02-02 15:50:39 UTC
it's not a Betta stopper
Comment 16 Sergey Lunegov 2011-02-03 08:30:54 UTC
Nikita, please review patch from Jarda
Comment 17 Nikita Krjukov 2011-02-07 21:36:01 UTC
It's a problem to check if the patch effects another XML modules because they are excluded from build procedure. But I think it's acceptable because I think nobody has plan to include them back. Moreover, another XML modules can have similar EditorCookie implementations and they can cause the same bug again.
Comment 18 Marian Mirilovic 2011-02-11 11:21:11 UTC
I am decreasing the priority if it isn't beta stopper.
Comment 19 Petr Jiricka 2011-03-01 17:44:21 UTC
Nikita, so can Jarda's patch be applied? I agree that the additional XML modules will not be added back, although we may publish them on the update center as there is some user demand for this (issue 184379).
Comment 20 Nikita Krjukov 2011-03-01 18:26:32 UTC
I haven't managed to check if the patch had broken something or not. But I think it can be applied. It only necessary to keep in mind that it can be considered not acceptable later if somebody would like to reanimate XML modules. I don't think it would be the only problem at that moment because I haven't listened that XML modules are developing now. But NetBeans seems is moved forward gradually. So the gap between them becomes wider time after time.
Comment 21 Thomas Preisler 2011-03-02 20:18:45 UTC
Removing link to CR_7002932 as the issue is now fixed in the Studio IDE.
Comment 22 Vladimir Voskresensky 2011-03-03 13:34:26 UTC
There is a related CR_7024164
Comment 23 Petr Jiricka 2011-03-03 20:55:53 UTC
> I haven't managed to check if the patch had broken something or not.

I started running XML tests on this Hudson job: http://bertram.netbeans.org/hudson/job/javaee/ (though 16 XML tests are now failing). So after applying the fix, you can check that no additional tests have been broken.
Comment 24 Petr Jiricka 2011-03-14 13:59:15 UTC
Requesting a waiver for NetBeans 7.0.
Comment 25 Petr Jiricka 2011-03-21 11:59:57 UTC
Jarda's patch committed to trunk: http://hg.netbeans.org/web-main/rev/8ebb38b41d8c. Still, it should be tested properly before we potentially decide to put it into release70.

So the issue should now be fixed in trunk, but I am leaving this issue open because of the pending unresolved waiver request.
Comment 27 Quality Engineering 2011-03-24 09:50:21 UTC
Integrated into 'main-golden', will be available in build *201103240400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8ebb38b41d8c
User: pjiricka@netbeans.org
Log: #192537 - committing patch contributed by Jarda Tulach.
Comment 28 Marian Mirilovic 2011-03-24 16:51:45 UTC
Petr, 
what is the status of this issue ? Is it waived or ... ?
Comment 29 Petr Jiricka 2011-03-26 20:17:59 UTC
Yes, waiver is approved.
Comment 30 Petr Jiricka 2011-05-04 09:23:27 UTC
> This change broke a test: 
> .../o.n.m.xml.schema.model/SchemaRefCacheTest/testRedefineSchemaLocationModified/

This was actually a random failure, so I think we are ok.

The changes were committed to trunk after 7.0, so I believe this is fixed for 7.0.1. Vladimir, can you please verify?
Comment 31 Vladimir Voskresensky 2011-05-04 09:30:37 UTC
Thanks Petr,
I will verify as soon as it appears in cnd-main
Comment 32 Vladimir Voskresensky 2011-05-04 14:30:26 UTC
Jarda, can you have a look? Now after applied fix => redirector doesn't work  and multiple instances of xml files are opened instead of one
Comment 33 Vladimir Voskresensky 2011-05-04 14:31:33 UTC
My comments are about xml files only. C++ and Java files works fine (as before)
Comment 34 Petr Jiricka 2011-05-11 12:51:49 UTC
So Vladimir, are you saying the fix caused a regression, and it should be reverted?
Comment 35 Vladimir Voskresensky 2011-05-11 13:04:01 UTC
Hi Petr,
I'm saying, that before fix we had never ending "Loading..." panel instead of editor. Now editors are opened, but each time new tab per opened file (instead of reselecting previously opened tab according to CESRedirector)
Comment 36 Petr Jiricka 2011-06-03 11:59:16 UTC
Ok, so this is partially fixed. Sounds like with this partial fix, this bug is still P2 priority. So I'd like to request a waiver for NB 7.0.1.
Comment 37 Petr Jiricka 2011-06-08 08:25:22 UTC
Waiver approved.
Comment 38 Svata Dedic 2011-09-16 08:22:57 UTC
Applied cesredirector sample module & tried Java application on 09/15 dev build. Goto file & open action seems to work as expected (open file, do not open multiple windows for the same file).

Please verify on a recent dev build.
Comment 39 Vladimir Voskresensky 2011-09-16 12:54:07 UTC
(In reply to comment #38)
> Applied cesredirector sample module & tried Java application on 09/15 dev
> build. Goto file & open action seems to work as expected (open file, do not
> open multiple windows for the same file).
> 
> Please verify on a recent dev build.
I verified using my project attached to this IZ.

And all xml files are opened as file in own tab, instead of one tab.
While *.cc and *.java files are opened correctly.

Note that bug is exactly about links on xml files.
So the infinite "Loading..." is gone due to applied patch
http://hg.netbeans.org/main/rev/8ebb38b41d8c

But original issue is in place:
- ces redirector does not work for links to some files (i.e. xml in our case)
Comment 40 Svata Dedic 2011-09-16 13:35:11 UTC
I understood the issue is about duplicating windows. However I was unable to reproduce the behaviour on current dev sources (OS Ubuntu Linux) - and using the JavaApplication2 project + cesredirector module attached to this issue.

No matter how many times I tried to click on the _link.xml files, subsequent clicks reused the already opened editor. Is there anything other special to be done between two openings of e.g. test/make_project_link.xml ?

The affected platform is set to "UNIX"; are you sure the defect is not just solaris-specific ? Which IDE version/build number do you use ?
Comment 41 Vladimir Voskresensky 2011-09-16 14:49:11 UTC
Thanks for extra evaluation. 
I've checked on Solaris 10 using today's dev version of IDE
Comment 42 Vladimir Voskresensky 2011-09-16 14:53:12 UTC
(In reply to comment #41)
> Thanks for extra evaluation. 
> I've checked on Solaris 10 using today's dev version of IDE
sorry for posting not finished comment.

I've checked on Solaris 10 using today's dev version of IDE and dbl clicking to open files from Project view (Tests folder) open all of them in own tab => 3 tabs
Comment 43 Svata Dedic 2011-09-16 15:05:45 UTC
Got it, thanks.
Comment 44 Vladimir Voskresensky 2011-09-16 16:13:54 UTC
checked on Linux and all 3 files are redirected into one tab
Comment 45 Svata Dedic 2011-09-19 09:04:48 UTC
Reproduced even in Linux; the key point is that the editor for the _link file MUST NOT be cached already in the CookieSet (quite random condition ;)). E.g. if the 1st file being opened after IDE start is the link file, it will open in a separate _link tab instead of redirecting to the original.
Comment 46 Svata Dedic 2011-09-19 10:43:16 UTC
CloneableEditorSupport added to the DO's lookup; will create/use the same instance as if looking up the OpenCookie.
Comment 47 Quality Engineering 2011-09-21 08:10:26 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/d2c100870fae
User: sdedic@netbeans.org
Log: #192537: CloneableEditorSupport must be registered explicitly, otherwise it might not appear in do.getLookup queries