[Spring] Spotbugs static class and default encoding (#2609)

* add static modifier - mvn verify passes

* specify charset, mvn verify works, compiles and clean on spotbugs in my project

* update samples as per contribution guide; mvn integration-test passes

* commit rest of samples

* fix missing newline at EOF

* lots of new newlines

* needed to run mvn clean beforehand...
This commit is contained in:
Paul Brabban 2019-04-10 11:03:35 +01:00 committed by William Cheng
parent 81f970e946
commit b5ae21b090
22 changed files with 26 additions and 24 deletions

View File

@ -1,6 +1,7 @@
package {{apiPackage}};
{{#reactive}}
import java.nio.charset.StandardCharsets;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
@ -27,7 +28,7 @@ public class ApiUtil {
{{/reactive}}
{{#reactive}}
public static Mono<Void> getExampleResponse(ServerWebExchange exchange, String example) {
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes())));
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes(StandardCharsets.UTF_8))));
}
{{/reactive}}
}
}

View File

@ -41,7 +41,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -27,7 +27,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -26,7 +26,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -27,7 +27,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -26,7 +26,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -27,7 +27,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -1,11 +1,12 @@
package org.openapitools.api;
import java.nio.charset.StandardCharsets;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
public class ApiUtil {
public static Mono<Void> getExampleResponse(ServerWebExchange exchange, String example) {
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes())));
return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes(StandardCharsets.UTF_8))));
}
}
}

View File

@ -26,7 +26,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -26,7 +26,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}

View File

@ -26,7 +26,7 @@ public class OpenAPI2SpringBoot implements CommandLineRunner {
new SpringApplication(OpenAPI2SpringBoot.class).run(args);
}
class ExitException extends RuntimeException implements ExitCodeGenerator {
static class ExitException extends RuntimeException implements ExitCodeGenerator {
private static final long serialVersionUID = 1L;
@Override

View File

@ -16,4 +16,4 @@ public class ApiUtil {
throw new RuntimeException(e);
}
}
}
}