Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-3939 Remove Google Guava #4118

Merged
merged 6 commits into from Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,7 +41,6 @@

package org.glassfish.admingui.common.handlers;

import com.google.common.collect.ImmutableMap;
import com.sun.enterprise.universal.xml.MiniXmlParser.JvmOption;
import com.sun.jsftemplating.annotation.Handler;
import com.sun.jsftemplating.annotation.HandlerInput;
Expand Down Expand Up @@ -792,15 +791,17 @@ public static void saveSecurityManagerValue(HandlerContext handlerCtx){
for (Map<String, String> origOption : list){
newOptions.add(origOption);
}
newOptions.add(ImmutableMap.of(JVM_OPTION, JVM_OPTION_SECURITY_MANAGER));
newOptions.add(Collections.singletonMap(JVM_OPTION, JVM_OPTION_SECURITY_MANAGER));
} else {
for (Map<String, String> origOption : list){
String str = origOption.get(JVM_OPTION);
if (! (str.trim().equals(JVM_OPTION_SECURITY_MANAGER) ||
str.trim().startsWith(JVM_OPTION_SECURITY_MANAGER_WITH_EQUAL))){
newOptions.add(ImmutableMap.of(JVM_OPTION, str,
MIN_VERSION, origOption.get(MIN_VERSION),
MAX_VERSION, origOption.get(MAX_VERSION)));
Map<String, String> jvmOptions = new HashMap<>(3);
jvmOptions.put(JVM_OPTION, str);
jvmOptions.put(MIN_VERSION, origOption.get(MIN_VERSION));
jvmOptions.put(MAX_VERSION, origOption.get(MAX_VERSION));
newOptions.add(Collections.unmodifiableMap(jvmOptions));
}
}
}
Expand Down
Expand Up @@ -37,11 +37,10 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]

package org.glassfish.admingui.devtests;

import com.google.common.base.Function;
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.SeleniumException;
import org.junit.*;
Expand All @@ -53,9 +52,9 @@
import java.security.SecureRandom;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.admingui.common.util.RestUtil;
import org.glassfish.admingui.devtests.util.ElementFinder;
import org.glassfish.admingui.devtests.util.SeleniumHelper;
import org.openqa.selenium.support.ui.ExpectedCondition;
Expand Down
Expand Up @@ -37,10 +37,11 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2019] Payara Foundation and/or affiliates

package org.glassfish.admingui.devtests.util;

import com.google.common.base.Function;
import com.thoughtworks.selenium.Wait;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openqa.selenium.By;
Expand Down
8 changes: 7 additions & 1 deletion appserver/appclient/client/acc/pom.xml
Expand Up @@ -253,6 +253,12 @@
<groupId>org.glassfish.main.security</groupId>
<artifactId>webservices.security</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-metadata-generator</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand All @@ -272,7 +278,7 @@
<artifactId>connectors-inbound-runtime</artifactId>
<version>${project.version}</version>
</dependency>


<dependency>
<groupId>org.glassfish.main.orb</groupId>
Expand Down
4 changes: 0 additions & 4 deletions appserver/deployment/dol/pom.xml
Expand Up @@ -167,10 +167,6 @@
<artifactId>logging-annotation-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>fish.payara.api</groupId>
<artifactId>payara-api</artifactId>
Expand Down
Expand Up @@ -79,9 +79,6 @@
import org.glassfish.internal.api.Globals;
import org.glassfish.security.common.Role;

import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.sun.enterprise.deployment.node.ApplicationNode;
import com.sun.enterprise.deployment.runtime.application.wls.ApplicationParam;
import com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping;
Expand All @@ -98,6 +95,8 @@
import com.sun.enterprise.deployment.util.DOLUtils;
import com.sun.enterprise.util.LocalStringManagerImpl;
import com.sun.enterprise.util.StringUtils;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Objects of this type encapsulate the data and behaviour of a J2EE
Expand Down Expand Up @@ -796,25 +795,23 @@ public void addScanningInclusions(List<String> inclusions) {
}

public void addScanningInclusions(List<String> inclusions, String libDir) {
this.scanningInclusions.addAll(FluentIterable.from(inclusions)
.transform(new WildcardToRegex(libDir)).toList());
this.scanningInclusions.addAll(inclusions.stream().map(new WildcardToRegex(libDir)).collect(Collectors.toList()));
}

public void addScanningExclusions(List<String> exclusions) {
addScanningExclusions(exclusions, getLibraryDirectory());
}

public void addScanningExclusions(List<String> exclusions, String libDir) {
this.scanningExclusions.addAll(FluentIterable.from(exclusions)
.transform(new WildcardToRegex(libDir)).toList());
this.scanningExclusions.addAll(exclusions.stream().map(new WildcardToRegex(libDir)).collect(Collectors.toList()));
}

public boolean isWhitelistEnabled() {
return !whitelistPackages.isEmpty();
}

public Set<String> getWhitelistPackages() {
return ImmutableSet.copyOf(whitelistPackages);
return Collections.unmodifiableSet(whitelistPackages);
}

public void addWhitelistPackage(String aPackage) {
Expand Down
Expand Up @@ -37,11 +37,10 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.deployment.node.runtime.application.gf;

import com.google.common.collect.ImmutableList;
import com.sun.enterprise.config.serverbeans.ConfigBeansUtilities;
import com.sun.enterprise.deployment.Application;
import com.sun.enterprise.deployment.ResourcePropertyDescriptor;
Expand All @@ -56,6 +55,7 @@
import com.sun.enterprise.deployment.xml.DTDRegistry;
import com.sun.enterprise.deployment.xml.RuntimeTagNames;
import com.sun.enterprise.deployment.xml.WebServicesTagNames;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.glassfish.deployment.common.ModuleDescriptor;
Expand Down Expand Up @@ -193,10 +193,10 @@ public void setElementValue(XMLElement element, String value) {
// ignore, handled in EarHandler.java
} else
if (element.getQName().equals(RuntimeTagNames.PAYARA_SCANNING_EXCLUDE)) {
descriptor.addScanningExclusions(ImmutableList.of(value));
descriptor.addScanningExclusions(Collections.singletonList(value));
} else
if (element.getQName().equals(RuntimeTagNames.PAYARA_SCANNING_INCLUDE)) {
descriptor.addScanningInclusions(ImmutableList.of(value));
descriptor.addScanningInclusions(Collections.singletonList(value));
} else
if (element.getQName().equals(RuntimeTagNames.PAYARA_WHITELIST_PACKAGE)) {
descriptor.addWhitelistPackage(value);
Expand Down
Expand Up @@ -37,16 +37,10 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.deployment.util;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -109,7 +103,10 @@
import com.sun.enterprise.deployment.node.XMLElement;
import com.sun.enterprise.deployment.xml.TagNames;
import com.sun.enterprise.util.LocalStringManagerImpl;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;

import org.glassfish.logging.annotation.LogMessageInfo;
Expand Down Expand Up @@ -166,18 +163,9 @@ public class DOLUtils {
private static final String IGNORE_WLSDD = "ignore.wlsdd";

private static final String ID_SEPARATOR = "_";
private static final Set<String> SYSTEM_PACKAGES_ =
ImmutableSet.of("com.sun", "org.glassfish", "org.apache.jasper", "fish.payara", "com.ibm.jbatch",
"org.hibernate.validator", "org.jboss.weld", "com.ctc.wstx",
"java", "javax");
private static final Set<String> SYSTEM_PACKAGES = ImmutableSet.copyOf(Collections2.transform(SYSTEM_PACKAGES_,
new Function<String, String>() {
@Override
public String apply(String input) {
return input + ".";
}
}));

private static final String[] SYSTEM_PACKAGES = {"com.sun.", "org.glassfish.", "org.apache.jasper.", "fish.payara.", "com.ibm.jbatch.",
"org.hibernate.validator.", "org.jboss.weld.", "com.ctc.wstx.", "java.", "javax."};

/** no need to creates new DOLUtils */
private DOLUtils() {
}
Expand Down Expand Up @@ -224,8 +212,9 @@ public static List<URI> getLibraryJarURIs(BundleDescriptor bundleDesc, ReadableA
* @return
*/
public static boolean isScanningAllowed(Application app, String entryName) {
boolean included = !FluentIterable.from(app.getScanningExclusions()).anyMatch(new MatchingPredicate(entryName));
return included |= FluentIterable.from(app.getScanningInclusions()).anyMatch(new MatchingPredicate(entryName));

boolean included = !app.getScanningExclusions().stream().anyMatch(new MatchingPredicate(entryName));
return included |= app.getScanningInclusions().stream().anyMatch(new MatchingPredicate(entryName));
}

private static class MatchingPredicate implements Predicate<Pattern> {
Expand All @@ -236,7 +225,7 @@ public MatchingPredicate(String entryName) {
}

@Override
public boolean apply(Pattern input) {
public boolean test(Pattern input) {
return input.matcher(entryName).matches();
}
}
Expand Down Expand Up @@ -1009,7 +998,12 @@ public static String getComponentEnvId(JndiNameEnvironment env) {
* @return true if the class is white-listed
*/
public static boolean isWhiteListed(Application application, String className) {
for (String packageName : Iterables.concat(application.getWhitelistPackages(), SYSTEM_PACKAGES)) {
for (String packageName : SYSTEM_PACKAGES) {
if (className.startsWith(packageName)) {
return true;
}
}
for (String packageName : application.getWhitelistPackages()) {
if (className.startsWith(packageName)) {
return true;
}
Expand Down
6 changes: 1 addition & 5 deletions appserver/deployment/javaee-full/pom.xml
Expand Up @@ -39,7 +39,7 @@
only if the new code is made subject to such option by the copyright
holder.

Portions Copyright [2016] [Payara Foundation and/or its affiliates]
Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Expand Down Expand Up @@ -159,10 +159,6 @@
<groupId>org.glassfish.main.security</groupId>
<artifactId>security-ee</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
</project>
Expand Up @@ -37,19 +37,17 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]

package org.glassfish.javaee.full.deployment;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.sun.enterprise.loader.ASURLClassLoader;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;

/**
* Classloader that is responsible to load the ear libraries (lib/*.jar etc)
Expand Down Expand Up @@ -79,19 +77,24 @@ public Enumeration<URL> getResources(String name) throws IOException {
Enumeration<URL> localResources = super.getResources(name);
Enumeration<URL> parentResources = getParent().getResources(name);

Enumeration<URL> combinedResources = Iterators.asEnumeration(Iterators.concat(
Lists.transform(currentBeforeParentEnabled?
ImmutableList.of(localResources, parentResources) :
ImmutableList.of(parentResources, localResources),
new Function<Enumeration<URL>, Iterator<URL>>() {
@Override
public Iterator<URL> apply(Enumeration<URL> enumeration) {
return Iterators.forEnumeration(enumeration);
}
}).iterator()
));
Enumeration<URL> combined = Collections.emptyEnumeration();

Enumeration<URL> combinedResources = currentBeforeParentEnabled?
combineEnumerations(localResources, parentResources):
combineEnumerations(parentResources, localResources);
return combinedResources;
}

private Enumeration<URL> combineEnumerations(Enumeration<URL> first, Enumeration<URL> second) {
List<URL> combinedList = new ArrayList<>();
while (first.hasMoreElements()) {
combinedList.add(first.nextElement());
}
while (second.hasMoreElements()) {
combinedList.add(second.nextElement());
}
return Collections.enumeration(combinedList);
}

@Override
protected String getClassLoaderName() {
Expand Down
Expand Up @@ -39,8 +39,6 @@
*/
package fish.payara.micro.cmd.options;

import com.google.common.base.Joiner;

import java.text.MessageFormat;
import java.util.*;

Expand Down Expand Up @@ -131,8 +129,7 @@ public RuntimeOptions(String args[]) throws ValidationException {
}
}
if (invalidArgs.size() > 0) {
String argsStr = Joiner.on(",").skipNulls().join(invalidArgs);
throw new ValidationException(MessageFormat.format(commandlogstrings.getString("notValidArguments"), argsStr));
throw new ValidationException(MessageFormat.format(commandlogstrings.getString("notValidArguments"), String.join(",", invalidArgs)));
}
}

Expand Down