Skip to content

Commit

Permalink
Merge pull request #28 from jGauravGupta/FISH-6432-6x
Browse files Browse the repository at this point in the history
FISH-6432 Applications Take Longer To Deploy on JDK 17 (Payara 6.x)
  • Loading branch information
jGauravGupta authored Feb 6, 2023
2 parents 84cd5da + 9fff4aa commit aa3e272
Show file tree
Hide file tree
Showing 81 changed files with 186 additions and 120 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-bom</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
<packaging>pom</packaging>

<name>HK2 Bom Pom</name>
Expand Down
2 changes: 1 addition & 1 deletion class-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-parent</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<groupId>org.glassfish.hk2</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -47,14 +48,6 @@ public Collection<URI> getDefiningURIs() {

synchronized void addDefiningURI(URI uri) {
definingURIs.add(uri);
try {
File file = new File(uri);
// assert(file.exists()) : file + " does not exist";
definingURIs.add(file.getCanonicalFile().toURI());
} catch (IOException e) {
// ignore, this is a safeguard for confused user's code that do not
// deal well with file path.
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion examples/caching/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/caching/runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>caching-aop-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>caching-aop-example-runner</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/caching/system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>caching-aop-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>caching-aop-example-system</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/configuration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration/webserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>configuration-examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>webserver-configuration-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/configuration/xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>configuration-examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>xml-configuration-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-resolver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<artifactId>custom-resolver-example</artifactId>
<name>Custom Resolver Example</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/events/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/events/threaded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>event-examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>threading-event-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/operations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<artifactId>operations-example</artifactId>
<name>Operations Example</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-parent</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/security-lockdown/alice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>security-lockdown-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>security-lockdown-example-alice</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/security-lockdown/mallory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>security-lockdown-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>security-lockdown-example-mallory</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/security-lockdown/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>examples</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples/security-lockdown/runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>security-lockdown-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>security-lockdown-example-runner</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/security-lockdown/system/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>security-lockdown-example</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>security-lockdown-example-system</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion external/aopalliance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>external</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>aopalliance-repackaged</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion external/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-parent</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion guice-bridge/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-parent</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>guice-bridge</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion hk2-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-parent</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,6 +18,7 @@
package org.glassfish.hk2.internal;

import java.lang.annotation.Annotation;
import org.glassfish.hk2.utilities.CleanerFactory;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
Expand Down Expand Up @@ -114,10 +116,14 @@ public void destroyOne(ActiveDescriptor<?> descriptor) {
}

private static class InheritableContextThreadWrapper {
private final HashMap<ActiveDescriptor<?>, Object> instances =
new HashMap<ActiveDescriptor<?>, Object>();

private final HashMap<ActiveDescriptor<?>, Object> instances = new HashMap<>();
private final long id = Thread.currentThread().getId();

public InheritableContextThreadWrapper() {
registerStopEvent();
}

public boolean has(ActiveDescriptor<?> d) {
return instances.containsKey(d);
}
Expand All @@ -130,13 +136,14 @@ public void put(ActiveDescriptor<?> d, Object v) {
instances.put(d, v);
}

@Override
public void finalize() throws Throwable {
instances.clear();
public final void registerStopEvent() {
CleanerFactory.create().register(this, () -> {
instances.clear();

if (LOG_THREAD_DESTRUCTION) {
Logger.getLogger().debug("Removing PerThreadContext data for thread " + id);
}
if (LOG_THREAD_DESTRUCTION) {
Logger.getLogger().debug("Removing PerThreadContext data for thread " + id);
}
});
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,6 +18,7 @@
package org.glassfish.hk2.internal;

import java.lang.annotation.Annotation;
import org.glassfish.hk2.utilities.CleanerFactory;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
Expand Down Expand Up @@ -117,10 +119,14 @@ public void destroyOne(ActiveDescriptor<?> descriptor) {
}

private static class PerContextThreadWrapper {
private final HashMap<ActiveDescriptor<?>, Object> instances =
new HashMap<ActiveDescriptor<?>, Object>();

private final HashMap<ActiveDescriptor<?>, Object> instances = new HashMap<>();
private final long id = Thread.currentThread().getId();


public PerContextThreadWrapper() {
registerStopEvent();
}

public boolean has(ActiveDescriptor<?> d) {
return instances.containsKey(d);
}
Expand All @@ -133,13 +139,14 @@ public void put(ActiveDescriptor<?> d, Object v) {
instances.put(d, v);
}

@Override
public void finalize() throws Throwable {
instances.clear();

if (LOG_THREAD_DESTRUCTION) {
Logger.getLogger().debug("Removing PerThreadContext data for thread " + id);
}
public final void registerStopEvent() {
CleanerFactory.create().register(this, () -> {
instances.clear();

if (LOG_THREAD_DESTRUCTION) {
Logger.getLogger().debug("Removing PerThreadContext data for thread " + id);
}
});
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2023 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.hk2.utilities;

import java.lang.ref.Cleaner;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ThreadFactory;

/**
* CleanerFactory provides a Cleaner reference which is created on the first
* reference to the CleanerFactory.
*/
public final class CleanerFactory {

/* The common Cleaner. */
private final static Cleaner commonCleaner = Cleaner.create(new ThreadFactory() {
@Override
public Thread newThread(final Runnable r) {
return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Thread run() {
Thread t = new Thread(null, r, "Common-Cleaner");
t.setPriority(Thread.MAX_PRIORITY - 2);
return t;
}
});
}
});


/**
* This Cleaner will run on a thread whose context class loader
* is {@code null}. The system cleaning action to perform in
* this Cleaner should handle a {@code null} context class loader.
*
* @return a common cleaner reference
*/
public static Cleaner create() {
return commonCleaner;
}
}
2 changes: 1 addition & 1 deletion hk2-configuration/hk2-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-configuration</artifactId>
<version>3.0.1.payara-p1</version>
<version>3.0.1.payara-p2</version>
</parent>

<artifactId>hk2-configuration-integration</artifactId>
Expand Down
Loading

0 comments on commit aa3e272

Please sign in to comment.