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 244990 - unable to disable pre-built cache fallback mechanism
Summary: unable to disable pre-built cache fallback mechanism
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Module System (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2014-06-10 21:07 UTC by stoto79
Modified: 2014-07-16 01:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stoto79 2014-06-10 21:07:34 UTC
In JDev we came across the following scenario:

1) jdeveloper/netbeans/bridge/var/cache is installed in a shared, read-only file location. The entire Jdev  & NB is installed not locally but on a shared server. We can't delete var/cache . The .lastModified file under it (the file we're supposed to touch to invalidate the caches) is also read-only.
2) We start JDev with autodiscovery on, the first time, and because of auto-discovery in our bootstrapping code we determine that we must invalidate the caches.  But because of 1) can't really do that, we simply proceed and (the way things currently work) call launchNBMain()
3) org.netebans.Stamps.findFallbackCache() then finds and loads the pre-built caches, as it does not know that the caches are (or rather must be) invalid.

Because the caches' contents are wrong, but not broken, the IDE does start, only without doing any of the scanning that comes with auto-discovery.

We want the fallback cache to be ignored, but outside a system property we, on the IDE side, can't communicate to the NB startup code to ignore the cache. I've told our client to delete the cache, but assuming that may not always be possible for a given user (e.g. say the user does not have permission to do it) or desired (e.g. for other clients, who didn't have auto-discovery on, and for whom the cache is valid), can the NB code handle this case differently? It can either rely on a system property, for example, or we can pass in a parameter to MainImpl.main() maybe?

I can send a patch where this works with a system property, let me know if that's OK, and if so what do you want that system property name to be (e.g. more in line with NB's standards).
Comment 1 Jaroslav Tulach 2014-06-16 14:51:24 UTC
You can probably influence the behavior by pre-pending empty directory to "netbeans.dirs" property. Then dirs()[0] will be empty and no fallback cache will appear at all. But I agree, new property is cleaner way...

Let's name the new property

"netbeans.fallback.cache"

and by default set it to dirs()[0]"/var/cache" to keep consistency with existing behavior. If set to "none", let's ignore the fallback cache all-together.
Comment 2 stoto79 2014-06-17 17:36:53 UTC
OK, I agree. So here is the new org.netebans.Stamps.findFallbackCache(String cache):    

   private static File findFallbackCache(String cache) {
        String fallbackCacheLocation = System.getProperty("netbeans.fallback.cache"); // NOI18N
        if ("none".equals(fallbackCacheLocation)) { // NOI18N
            return null;
        }
        
        if (fallbackCache == null) {
            fallbackCache = new File[0];
            if (fallbackCacheLocation != null) {
                File fallbackFile = new File(fallbackCacheLocation);
                if (fallbackFile.isDirectory()) {
                    fallbackCache = new File[]{ fallbackFile }; 
                }
            }
            if (fallbackCache.length == 0 &&  dirs().length >= 1) {
                File fallback = new File(new File(new File(dirs()[0]), "var"), "cache"); // NOI18N
                if (fallback.isDirectory()) {
                    fallbackCache = new File[]{ fallback };
                }
            }
        }
        if (fallbackCache.length == 0) {
            return null;
        }
        return new File(fallbackCache[0], cache);
    }
Comment 3 Jaroslav Tulach 2014-06-27 08:04:09 UTC
Y01 The best way to produce diff is to use 

$ hg diff

and attach the resulting file. this

Y02 api changes like introduction of new property are subject to review

Y03 missing description in module's arch.xml

Y04 missing test
Comment 4 Jaroslav Tulach 2014-06-27 08:49:07 UTC
Proposal for review:
https://hg.netbeans.org/ergonomics/rev/b922e98fdfa8
Comment 5 stoto79 2014-07-10 21:51:14 UTC
Looks good. I am not sure if I should do anything more to fully review the transaction (e.g. set status, add tag), but it all looks good from my side.
Comment 6 Jaroslav Tulach 2014-07-15 12:41:22 UTC
OK, let's propagate the change into main code line then.
Comment 7 Quality Engineering 2014-07-16 01:44:50 UTC
Integrated into 'main-silver', will be available in build *201407160001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b922e98fdfa8
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #244990: Support for netbeans.fallback.cache property