From f81c01d490b853ee03142adcdab3d2f7066075c2 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 29 Apr 2014 15:26:37 +0100 Subject: [PATCH 1/2] @WebApplication->@WebAppConfiguration Fixed gh-746 --- spring-boot-docs/src/main/asciidoc/howto.adoc | 2 +- spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 51644630c7..e9874167b7 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -371,7 +371,7 @@ and then inject the actual (``local'') port as a `@Value`. For example: ---- @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class) - @WebApplication + @WebAppConfiguration @IntegrationTest("server.port:0") public class CityRepositoryIntegrationTests { diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index cb59230d88..b9326c7771 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1558,7 +1558,7 @@ interaction. For Example: ---- @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class) - @WebApplication + @WebAppConfiguration @IntegrationTest public class CityRepositoryIntegrationTests { From 471e6af2afb911bf862185070b75d51a01bdf15d Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 30 Apr 2014 11:56:04 +0300 Subject: [PATCH 2/2] Make `loader` Windows compatible The encoding of UTF-8 (et al.) chars in the JarUrlConnection has to be made explicit, otherwise Wdinows apparently does not pick the default(?). Fixes gh-711, Fixes gh-753 --- .../boot/loader/jar/JarURLConnection.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 18eb98848d..908d7bc511 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -20,14 +20,14 @@ import java.io.ByteArrayOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.Charset; import java.util.jar.Manifest; /** * {@link java.net.JarURLConnection} used to support {@link JarFile#getUrl()}. - * + * * @author Phillip Webb */ class JarURLConnection extends java.net.JarURLConnection { @@ -169,25 +169,21 @@ class JarURLConnection extends java.net.JarURLConnection { if ((length == 0) || (source.indexOf('%') < 0)) { return source; } - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(length); - for (int i = 0; i < length; i++) { - int ch = source.charAt(i); - if (ch == '%') { - if ((i + 2) >= length) { - throw new IllegalArgumentException("Invalid encoded sequence \"" - + source.substring(i) + "\""); - } - ch = decodeEscapeSequence(source, i); - i += 2; + ByteArrayOutputStream bos = new ByteArrayOutputStream(length); + for (int i = 0; i < length; i++) { + int ch = source.charAt(i); + if (ch == '%') { + if ((i + 2) >= length) { + throw new IllegalArgumentException("Invalid encoded sequence \"" + + source.substring(i) + "\""); } - bos.write(ch); + ch = decodeEscapeSequence(source, i); + i += 2; } - return new String(bos.toByteArray(), "UTF-8"); - } - catch (UnsupportedEncodingException ex) { - throw new IllegalStateException(ex); + bos.write(ch); } + return new String(bos.toByteArray(), Charset.defaultCharset()); + } private static char decodeEscapeSequence(String source, int i) {