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 225314 - 4.2s - j2ee.deployment.impl.Server.getOptionalFactory()
Summary: 4.2s - j2ee.deployment.impl.Server.getOptionalFactory()
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Petr Hejl
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2013-01-25 04:35 UTC by Exceptions Reporter
Modified: 2015-05-18 15:30 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 197972


Attachments
nps snapshot (89.71 KB, application/nps)
2013-01-25 04:35 UTC, Exceptions Reporter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Exceptions Reporter 2013-01-25 04:35:18 UTC
This bug was originally marked as duplicate of bug 174134, that is already resolved. This bug is still valid, so this seems to be another bug, but it might be related.

Build: NetBeans IDE 7.3 Beta (Build 201210011125)
VM: Java HotSpot(TM) Client VM, 10.0-b19, Java(TM) SE Runtime Environment, 1.6.0_04-b12
OS: Windows Vista
Maximum slowness yet reported was 4230 ms, average is 4230
Comment 1 Exceptions Reporter 2013-01-25 04:35:22 UTC
Created attachment 130614 [details]
nps snapshot
Comment 2 Petr Hejl 2013-06-18 10:13:54 UTC
There are two things:
1) Maybe the GF should register optional factory via org.netbeans.modules.j2ee.deployment.plugins.spi.support.ProxyOptionalFactory. I'm not sure about side effects such as race condition in initialization.
2) GlassfishInstance.hashCode() is touching the disk. Actually not just touching - it is copying stuff.
Comment 3 TomasKraus 2013-08-04 00:14:11 UTC
    public int hashCode() {
        StringBuilder sb = new StringBuilder(
                getDeployerUri().replace("127.0.0.1", "localhost"));
        sb.append(getHttpPort());
        sb.append(getDomainsRoot());
        sb.append(getDomainName());
        return sb.toString().hashCode();
    }

This looks quite safe when you look at it. But getDomainsRoot() can initialize new domains root when the one registered in GF is read only and it has to initialize whole GF domain.
So yes, this is bad. Displayname is 100% unique so maybe it's safe enough to use this String to generate hash. The only problem is, that those strings are usually very similar (their code distance is very low). String hash is being computed as s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] so this seems to be safe - it usually differs at the end and looks like this method will guarantee some spread of those values.
I'll change it to String hash from display name.

I see GlassfishInstance.loadServerInstances as the most critical part of this snapshot. What will this optional factory registration do? We need to kick GlassfishInstanceProvider somehow and the best place is some asynchronous task far from AWT thread.

This is the same as Bug# 233869 - I added you into cc list - asynchronous access to GlassfishInstanceProvider before anythyng else touches it would help.
Comment 4 TomasKraus 2013-08-05 18:24:05 UTC
2) is fixed, checked int web-main:
----------------------------------
changeset:   260328:f17b5b02564a
summary:     #225314 - GlassfishInstance#hashCode() rewritten
             to use server display name which is mandatory and unique
Comment 5 Quality Engineering 2013-08-07 02:27:02 UTC
Integrated into 'main-silver', will be available in build *201308062300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f17b5b02564a
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #225314 - GlassfishInstance#hashCode() rewritten to use server display name which is mandatory and unique
Comment 6 Petr Hejl 2015-05-18 15:30:35 UTC
#1 has been fixed recently in another issue.