Merge branch 'jetty-9.4.x' into jetty-10.0.x

This commit is contained in:
olivier lamy 2020-12-14 09:24:17 +10:00
commit 0c1f9636b3
7 changed files with 75 additions and 89 deletions

View File

@ -159,7 +159,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
if (pathSpec == null || "".equals(pathSpec.trim()) || constraintMappings == null || constraintMappings.size() == 0)
return Collections.emptyList();
List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();
for (ConstraintMapping mapping : constraintMappings)
{
if (pathSpec.equals(mapping.getPathSpec()))
@ -183,7 +183,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
if (pathSpec == null || "".equals(pathSpec.trim()) || constraintMappings == null || constraintMappings.size() == 0)
return Collections.emptyList();
List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();
for (ConstraintMapping mapping : constraintMappings)
{
//Remove the matching mappings by only copying in non-matching mappings
@ -205,10 +205,10 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
*/
public static List<ConstraintMapping> createConstraintsWithMappingsForPath(String name, String pathSpec, ServletSecurityElement securityElement)
{
List<ConstraintMapping> mappings = new ArrayList<ConstraintMapping>();
List<ConstraintMapping> mappings = new ArrayList<>();
//Create a constraint that will describe the default case (ie if not overridden by specific HttpMethodConstraints)
Constraint httpConstraint = null;
Constraint httpConstraint;
ConstraintMapping httpConstraintMapping = null;
if (securityElement.getEmptyRoleSemantic() != EmptyRoleSemantic.PERMIT ||
@ -225,7 +225,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
}
//See Spec 13.4.1.2 p127
List<String> methodOmissions = new ArrayList<String>();
List<String> methodOmissions = new ArrayList<>();
//make constraint mappings for this url for each of the HttpMethodConstraintElements
Collection<HttpMethodConstraintElement> methodConstraintElements = securityElement.getHttpMethodConstraints();
@ -250,7 +250,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
//See spec 13.4.1.2 p127 - add an omission for every method name to the default constraint
//UNLESS the default constraint contains all default values. In that case, we won't add it. See Servlet Spec 3.1 pg 129
if (methodOmissions.size() > 0 && httpConstraintMapping != null)
httpConstraintMapping.setMethodOmissions(methodOmissions.toArray(new String[methodOmissions.size()]));
httpConstraintMapping.setMethodOmissions(methodOmissions.toArray(new String[0]));
return mappings;
}
@ -394,10 +394,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
_constraintRoles.reset();
if (_constraintMappings != null)
{
for (ConstraintMapping mapping : _constraintMappings)
{
processConstraintMapping(mapping);
}
_constraintMappings.stream().forEach(this::processConstraintMapping);
}
//Servlet Spec 3.1 pg 147 sec 13.8.4.2 log paths for which there are uncovered http methods
@ -424,7 +421,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
Map<String, RoleInfo> mappings = _constraintRoles.get(PathMappings.asPathSpec(mapping.getPathSpec()));
if (mappings == null)
{
mappings = new HashMap<String, RoleInfo>();
mappings = new HashMap<>();
_constraintRoles.put(mapping.getPathSpec(), mappings);
}
RoleInfo allMethodsRoleInfo = mappings.get(ALL_METHODS);
@ -579,7 +576,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
if (roleInfo == null)
{
//No specific http-method names matched
List<RoleInfo> applicableConstraints = new ArrayList<RoleInfo>();
List<RoleInfo> applicableConstraints = new ArrayList<>();
//Get info for constraint that matches all methods if it exists
RoleInfo all = mappings.get(ALL_METHODS);
@ -767,7 +764,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
if (_denyUncoveredMethods)
return Collections.emptySet();
Set<String> uncoveredPaths = new HashSet<String>();
Set<String> uncoveredPaths = new HashSet<>();
for (MappedResource<Map<String, RoleInfo>> resource : _constraintRoles)
{
@ -839,7 +836,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
return Collections.emptySet();
String[] strings = omission.split("\\.");
Set<String> methods = new HashSet<String>();
Set<String> methods = new HashSet<>();
for (int i = 0; i < strings.length - 1; i++)
{
methods.add(strings[i]);

View File

@ -66,13 +66,10 @@ public class Licensing
System.err.printf(" + contains software not covered by the Eclipse Public License!%n");
System.err.printf(" + has not been audited for compliance with its license%n");
for (String key : licenseMap.keySet())
for (Map.Entry<String, List<String>> entry : licenseMap.entrySet())
{
System.err.printf("%n Module: %s%n", key);
for (String line : licenseMap.get(key))
{
System.err.printf(" + %s%n", line);
}
System.err.printf("%n Module: %s%n", entry.getKey());
entry.getValue().forEach(line -> System.err.printf(" + %s%n", line));
}
boolean licenseAck = false;

View File

@ -251,11 +251,11 @@ public class Scanner extends AbstractLifeCycle
*/
public interface DiscreteListener extends Listener
{
public void fileChanged(String filename) throws Exception;
void fileChanged(String filename) throws Exception;
public void fileAdded(String filename) throws Exception;
void fileAdded(String filename) throws Exception;
public void fileRemoved(String filename) throws Exception;
void fileRemoved(String filename) throws Exception;
}
/**
@ -271,11 +271,11 @@ public class Scanner extends AbstractLifeCycle
*/
public interface ScanCycleListener extends Listener
{
public default void scanStarted(int cycle) throws Exception
default void scanStarted(int cycle) throws Exception
{
}
public default void scanEnded(int cycle) throws Exception
default void scanEnded(int cycle) throws Exception
{
}
}
@ -636,11 +636,12 @@ public class Scanner extends AbstractLifeCycle
private Map<String, MetaData> scanFiles()
{
Map<String, MetaData> currentScan = new HashMap<>();
for (Path p : _scannables.keySet())
for (Map.Entry<Path, IncludeExcludeSet<PathMatcher, Path>> entry : _scannables.entrySet())
{
try
{
Files.walkFileTree(p, EnumSet.allOf(FileVisitOption.class),_scanDepth, new Visitor(p, _scannables.get(p), currentScan));
Files.walkFileTree(entry.getKey(), EnumSet.allOf(FileVisitOption.class),_scanDepth,
new Visitor(entry.getKey(), entry.getValue(), currentScan));
}
catch (IOException e)
{
@ -671,10 +672,10 @@ public class Scanner extends AbstractLifeCycle
}
// Handle new and changed files
for (String file : currentScan.keySet())
for (Map.Entry<String, MetaData> entry : currentScan.entrySet())
{
MetaData current = currentScan.get(file);
MetaData previous = oldScan.get(file);
MetaData current = entry.getValue();
MetaData previous = oldScan.get(entry.getKey());
if (previous == null)
{
@ -700,9 +701,9 @@ public class Scanner extends AbstractLifeCycle
//Unchanged file: if it was previously
//ADDED, we can now send the ADDED event.
if (previous._status == Status.ADDED)
changes.put(file, Notification.ADDED);
changes.put(entry.getKey(), Notification.ADDED);
else if (previous._status == Status.CHANGED)
changes.put(file, Notification.CHANGED);
changes.put(entry.getKey(), Notification.CHANGED);
current._status = Status.STABLE;
}

View File

@ -57,16 +57,9 @@ public class FragmentConfiguration extends AbstractConfiguration
Map<Resource, Resource> frags = (Map<Resource, Resource>)context.getAttribute(FRAGMENT_RESOURCES);
if (frags != null)
{
for (Resource key : frags.keySet())
for (Map.Entry<Resource, Resource> entry : frags.entrySet())
{
if (key.isDirectory()) //tolerate the case where the library is a directory, not a jar. useful for OSGi for example
{
metaData.addFragmentDescriptor(key, new FragmentDescriptor(frags.get(key)));
}
else //the standard case: a jar most likely inside WEB-INF/lib
{
metaData.addFragmentDescriptor(key, new FragmentDescriptor(frags.get(key)));
}
metaData.addFragmentDescriptor(entry.getKey(), new FragmentDescriptor(entry.getValue()));
}
}
}

View File

@ -458,7 +458,7 @@ public class MetaData
if (isOrdered())
{
orderedWebInfJars = getWebInfResources(true);
List<String> orderedLibs = new ArrayList<String>();
List<String> orderedLibs = new ArrayList<>();
for (Resource webInfJar : orderedWebInfJars)
{
//get just the name of the jar file
@ -611,12 +611,12 @@ public class MetaData
*/
public Resource getJarForFragmentName(String name)
{
Resource jar = null;
FragmentDescriptor f = getFragmentDescriptor(name);
if (f == null)
return null;
Resource jar = null;
for (Map.Entry<Resource, FragmentDescriptor> entry : _webFragmentResourceMap.entrySet())
{
if (entry.getValue().equals(f))

View File

@ -54,7 +54,7 @@ public class XmlAppendable
{
_out = out;
_indent = indent;
_out.append("<?xml version=\"1.0\" encoding=\"" + encoding + "\"?>\n");
_out.append("<?xml version=\"1.0\" encoding=\"").append(encoding).append("\"?>\n");
}
public XmlAppendable openTag(String tag, Map<String, String> attributes) throws IOException
@ -146,11 +146,10 @@ public class XmlAppendable
private void attributes(Map<String, String> attributes) throws IOException
{
for (String k : attributes.keySet())
for (Map.Entry<String, String> entry : attributes.entrySet())
{
String v = attributes.get(k);
_out.append(' ').append(k).append("=\"");
content(v);
_out.append(' ').append(entry.getKey()).append("=\"");
content(entry.getValue());
_out.append('"');
}
}

View File

@ -1811,10 +1811,9 @@ public class XmlConfiguration
if (properties.size() > 0)
{
Map<String, String> props = new HashMap<>();
for (Object key : properties.keySet())
{
props.put(key.toString(), String.valueOf(properties.get(key)));
}
properties.entrySet().stream()
.forEach(objectObjectEntry -> props.put(objectObjectEntry.getKey().toString(),
String.valueOf(objectObjectEntry.getValue())));
configuration.getProperties().putAll(props);
}