Nullability refinements (based on IntelliJ IDEA 2018.1 introspection)

Issue: SPR-15756
This commit is contained in:
Juergen Hoeller
2018-03-29 23:50:17 +02:00
parent 1cc513d7db
commit d553ddc5b3
17 changed files with 84 additions and 107 deletions

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.
@@ -222,12 +222,14 @@ public class Jaxb2XmlDecoder extends AbstractDecoder<Object> {
this.elementDepth++;
}
if (this.elementDepth > this.barrier) {
Assert.state(this.events != null, "No XMLEvent List");
this.events.add(event);
}
if (event.isEndElement()) {
this.elementDepth--;
if (this.elementDepth == this.barrier) {
this.barrier = Integer.MAX_VALUE;
Assert.state(this.events != null, "No XMLEvent List");
return Mono.just(this.events);
}
}

View File

@@ -180,9 +180,9 @@ class DefaultPathContainer implements PathContainer {
return EMPTY_PATH;
}
Assert.isTrue(fromIndex < toIndex, () -> "fromIndex: " + fromIndex + " should be < toIndex " + toIndex);
Assert.isTrue(fromIndex >= 0 && fromIndex < elements.size(), () -> "Invalid fromIndex: " + fromIndex);
Assert.isTrue(toIndex >= 0 && toIndex <= elements.size(), () -> "Invalid toIndex: " + toIndex);
Assert.isTrue(fromIndex < toIndex, () -> "fromIndex: " + fromIndex + " should be < toIndex " + toIndex);
List<Element> subList = elements.subList(fromIndex, toIndex);
String path = subList.stream().map(Element::value).collect(Collectors.joining(""));

View File

@@ -109,9 +109,7 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
public Mono<Void> writeWith(File file, long position, long count) {
return doCommit(() ->
Mono.defer(() -> {
FileChannel source = null;
try {
source = FileChannel.open(file.toPath(), StandardOpenOption.READ);
try (FileChannel source = FileChannel.open(file.toPath(), StandardOpenOption.READ)) {
StreamSinkChannel destination = this.exchange.getResponseChannel();
Channels.transferBlocking(destination, source, position, count);
return Mono.empty();
@@ -119,17 +117,6 @@ class UndertowServerHttpResponse extends AbstractListenerServerHttpResponse impl
catch (IOException ex) {
return Mono.error(ex);
}
finally {
if (source != null) {
try {
source.close();
}
catch (IOException ex) {
// ignore
}
}
}
}));
}