Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720 Issue: SPR-15792
This commit is contained in:
@@ -30,10 +30,7 @@ import rx.RxReactiveStreams;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import static org.springframework.core.ReactiveTypeDescriptor.multiValue;
|
||||
import static org.springframework.core.ReactiveTypeDescriptor.noValue;
|
||||
import static org.springframework.core.ReactiveTypeDescriptor.singleOptionalValue;
|
||||
import static org.springframework.core.ReactiveTypeDescriptor.singleRequiredValue;
|
||||
import static org.springframework.core.ReactiveTypeDescriptor.*;
|
||||
|
||||
/**
|
||||
* A registry of adapters to adapt a Reactive Streams {@link Publisher} to/from
|
||||
@@ -250,7 +247,7 @@ public class ReactiveAdapterRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Publisher<T> toPublisher(Object source) {
|
||||
public <T> Publisher<T> toPublisher(@Nullable Object source) {
|
||||
Publisher<T> publisher = super.toPublisher(source);
|
||||
return (isMultiValue() ? Flux.from(publisher) : Mono.from(publisher));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
||||
|
||||
private final MultiValueMap<String, AnnotationAttributes> attributesMap;
|
||||
|
||||
@Nullable
|
||||
private final Map<String, Set<String>> metaAnnotationMap;
|
||||
|
||||
|
||||
@@ -83,13 +82,11 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.metaAnnotationMap != null) {
|
||||
Set<String> metaAnnotationTypeNames = new LinkedHashSet<>(visited.size());
|
||||
for (Annotation ann : visited) {
|
||||
metaAnnotationTypeNames.add(ann.annotationType().getName());
|
||||
}
|
||||
this.metaAnnotationMap.put(annotationClass.getName(), metaAnnotationTypeNames);
|
||||
Set<String> metaAnnotationTypeNames = new LinkedHashSet<>(visited.size());
|
||||
for (Annotation ann : visited) {
|
||||
metaAnnotationTypeNames.add(ann.annotationType().getName());
|
||||
}
|
||||
this.metaAnnotationMap.put(annotationClass.getName(), metaAnnotationTypeNames);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
|
||||
|
||||
private String xmlVersion = DEFAULT_XML_VERSION;
|
||||
|
||||
@Nullable
|
||||
private String encoding;
|
||||
|
||||
|
||||
@@ -77,7 +78,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxEventXMLReader(XMLEventReader reader) {
|
||||
Assert.notNull(reader, "'reader' must not be null");
|
||||
Assert.notNull(reader, "XMLEventReader must not be null");
|
||||
try {
|
||||
XMLEvent event = reader.peek();
|
||||
if (event != null && !(event.isStartDocument() || event.isStartElement())) {
|
||||
@@ -189,6 +190,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
|
||||
return xmlVersion;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
@@ -48,22 +48,13 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
class StaxResult extends SAXResult {
|
||||
|
||||
@Nullable
|
||||
private XMLEventWriter eventWriter;
|
||||
|
||||
@Nullable
|
||||
private XMLStreamWriter streamWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
|
||||
* @param streamWriter the {@code XMLStreamWriter} to write to
|
||||
*/
|
||||
public StaxResult(XMLStreamWriter streamWriter) {
|
||||
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
|
||||
super.setHandler(handler);
|
||||
super.setLexicalHandler(handler);
|
||||
this.streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}.
|
||||
* @param eventWriter the {@code XMLEventWriter} to write to
|
||||
@@ -75,6 +66,17 @@ class StaxResult extends SAXResult {
|
||||
this.eventWriter = eventWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
|
||||
* @param streamWriter the {@code XMLStreamWriter} to write to
|
||||
*/
|
||||
public StaxResult(XMLStreamWriter streamWriter) {
|
||||
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
|
||||
super.setHandler(handler);
|
||||
super.setLexicalHandler(handler);
|
||||
this.streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code XMLEventWriter} used by this {@code StaxResult}.
|
||||
|
||||
@@ -47,23 +47,13 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
class StaxSource extends SAXSource {
|
||||
|
||||
@Nullable
|
||||
private XMLEventReader eventReader;
|
||||
|
||||
@Nullable
|
||||
private XMLStreamReader streamReader;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
|
||||
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
* {@code XMLStreamConstants.START_ELEMENT} state.
|
||||
* @param streamReader the {@code XMLStreamReader} to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxSource(XMLStreamReader streamReader) {
|
||||
super(new StaxStreamXMLReader(streamReader), new InputSource());
|
||||
this.streamReader = streamReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLEventReader}.
|
||||
* The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
@@ -76,6 +66,18 @@ class StaxSource extends SAXSource {
|
||||
this.eventReader = eventReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
|
||||
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
* {@code XMLStreamConstants.START_ELEMENT} state.
|
||||
* @param streamReader the {@code XMLStreamReader} to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxSource(XMLStreamReader streamReader) {
|
||||
super(new StaxStreamXMLReader(streamReader), new InputSource());
|
||||
this.streamReader = streamReader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code XMLEventReader} used by this {@code StaxSource}.
|
||||
|
||||
@@ -51,6 +51,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
|
||||
|
||||
private String xmlVersion = DEFAULT_XML_VERSION;
|
||||
|
||||
@Nullable
|
||||
private String encoding;
|
||||
|
||||
|
||||
@@ -62,7 +63,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxStreamXMLReader(XMLStreamReader reader) {
|
||||
Assert.notNull(reader, "'reader' must not be null");
|
||||
Assert.notNull(reader, "XMLStreamReader must not be null");
|
||||
int event = reader.getEventType();
|
||||
if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) {
|
||||
throw new IllegalStateException("XMLEventReader not at start of document or element");
|
||||
@@ -166,6 +167,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
|
||||
return xmlVersion;
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user