Skip to content

Commit

Permalink
Fix new checkstyle violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Syer committed May 14, 2019
1 parent 3c4fc78 commit 38d8ccb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -45,11 +45,11 @@ class FluxWriter extends Writer {

private List<Object> accumulated = new ArrayList<>();

public FluxWriter(Supplier<DataBuffer> factory) {
FluxWriter(Supplier<DataBuffer> factory) {
this(factory, Charset.defaultCharset());
}

public FluxWriter(Supplier<DataBuffer> factory, Charset charset) {
FluxWriter(Supplier<DataBuffer> factory, Charset charset) {
this.factory = factory;
this.charset = charset;
}
Expand All @@ -72,7 +72,7 @@ public Publisher<? extends Publisher<? extends DataBuffer>> 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
Expand Down Expand Up @@ -111,4 +111,4 @@ public void write(Object thing) {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -119,7 +119,7 @@ protected Mono<Void> renderInternal(Map<String, Object> 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()))))
Expand All @@ -130,7 +130,7 @@ private void close(FluxWriter writer) {
try {
writer.close();
}
catch (IOException e) {
catch (IOException ex) {
writer.release();
}
}
Expand All @@ -142,7 +142,7 @@ private Template compile(Resource resource) {
return template;
}
}
catch (IOException e) {
catch (IOException ex) {
throw new IllegalStateException("Cannot close reader");
}
}
Expand All @@ -160,7 +160,7 @@ protected Mono<Void> resolveAsyncAttributes(Map<String, Object> model) {
}
}
return super.resolveAsyncAttributes(result)
.doOnSuccess(v -> model.putAll(result));
.doOnSuccess((v) -> model.putAll(result));
}

private Resource resolveResource() {
Expand All @@ -183,14 +183,14 @@ private Reader getReader(Resource resource) throws IOException {
}

private Optional<Charset> 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;
}

Expand All @@ -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();
}
}

Expand All @@ -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);
}
}

Expand Down

0 comments on commit 38d8ccb

Please sign in to comment.