Polishing (collapsed if checks, consistent downcasts, refined javadoc)

This commit is contained in:
Juergen Hoeller
2018-03-08 18:11:57 +01:00
parent 0f7485b01d
commit 139dc1d373
50 changed files with 336 additions and 435 deletions

View File

@@ -56,7 +56,8 @@ public class DataBufferEncoder extends AbstractEncoder<DataBuffer> {
}
@Override
public Long getContentLength(DataBuffer dataBuffer, MimeType mimeType) {
public Long getContentLength(DataBuffer dataBuffer, @Nullable MimeType mimeType) {
return (long) dataBuffer.readableByteCount();
}
}

View File

@@ -493,14 +493,12 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
for (Resource rootDirResource : rootDirResources) {
rootDirResource = resolveRootDirResource(rootDirResource);
URL rootDirUrl = rootDirResource.getURL();
if (equinoxResolveMethod != null) {
if (rootDirUrl.getProtocol().startsWith("bundle")) {
URL resolvedUrl = (URL) ReflectionUtils.invokeMethod(equinoxResolveMethod, null, rootDirUrl);
if (resolvedUrl != null) {
rootDirUrl = resolvedUrl;
}
rootDirResource = new UrlResource(rootDirUrl);
if (equinoxResolveMethod != null && rootDirUrl.getProtocol().startsWith("bundle")) {
URL resolvedUrl = (URL) ReflectionUtils.invokeMethod(equinoxResolveMethod, null, rootDirUrl);
if (resolvedUrl != null) {
rootDirUrl = resolvedUrl;
}
rootDirResource = new UrlResource(rootDirUrl);
}
if (rootDirUrl.getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
result.addAll(VfsResourceMatchingDelegate.findMatchingResources(rootDirUrl, subPattern, getPathMatcher()));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -184,13 +184,10 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
*/
protected void startPrefixMapping(@Nullable String prefix, String namespace) throws SAXException {
if (getContentHandler() != null) {
if (getContentHandler() != null && StringUtils.hasLength(namespace)) {
if (prefix == null) {
prefix = "";
}
if (!StringUtils.hasLength(namespace)) {
return;
}
if (!namespace.equals(this.namespaces.get(prefix))) {
getContentHandler().startPrefixMapping(prefix, namespace);
this.namespaces.put(prefix, namespace);
@@ -203,11 +200,9 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#endPrefixMapping(String)
*/
protected void endPrefixMapping(String prefix) throws SAXException {
if (getContentHandler() != null) {
if (this.namespaces.containsKey(prefix)) {
getContentHandler().endPrefixMapping(prefix);
this.namespaces.remove(prefix);
}
if (getContentHandler() != null && this.namespaces.containsKey(prefix)) {
getContentHandler().endPrefixMapping(prefix);
this.namespaces.remove(prefix);
}
}