diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/FluxWriter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/FluxWriter.java index c5de1bc7e26b..c7c2ed12be95 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/FluxWriter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/FluxWriter.java @@ -1,11 +1,11 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2019-2019 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -45,11 +45,11 @@ class FluxWriter extends Writer { private List accumulated = new ArrayList<>(); - public FluxWriter(Supplier factory) { + FluxWriter(Supplier factory) { this(factory, Charset.defaultCharset()); } - public FluxWriter(Supplier factory, Charset charset) { + FluxWriter(Supplier factory, Charset charset) { this.factory = factory; this.charset = charset; } @@ -72,7 +72,7 @@ public Publisher> getBuffers() { buffers = buffers.concatWithValues(list.toArray(new String[0])); } } - return buffers.map(string -> Mono.just(buffer().write(string, this.charset))); + return buffers.map((string) -> Mono.just(buffer().write(string, this.charset))); } @Override @@ -111,4 +111,4 @@ public void write(Object thing) { } } -} \ No newline at end of file +} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java index fad3a1813159..7343c3bae61a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -119,7 +119,7 @@ protected Mono renderInternal(Map model, MediaType content else { map = model; } - rendered = rendered.doOnSuccess(template -> template.execute(map, writer)); + rendered = rendered.doOnSuccess((template) -> template.execute(map, writer)); return rendered .thenEmpty(Mono.defer(() -> exchange.getResponse() .writeAndFlushWith(Flux.from(writer.getBuffers())))) @@ -130,7 +130,7 @@ private void close(FluxWriter writer) { try { writer.close(); } - catch (IOException e) { + catch (IOException ex) { writer.release(); } } @@ -142,7 +142,7 @@ private Template compile(Resource resource) { return template; } } - catch (IOException e) { + catch (IOException ex) { throw new IllegalStateException("Cannot close reader"); } } @@ -160,7 +160,7 @@ protected Mono resolveAsyncAttributes(Map model) { } } return super.resolveAsyncAttributes(result) - .doOnSuccess(v -> model.putAll(result)); + .doOnSuccess((v) -> model.putAll(result)); } private Resource resolveResource() { @@ -183,14 +183,14 @@ private Reader getReader(Resource resource) throws IOException { } private Optional getCharset(MediaType mediaType) { - return Optional.ofNullable(mediaType != null ? mediaType.getCharset() : null); + return Optional.ofNullable((mediaType != null) ? mediaType.getCharset() : null); } private static class FluxLambda implements Mustache.Lambda { private Publisher publisher; - public FluxLambda(Publisher publisher) { + FluxLambda(Publisher publisher) { this.publisher = publisher; } @@ -200,12 +200,12 @@ public void execute(Fragment frag, Writer out) throws IOException { if (out instanceof FluxWriter) { FluxWriter fluxWriter = (FluxWriter) out; fluxWriter.flush(); - fluxWriter.write( - Flux.from(this.publisher).map(value -> frag.execute(value))); + fluxWriter.write(Flux.from(this.publisher) + .map((value) -> frag.execute(value))); } } - catch (IOException e) { - e.printStackTrace(); + catch (IOException ex) { + ex.printStackTrace(); } } @@ -220,19 +220,19 @@ public void execute(Fragment frag, Writer out) throws IOException { frag.execute(writer); try (BufferedReader reader = new BufferedReader(new InputStreamReader( new ByteArrayInputStream(writer.toString().getBytes())))) { - reader.lines().forEach(line -> { + reader.lines().forEach((line) -> { try { out.write("data: " + line + "\n"); } - catch (IOException e) { - throw new IllegalStateException("Cannot write data", e); + catch (IOException ex) { + throw new IllegalStateException("Cannot write data", ex); } }); } out.write(new char[] { '\n', '\n' }); } - catch (IOException e) { - throw new IllegalStateException("Cannot render SSE data", e); + catch (IOException ex) { + throw new IllegalStateException("Cannot render SSE data", ex); } }