Consistent ordering of Resource methods (backported from main)

This commit is contained in:
Juergen Hoeller
2023-02-15 12:35:41 +01:00
parent 0026338c00
commit 3adabf391f
4 changed files with 54 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -203,11 +204,6 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
this.encoded = original.createRelative(original.getFilename() + extension);
}
@Override
public InputStream getInputStream() throws IOException {
return this.encoded.getInputStream();
}
@Override
public boolean exists() {
return this.encoded.exists();
@@ -243,6 +239,16 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
return this.encoded.getFile();
}
@Override
public InputStream getInputStream() throws IOException {
return this.encoded.getInputStream();
}
@Override
public ReadableByteChannel readableChannel() throws IOException {
return this.encoded.readableChannel();
}
@Override
public long contentLength() throws IOException {
return this.encoded.contentLength();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -65,7 +66,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public class VersionResourceResolver extends AbstractResourceResolver {
private AntPathMatcher pathMatcher = new AntPathMatcher();
private final AntPathMatcher pathMatcher = new AntPathMatcher();
/** Map from path pattern -> VersionStrategy. */
private final Map<String, VersionStrategy> versionStrategyMap = new LinkedHashMap<>();
@@ -283,9 +284,13 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
@Override
@Nullable
public String getFilename() {
return this.original.getFilename();
public InputStream getInputStream() throws IOException {
return this.original.getInputStream();
}
@Override
public ReadableByteChannel readableChannel() throws IOException {
return this.original.readableChannel();
}
@Override
@@ -304,13 +309,14 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
@Override
public String getDescription() {
return this.original.getDescription();
@Nullable
public String getFilename() {
return this.original.getFilename();
}
@Override
public InputStream getInputStream() throws IOException {
return this.original.getInputStream();
public String getDescription() {
return this.original.getDescription();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -199,12 +200,6 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
this.encoded = original.createRelative(original.getFilename() + extension);
}
@Override
public InputStream getInputStream() throws IOException {
return this.encoded.getInputStream();
}
@Override
public boolean exists() {
return this.encoded.exists();
@@ -240,6 +235,16 @@ public class EncodedResourceResolver extends AbstractResourceResolver {
return this.encoded.getFile();
}
@Override
public InputStream getInputStream() throws IOException {
return this.encoded.getInputStream();
}
@Override
public ReadableByteChannel readableChannel() throws IOException {
return this.encoded.readableChannel();
}
@Override
public long contentLength() throws IOException {
return this.encoded.contentLength();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -65,7 +66,7 @@ import org.springframework.util.StringUtils;
*/
public class VersionResourceResolver extends AbstractResourceResolver {
private AntPathMatcher pathMatcher = new AntPathMatcher();
private final AntPathMatcher pathMatcher = new AntPathMatcher();
/** Map from path pattern -> VersionStrategy. */
private final Map<String, VersionStrategy> versionStrategyMap = new LinkedHashMap<>();
@@ -279,9 +280,13 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
@Override
@Nullable
public String getFilename() {
return this.original.getFilename();
public InputStream getInputStream() throws IOException {
return this.original.getInputStream();
}
@Override
public ReadableByteChannel readableChannel() throws IOException {
return this.original.readableChannel();
}
@Override
@@ -300,13 +305,14 @@ public class VersionResourceResolver extends AbstractResourceResolver {
}
@Override
public String getDescription() {
return this.original.getDescription();
@Nullable
public String getFilename() {
return this.original.getFilename();
}
@Override
public InputStream getInputStream() throws IOException {
return this.original.getInputStream();
public String getDescription() {
return this.original.getDescription();
}
@Override